Documentation ¶
Index ¶
- Constants
- type AccessTokenType
- type Metadata
- type OPTest
- func (op *OPTest) Close()
- func (op *OPTest) GetRouter() *http.ServeMux
- func (op *OPTest) GetToken() (*TokenResponse, error)
- func (op *OPTest) GetTokenByUser(id string, nonce string) (*TokenResponse, error)
- func (op *OPTest) GetURL() string
- func (op *OPTest) RotateKeys() error
- func (op *OPTest) Start()
- type OPTesting
- func (o *OPTesting) Close(tb testing.TB)
- func (o *OPTesting) GetRouter(tb testing.TB) *http.ServeMux
- func (o *OPTesting) GetToken(tb testing.TB) *TokenResponse
- func (o *OPTesting) GetTokenByUser(tb testing.TB, userString string) *TokenResponse
- func (o *OPTesting) GetURL(tb testing.TB) string
- func (o *OPTesting) RotateKeys(tb testing.TB)
- func (o *OPTesting) Start(tb testing.TB)
- type Option
- type Options
- type TestUser
- type TokenResponse
Constants ¶
const ( // JwtAccessTokenType sets the access token to be a JWT. JwtAccessTokenType = iota // OpaqueAccessTokenType sets the access token to be opaque. OpaqueAccessTokenType )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccessTokenType ¶ added in v0.0.31
type AccessTokenType int
AccessTokenType defines the type of token to be used.
type Metadata ¶
type Metadata struct { Issuer string `json:"issuer"` AuthorizationEndpoint string `json:"authorization_endpoint"` TokenEndpoint string `json:"token_endpoint"` JwksUri string `json:"jwks_uri"` ResponseTypesSupported []string `json:"response_types_supported"` UserinfoEndpoint string `json:"userinfo_endpoint"` }
Metadata contains the information exposed through `/.well-known/openid-configuration`.
type OPTest ¶
type OPTest struct {
// contains filtered or unexported fields
}
OPTest is the struct used for the test OpenID Provider.
func (*OPTest) GetToken ¶
func (op *OPTest) GetToken() (*TokenResponse, error)
GetToken returns a TokenResponse with an id_token and an access_token for the default test user.
func (*OPTest) GetTokenByUser ¶ added in v0.0.30
func (op *OPTest) GetTokenByUser(id string, nonce string) (*TokenResponse, error)
GetTokenByUser returns a TokenResponse with an id_token and an access_token for the specified user.
type OPTesting ¶
type OPTesting struct {
// contains filtered or unexported fields
}
OPTesting is a wrapper for the OPTest to be used in tests.
func NewTesting ¶
NewTesting sets up a new test OpenID Provider.
func (*OPTesting) GetToken ¶
func (o *OPTesting) GetToken(tb testing.TB) *TokenResponse
GetToken returns a TokenResponse with an id_token and an access_token for the default test user.
func (*OPTesting) GetTokenByUser ¶ added in v0.0.30
func (o *OPTesting) GetTokenByUser(tb testing.TB, userString string) *TokenResponse
GetTokenByUser returns a TokenResponse with an id_token and an access_token for the specified user.
func (*OPTesting) RotateKeys ¶
RotateKeys rotates the jwks keys.
type Option ¶
type Option func(*Options)
Option is used to configure functional options for OPTest.
func WithDefaultTestUser ¶ added in v0.0.30
WithDefaultTestUser configures the default test user, needs to match one of the users provided in `WithTestUsers()`. Defaults to the addr of the http server.
func WithIssuer ¶
WithIssuer configures the issuer claim for tokens and addresses in metadata. Defaults to the addr of the http server.
func WithLoginPrompt ¶ added in v0.0.38
func WithLoginPrompt() Option
WithLoginPrompt enables login prompt if there are more than one Test User. Default is login prompt disabled.
func WithOpaqueAccessTokens ¶ added in v0.0.31
func WithOpaqueAccessTokens() Option
WithOpaqueAccessTokens enables opaque access tokens. Default is access tokens as JWT.
func WithTestUsers ¶ added in v0.0.30
WithTestUsers configures the users that can be used to issue tokens. Defaults to a single test user named `test`.
func WithTokenExpiration ¶
WithTokenExpiration configures the expiration for tokens. Default: 1 hour (3600 seconds).
func WithoutAutoStart ¶
func WithoutAutoStart() Option
WithoutAutoStart disables the autostart of the http server. Default is AutoStart enabled.
type Options ¶
type Options struct { Issuer string DefaultTestUser string TestUsers map[string]TestUser TokenExpiration time.Duration AutoStart bool AccessTokenType AccessTokenType LoginPromptEnabled bool }
Options is the configuration object for OPTest.
type TokenResponse ¶
type TokenResponse struct { AccessToken string `json:"access_token"` TokenType string `json:"token_type"` ExpiresIn int `json:"expires_in"` IdToken string `json:"id_token"` Expiry time.Time }
TokenResponse contains the token endpoint response data.
func (*TokenResponse) SetAuthHeader ¶
func (t *TokenResponse) SetAuthHeader(r *http.Request)
SetAuthHeader adds the access_token to the `Authorization` header of the request.
func (*TokenResponse) Valid ¶
func (t *TokenResponse) Valid() bool
Valid returns true if the token exists and isn't expired.