當前位置: 首頁>>代碼示例>>Golang>>正文


Golang jwt.Claims函數代碼示例

本文整理匯總了Golang中github.com/SermoDigital/jose/jwt.Claims函數的典型用法代碼示例。如果您正苦於以下問題:Golang Claims函數的具體用法?Golang Claims怎麽用?Golang Claims使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了Claims函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: Claims

// Claims helps implements jwt.JWT.
func (j *jws) Claims() jwt.Claims {
	if j.isJWT {
		if c, ok := j.payload.v.(Claims); ok {
			return jwt.Claims(c)
		}
	}
	return nil
}
開發者ID:andrefreitas,項目名稱:jose,代碼行數:9,代碼來源:jwt.go

示例2: NewValidator

// NewValidator returns a pointer to a jwt.Validator structure containing
// the info to be used in the validation of a JWT.
func NewValidator(c Claims, exp, nbf float64, fn func(Claims) error) *jwt.Validator {
	return &jwt.Validator{
		Expected: jwt.Claims(c),
		EXP:      exp,
		NBF:      nbf,
		Fn:       Conv(fn),
	}
}
開發者ID:andrefreitas,項目名稱:jose,代碼行數:10,代碼來源:jwt.go

示例3: Validate

func (j *jws) Validate(key interface{}, m crypto.SigningMethod, v ...*jwt.Validator) error {
	if j.isJWT {
		if err := j.Verify(key, m); err != nil {
			return err
		}
		var v1 jwt.Validator
		if len(v) > 0 {
			v1 = *v[0]
		}
		c, ok := j.payload.v.(Claims)
		if ok {
			if err := v1.Validate(j); err != nil {
				return err
			}
			return jwt.Claims(c).Validate(float64(time.Now().Unix()), v1.EXP, v1.NBF)
		}
	}
	return ErrIsNotJWT
}
開發者ID:andrefreitas,項目名稱:jose,代碼行數:19,代碼來源:jwt.go

示例4: NotBefore

// NotBefore retrieves claim "nbf" per its type in
// https://tools.ietf.org/html/rfc7519#section-4.1.5
func (c Claims) NotBefore() (time.Time, bool) {
	return jwt.Claims(c).NotBefore()
}
開發者ID:fujitsu-cf,項目名稱:cli,代碼行數:5,代碼來源:claims.go

示例5: Audience

// Audience retrieves claim "aud" per its type in
// https://tools.ietf.org/html/rfc7519#section-4.1.3
func (c Claims) Audience() ([]string, bool) {
	return jwt.Claims(c).Audience()
}
開發者ID:fujitsu-cf,項目名稱:cli,代碼行數:5,代碼來源:claims.go

示例6: Issuer

// Issuer retrieves claim "iss" per its type in
// https://tools.ietf.org/html/rfc7519#section-4.1.1
func (c Claims) Issuer() (string, bool) {
	return jwt.Claims(c).Issuer()
}
開發者ID:fujitsu-cf,項目名稱:cli,代碼行數:5,代碼來源:claims.go

示例7: MarshalJSON

// MarshalJSON implements json.Marshaler for Claims.
func (c Claims) MarshalJSON() ([]byte, error) {
	return jwt.Claims(c).MarshalJSON()
}
開發者ID:fujitsu-cf,項目名稱:cli,代碼行數:4,代碼來源:claims.go

示例8: Del

// Del removes the value that corresponds with key from the Claims.
func (c Claims) Del(key string) {
	jwt.Claims(c).Del(key)
}
開發者ID:fujitsu-cf,項目名稱:cli,代碼行數:4,代碼來源:claims.go

示例9: SetJWTID

// SetJWTID sets claim "jti" per its type in
// https://tools.ietf.org/html/rfc7519#section-4.1.7
func (c Claims) SetJWTID(uniqueID string) {
	jwt.Claims(c).SetJWTID(uniqueID)
}
開發者ID:fujitsu-cf,項目名稱:cli,代碼行數:5,代碼來源:claims.go

示例10: RemoveNotBefore

// RemoveNotBefore deletes claim "nbf" from c.
func (c Claims) RemoveNotBefore() {
	jwt.Claims(c).NotBefore()
}
開發者ID:fujitsu-cf,項目名稱:cli,代碼行數:4,代碼來源:claims.go

示例11: RemoveExpiration

// RemoveExpiration deletes claim "exp" from c.
func (c Claims) RemoveExpiration() {
	jwt.Claims(c).RemoveExpiration()
}
開發者ID:fujitsu-cf,項目名稱:cli,代碼行數:4,代碼來源:claims.go

示例12: RemoveAudience

// RemoveAudience deletes claim "aud" from c.
func (c Claims) RemoveAudience() {
	jwt.Claims(c).Audience()
}
開發者ID:fujitsu-cf,項目名稱:cli,代碼行數:4,代碼來源:claims.go

示例13: RemoveSubject

// RemoveSubject deletes claim "sub" from c.
func (c Claims) RemoveSubject() {
	jwt.Claims(c).RemoveIssuer()
}
開發者ID:fujitsu-cf,項目名稱:cli,代碼行數:4,代碼來源:claims.go

示例14: JWTID

// JWTID retrieves claim "jti" per its type in
// https://tools.ietf.org/html/rfc7519#section-4.1.7
func (c Claims) JWTID() (string, bool) {
	return jwt.Claims(c).JWTID()
}
開發者ID:fujitsu-cf,項目名稱:cli,代碼行數:5,代碼來源:claims.go

示例15: IssuedAt

// IssuedAt retrieves claim "iat" per its type in
// https://tools.ietf.org/html/rfc7519#section-4.1.6
func (c Claims) IssuedAt() (float64, bool) {
	return jwt.Claims(c).IssuedAt()
}
開發者ID:andrefreitas,項目名稱:jose,代碼行數:5,代碼來源:claims.go


注:本文中的github.com/SermoDigital/jose/jwt.Claims函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。