Documentation
¶
Overview ¶
Package oidctest provides an OpenID Connect provider for tests. It logs in every authorization request as the configured user, unless the user is logged out and the request asks for prompt=none.
Index ¶
- Constants
- Variables
- func VerifyDPoPProof(r *http.Request, accessToken, nonce string) (string, error)
- type Assertion
- type EndSession
- type Options
- type RequestObject
- type Server
- func (s *Server) AccessTokenResource(accessToken string) (string, bool)
- func (s *Server) Assertions() []Assertion
- func (s *Server) EndSessions() []EndSession
- func (s *Server) KeySetRequests() int
- func (s *Server) LogoutToken(clientID, sub, sid string) string
- func (s *Server) Refreshes() int
- func (s *Server) RequestObjects() []RequestObject
- func (s *Server) Revoked() []string
- func (s *Server) RotateKey()
- func (s *Server) Sign(typ string, claims map[string]any) string
- func (s *Server) Update(fn func(o *Options))
Constants ¶
const (
ClientSecret = "secret"
)
Variables ¶
var ErrDPoPNonce = errors.New("dpop nonce required")
ErrDPoPNonce is returned by VerifyDPoPProof when the proof does not have the required nonce.
Functions ¶
func VerifyDPoPProof ¶
VerifyDPoPProof verifies the DPoP proof of a request received by a server, as defined by RFC 9449 4.3, and returns the JWK thumbprint of its key. The proof must be bound to the access token and have the nonce when they are not empty.
Types ¶
type EndSession ¶
EndSession is a request to the end session endpoint.
type Options ¶
type Options struct {
// ClientKey is the public key that verifies the private_key_jwt assertions and the request objects of the clients.
ClientKey crypto.PublicKey
// Metadata is added to the discovery document. A nil value removes a field.
Metadata map[string]any
// Claims are added to the ID tokens. A nil value removes a claim.
Claims map[string]any
// UserInfo is added to the UserInfo response.
UserInfo map[string]any
// ISS is the iss parameter of the authorization response, sent when the discovery document advertises it. The
// default is the issuer.
ISS string
Subject string
SID string
// DPoPNonce is the nonce the token endpoint requires in the DPoP proofs, when it is not empty.
DPoPNonce string
// InvalidTargets are the resources the token endpoint rejects with invalid_target (RFC 8707 2).
InvalidTargets []string
// AccessTokenTTL is the lifetime of the access tokens. The default is 5 minutes.
AccessTokenTTL time.Duration
// UserInfoStatus is the status of the UserInfo responses, when it is not zero.
UserInfoStatus int
// SignedUserInfo sends the UserInfo responses as JWTs signed by the provider key.
SignedUserInfo bool
// RotateRefreshTokens issues a new refresh token on every refresh. Reusing a refresh token then revokes every
// token issued from it.
RotateRefreshTokens bool
LoggedOut bool
// PAR advertises the pushed authorization request endpoint.
PAR bool
// DecoyKeys adds to the key set the keys a client must ignore, as the OpenID conformance suite does.
DecoyKeys bool
// IgnoreDPoP issues bearer access tokens to the requests with a DPoP proof.
IgnoreDPoP bool
// Plain serves the provider over HTTP, for browser tests. It is read once by [NewServer].
Plain bool
}
Options configures a Server. Every field can be changed while the server runs, with Server.Update.
type RequestObject ¶
RequestObject is a request object accepted by the pushed authorization request endpoint.
type Server ¶
Server is an OpenID Connect provider served over TLS.
func (*Server) AccessTokenResource ¶
AccessTokenResource returns the resource of an access token issued by the provider, which is empty for an access token requested without resource.
func (*Server) Assertions ¶
Assertions returns the private_key_jwt assertions accepted by the provider.
func (*Server) EndSessions ¶
func (s *Server) EndSessions() []EndSession
EndSessions returns the requests received by the end session endpoint.
func (*Server) KeySetRequests ¶ added in v0.8.2
KeySetRequests returns the number of key set requests served by the provider.
func (*Server) LogoutToken ¶
LogoutToken returns a valid back-channel logout token for the client. An empty sub or sid is omitted.
func (*Server) Refreshes ¶
Refreshes returns the number of refresh token grants accepted by the provider.
func (*Server) RequestObjects ¶
func (s *Server) RequestObjects() []RequestObject
RequestObjects returns the request objects accepted by the provider.
func (*Server) RotateKey ¶
func (s *Server) RotateKey()
RotateKey replaces the provider key with a new key, published with a new key ID.