// Generate identity information from given JWT by extracting subject and tenant claims.
// Note that this function does not perform any form of token signature
// verification.
Generate identity information from given JWT by extracting subject and tenant claims.
Note that this function does not perform any form of token signature
verification.
// Generate identity information from given JWT by extracting subject and tenant claims . // Note that this function does not perform any form of token signature // verification .
func ExtractIdentity(token string) (id Identity, err error) {
	var (
		claims []byte
		jwt    []string
	)
	jwt = strings.Split(token, ".")
	if len(jwt) != 3 {
		return id, errors.New("identity: incorrect token format")
	}
	claims, err = base64.RawURLEncoding.DecodeString(jwt[1])
	if err != nil {
		return id, errors.Wrap(err,
			"identity: failed to decode base64 JWT claims")
	}
	err = json.Unmarshal(claims, &id)
	if err != nil {
		return id, errors.Wrap(err,
			"identity: failed to decode JSON JWT claims")
	}
	return id, id.Validate()
}
func ExtractIdentity ( token string ) ( id Identity , err error ) { var ( claims [ ] byte jwt [ ] string ) jwt = strings . Split ( token , " " ) if len ( jwt ) != 3 { return id , errors . New ( " " ) } claims , err = base64 . RawURLEncoding . DecodeString ( jwt [ 1 ] ) if err != nil { return id , errors . Wrap ( err , " " ) } err = json . Unmarshal ( claims , & id ) if err != nil { return id , errors . Wrap ( err , " " ) } return id , id . Validate ( ) }
Generate identity information from given JWT by extracting subject and tenant claims.
Generate identity information from given JWT by extracting subject and tenant claims .