// Valid time based claims "exp, iat, nbf".
// There is no accounting for clock skew.
// As well, if any of the above claims are not in the token, it will still
// be considered a valid claim.
Valid time based claims "exp, iat, nbf".
There is no accounting for clock skew.
As well, if any of the above claims are not in the token, it will still
be considered a valid claim.
// Valid time based claims " exp iat nbf " . // There is no accounting for clock skew . // As well if any of the above claims are not in the token it will still // be considered a valid claim .
func (c Oauth2Claims) Valid() error {
	vErr := new(jwt.ValidationError)
	now := timeutil.Now().Unix()
	if !c.VerifyExpiresAt(now, false) {
		delta := time.Unix(now, 0).Sub(time.Unix(c.ExpiresAt, 0))
		vErr.Inner = fmt.Errorf("token is expired by %v", delta)
		vErr.Errors |= jwt.ValidationErrorExpired
	}
	if !c.VerifyIssuedAt(now, false) {
		vErr.Inner = fmt.Errorf("token used before issued")
		vErr.Errors |= jwt.ValidationErrorIssuedAt
	}
	if !c.VerifyNotBefore(now, false) {
		vErr.Inner = fmt.Errorf("token is not valid yet")
		vErr.Errors |= jwt.ValidationErrorNotValidYet
	}
	if vErr.Errors == 0 {
		return nil
	}
	return vErr
}
func ( c Oauth2Claims ) Valid ( ) error { vErr := new ( jwt . ValidationError ) now := timeutil . Now ( ) . Unix ( ) if ! c . VerifyExpiresAt ( now , false ) { delta := time . Unix ( now , 0 ) . Sub ( time . Unix ( c . ExpiresAt , 0 ) ) vErr . Inner = fmt . Errorf ( " " , delta ) vErr . Errors |= jwt . ValidationErrorExpired } if ! c . VerifyIssuedAt ( now , false ) { vErr . Inner = fmt . Errorf ( " " ) vErr . Errors |= jwt . ValidationErrorIssuedAt } if ! c . VerifyNotBefore ( now , false ) { vErr . Inner = fmt . Errorf ( " " ) vErr . Errors |= jwt . ValidationErrorNotValidYet } if vErr . Errors == 0 { return nil } return vErr }
Valid time based claims "exp, iat, nbf".
Valid time based claims " exp iat nbf " .
// The claims below are optional, by default, so if they are set to the // default value in Go, let's not fail the verification for them.