token

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	InvalidTokenError        = fmt.Errorf("invalid token")
	UnexpectedIssuerError    = fmt.Errorf("unexpected issuer")
	UnexpectedAudienceError  = fmt.Errorf("unexpected audience")
	UnexpectedTokenTypeError = fmt.Errorf("unexpected token type")
	UnexpectedClientIDError  = fmt.Errorf("unexpected client_id")
)
View Source
var (
	NotJWEError = errors.New("not a valid JWE data")
)

Functions

func TokenHash

func TokenHash(token string) string

Types

type AccessTokenClaims

type AccessTokenClaims struct {
	OIDCClaims

	Scope string `json:"scope,omitempty"`
}

func (AccessTokenClaims) Validate

func (claims AccessTokenClaims) Validate(issuer *config.URL) error

type CodeClaims

type CodeClaims struct {
	OIDCClaims

	ClientID    string `json:"client_id"`
	RedirectURI string `json:"redirect_uri"`
	Nonce       string `json:"nonce,omitempty"`
	Scope       string `json:"scope,omitempty"`
}

func (CodeClaims) Validate

func (claims CodeClaims) Validate(issuer *config.URL) error

type ExtraClaims

type ExtraClaims map[string]interface{}

type IDTokenClaims

type IDTokenClaims struct {
	OIDCClaims

	Nonce           string      `json:"nonce,omitempty"`
	CodeHash        string      `json:"c_hash,omitempty"`
	AccessTokenHash string      `json:"at_hash,omitempty"`
	ExtraClaims     ExtraClaims `json:"-"`
}

func (IDTokenClaims) MarshalJSON

func (claims IDTokenClaims) MarshalJSON() ([]byte, error)

func (*IDTokenClaims) UnmarshalJSON

func (claims *IDTokenClaims) UnmarshalJSON(data []byte) error

func (IDTokenClaims) Validate

func (claims IDTokenClaims) Validate(issuer *config.URL, audience string) error

type JWK

type JWK struct {
	KeyID     string `json:"kid"`
	Use       string `json:"use"`
	Algorithm string `json:"alg"`
	KeyType   string `json:"kty"`
	E         string `json:"e"`
	N         string `json:"n"`
}

type LoginTokenClaims

type LoginTokenClaims struct {
	OIDCClaims

	ClientID string `json:"client_id"`
}

func (LoginTokenClaims) Validate

func (claims LoginTokenClaims) Validate(issuer *config.URL) error

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

func GenerateManager

func GenerateManager() (Manager, error)

func NewManager

func NewManager(private *rsa.PrivateKey) (Manager, error)

func NewManagerFromFile

func NewManagerFromFile(file io.Reader) (Manager, error)

func (Manager) CreateAccessToken

func (m Manager) CreateAccessToken(issuer *config.URL, subject, scope string, authTime time.Time, expiresIn time.Duration) (string, error)

func (Manager) CreateCode

func (m Manager) CreateCode(issuer *config.URL, subject, clientID, redirectURI, scope, nonce string, authTime time.Time, expiresIn time.Duration) (string, error)

func (Manager) CreateIDToken

func (m Manager) CreateIDToken(issuer *config.URL, subject, audience, nonce, code, accessToken string, extraClaims ExtraClaims, authTime time.Time, expiresIn time.Duration) (string, error)

func (Manager) CreateLoginToken

func (m Manager) CreateLoginToken(issuer *config.URL, subject, clientID string, expiresIn time.Duration) (string, error)

func (Manager) CreateRefreshToken

func (m Manager) CreateRefreshToken(issuer *config.URL, subject, clientID, scope, nonce string, authTime time.Time, expiresIn time.Duration) (string, error)

func (Manager) CreateSSOToken

func (m Manager) CreateSSOToken(issuer *config.URL, subject string, authTime time.Time, expiresIn time.Duration) (string, error)

func (Manager) JWKs

func (m Manager) JWKs() ([]JWK, error)

func (Manager) KeyID

func (m Manager) KeyID() uuid.UUID

func (Manager) ParseAccessToken

func (m Manager) ParseAccessToken(token string) (AccessTokenClaims, error)

func (Manager) ParseCode

func (m Manager) ParseCode(token string) (CodeClaims, error)

func (Manager) ParseIDToken

func (m Manager) ParseIDToken(token string) (IDTokenClaims, error)

func (Manager) ParseLoginToken

func (m Manager) ParseLoginToken(token string) (LoginTokenClaims, error)

func (Manager) ParseRefreshToken

func (m Manager) ParseRefreshToken(token string) (RefreshTokenClaims, error)

func (Manager) PublicKey

func (m Manager) PublicKey() *rsa.PublicKey

type OIDCClaims

type OIDCClaims struct {
	jwt.StandardClaims

	Type     string `json:"typ"`
	AuthTime int64  `json:"auth_time,omitempty"`
}

func (OIDCClaims) Validate

func (claims OIDCClaims) Validate(issuer *config.URL, audience string) error

type RefreshTokenClaims

type RefreshTokenClaims struct {
	OIDCClaims

	ClientID string `json:"client_id"`
	Scope    string `json:"scope,omitempty"`
	Nonce    string `json:"nonce,omitempty"`
}

func (RefreshTokenClaims) Validate

func (claims RefreshTokenClaims) Validate(issuer *config.URL) error

Jump to

Keyboard shortcuts

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