tokens

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 11, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

README

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessToken

type AccessToken interface {
	// Default access token properties
	ClientID() (string, bool)
	Exp() (int64, bool)
	Iat() (int64, bool)
	Iss() (string, bool)
	Jti() (string, bool)
	Scope() (string, bool)
	Sub() (string, bool)
	// Common convenience properties:
	Aud() (interface{}, bool)
	Nbf() (int64, bool)
	Typ() (string, bool)
	// Other convenience methods:
	RawClaims() Claims
}

AccessToken represents an access token.

func DefaultAccessToken

func DefaultAccessToken(claims Claims) AccessToken

DefaultAccessToken returns an instacne of the access token. Call this function using claims returned from jwks.Validator.ValidateToken(string).

type Claims

type Claims map[string]interface{}

Claims represents token claims.

func (Claims) GetClaim

func (c Claims) GetClaim(claim string) (interface{}, bool)

func (Claims) GetClaimMustString

func (c Claims) GetClaimMustString(claim string) (string, bool)

func (Claims) HasClaim

func (c Claims) HasClaim(claim string) bool

type IDToken

type IDToken interface {

	// https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims
	Birthdate() (string, bool)
	Email() (string, bool)
	EmailVerified() (bool, bool)
	FamilyName() (string, bool)
	Gender() (string, bool)
	MiddleName() (string, bool)
	Name() (string, bool)
	Nickname() (string, bool)
	PhoneNumber() (string, bool)
	PhoneNumberVerified() (bool, bool)
	Picture() (string, bool)
	PreferredUsername() (string, bool)
	Profile() (string, bool)
	Sub() (string, bool)
	UpdatedAt() (int64, bool)
	Website() (string, bool)
	ZoneInfo() (string, bool)

	// Other convenient documented claims:
	// https://openid.net/specs/openid-connect-core-1_0.html#AddressClaim
	Address() (interface{}, bool)
	// https://openid.net/specs/openid-connect-core-1_0.html#CodeIDToken
	AtHash() (string, bool)
	// https://openid.net/specs/openid-connect-core-1_0.html#HybridIDToken
	CHash() (string, bool)
	// https://openid.net/specs/openid-connect-core-1_0.html#SelfIssuedValidation
	SubJWK() (interface{}, bool)
}

IDToken represents the ID token.

func DefaultIDToken

func DefaultIDToken(claims Claims) IDToken

DefaultIDToken returns an instacne of the ID token. Call this function using claims returned from jwks.Validator.ValidateToken(string).

type JWT

type JWT interface {
	AccessToken() string
	IDToken() string
	ExpiresIn() int64
	RefreshExpiresIn() int64
	RefreshToken() string
	TokenType() string
	NotBeforePolicy() int64
	SessionState() string
	Scope() string
}

JWT is a JWT

func DefaultJWT

func DefaultJWT(rawData []byte) (JWT, error)

DefaultJWT tries to parse a JWT from bytes using the default implementation.

type RefreshToken

type RefreshToken interface {
	// Default refresh token properties
	Azp() (string, bool)
	Exp() (int64, bool)
	Iat() (int64, bool)
	Iss() (string, bool)
	Jti() (string, bool)
	Scope() (string, bool)
	Sub() (string, bool)
	// Common convenience properties:
	Aud() (interface{}, bool)
	Nbf() (int64, bool)
	Typ() (string, bool)
	// Other convenience methods:
	RawClaims() Claims
}

RefreshToken represents a refresh token.

func DefaultRefreshToken

func DefaultRefreshToken(claims Claims) RefreshToken

DefaultRefreshToken returns an instacne of the refresh token. Call this function using claims returned from jwks.Validator.ValidateToken(string).

type TokenType

type TokenType string

TokenType is a token type.

const (
	// BearerTokenType is a bearer token type.
	BearerTokenType TokenType = "Bearer"
	// RefreshTokenType is a refresh token type.
	RefreshTokenType TokenType = "Refresh"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL