forked from mirror/jwt
capture raw string when parsing a token
This commit is contained in:
parent
51b517e77a
commit
32c540957a
3
jwt.go
3
jwt.go
|
@ -17,6 +17,7 @@ type Keyfunc func(*Token) ([]byte, error)
|
||||||
|
|
||||||
// A JWT Token
|
// A JWT Token
|
||||||
type Token struct {
|
type Token struct {
|
||||||
|
Raw string
|
||||||
Header map[string]interface{}
|
Header map[string]interface{}
|
||||||
Claims map[string]interface{}
|
Claims map[string]interface{}
|
||||||
Method SigningMethod
|
Method SigningMethod
|
||||||
|
@ -81,7 +82,7 @@ func (t *Token) SigningString() (string, error) {
|
||||||
func Parse(tokenString string, keyFunc Keyfunc) (token *Token, err error) {
|
func Parse(tokenString string, keyFunc Keyfunc) (token *Token, err error) {
|
||||||
parts := strings.Split(tokenString, ".")
|
parts := strings.Split(tokenString, ".")
|
||||||
if len(parts) == 3 {
|
if len(parts) == 3 {
|
||||||
token = new(Token)
|
token = &Token{Raw: tokenString}
|
||||||
// parse Header
|
// parse Header
|
||||||
var headerBytes []byte
|
var headerBytes []byte
|
||||||
if headerBytes, err = DecodeSegment(parts[0]); err != nil {
|
if headerBytes, err = DecodeSegment(parts[0]); err != nil {
|
||||||
|
|
Loading…
Reference in New Issue