Documentation ¶
Index ¶
Constants ¶
const ( // Bearer is a constant for the bearer token Bearer = "Bearer" // ClientCredentials is a constant for the client credentials grant type ClientCredentials = "client_credentials" )
Variables ¶
var ( // ErrExpiredToken means the JWT token has expired. ErrExpiredToken = errors.New("token has expired (seconds)") // ErrBadTokenFuture means the JWT token was issued in the future. ErrBadTokenFuture = errors.New("token was issued in the future (seconds)") // ErrSubMissing means the JWT token has missing subject ErrSubMissing = errors.New("token subject is missing") )
Functions ¶
This section is empty.
Types ¶
type Claims ¶
type Claims map[string]interface{}
Claims represents the type for JWT claims
func ClaimsFrom ¶ added in v1.1.1
ClaimsFrom generates a claims object form the given struct
type Client ¶ added in v1.0.1
Client is a wrapper for an existing JWT mock server
func NewClient ¶ added in v1.0.1
func NewClient(url string, options ...ClientOption) *Client
NewClient creates a new client with the base URL and given options
func (*Client) GenerateJWT ¶ added in v1.0.1
GenerateJWT generates a JWT token for use in authorization header.
func (*Client) RegisterClient ¶ added in v1.1.1
func (c *Client) RegisterClient(ctx context.Context, registration ClientRegistration) error
RegisterClient register a new client
type ClientOption ¶ added in v1.0.1
type ClientOption func(*Client)
ClientOption allows setting options on the client
func WithHTTPClient ¶ added in v1.0.1
func WithHTTPClient(hc *http.Client) ClientOption
WithHTTPClient option is used to set the http client
type ClientRegistration ¶ added in v1.1.1
type ClientRegistration struct { ID string `json:"client_id"` Secret string `json:"client_secret"` Scope string `json:"scope"` }
ClientRegistration is used to register a new client for machine-to-machine auth.
type ClientTokenClaims ¶ added in v1.1.1
type ClientTokenClaims struct { Issuer string `mapstructure:"iss"` Subject string `mapstructure:"sub"` Audience string `mapstructure:"aud"` IssuedAt int64 `mapstructure:"iat"` Expires int64 `mapstructure:"exp"` AuthorizedParty string `mapstructure:"azp"` Scope string `mapstructure:"scope"` GrantType string `mapstructure:"gty"` }
ClientTokenClaims are claims in the JWT for the client
type ClientTokenRequest ¶ added in v1.1.1
type ClientTokenRequest struct { ClientID string `mapstructure:"client_id"` ClientSecret string `mapstructure:"client_secret"` GrantType string `mapstructure:"grant_type"` Audience string `mapstructure:"audience"` }
ClientTokenRequest is a request to obtain a JWT token for the given client - passed as form-URL encoded
type ClientTokenResponse ¶ added in v1.1.1
type ClientTokenResponse struct { AccessToken string `json:"access_token"` Scope string `json:"scope"` ExpiresIn int64 `json:"expires_in"` TokenType string `json:"token_type"` }
ClientTokenResponse is the response for token endpoint
type SigningKey ¶
type SigningKey struct { ID string Key interface{} Algorithm jwa.SignatureAlgorithm PublicKey interface{} }
SigningKey represents a generic key used to sign JWTs.
Directories ¶
Path | Synopsis |
---|---|
Package cmd contains CLI commands.
|
Package cmd contains CLI commands. |
internal
|
|
handlers
Package handlers contains handlers for the JWT Mock server.
|
Package handlers contains handlers for the JWT Mock server. |
jwks
Package jwks contains code for dealing with JSON Web Key Sets.
|
Package jwks contains code for dealing with JSON Web Key Sets. |
service
Package service contains services used by code here.
|
Package service contains services used by code here. |
Package jwtmocktest provides a test server for use in end-to-end HTTP tests.
|
Package jwtmocktest provides a test server for use in end-to-end HTTP tests. |
Package log contains a logger used by this library
|
Package log contains a logger used by this library |