Versions in this module Expand all Collapse all v0 v0.5.0 Nov 24, 2026 Changes in this version type ServerConfig + Log *slog.Logger v0.4.0 Nov 19, 2026 Changes in this version + const DPoPTokenType + var ErrUserAuthority = errors.New("oauth: account authority is no longer valid") + func BearerClaimsFromContext(ctx context.Context) (*oauth.BearerClaims, bool) + func DPoPAccessTokenHash(accessToken string) string + func DPoPProof(r *http.Request) (*DPoPHeader, *DPoPClaims, error) + func GenerateState() (string, error) + func JWKThumbprint(jwk *oauth.JWK) (string, error) + func NewBearerClaimsContext(ctx context.Context, claims *oauth.BearerClaims) context.Context + func SignState(state string, secret []byte) string + func ValidateState(cookie string, secret []byte) (string, bool) + func VerifyDPoPProof(r *http.Request, expectedHTU string, header *DPoPHeader, claims *DPoPClaims, ...) error + func VerifyDPoPProofTokenEndpoint(r *http.Request, expectedHTU string, header *DPoPHeader, claims *DPoPClaims, ...) error + type AccessTokenService struct + func NewAccessTokenService(keyPEM []byte, kid string, ttl time.Duration) (*AccessTokenService, error) + func (s *AccessTokenService) IssueAccessToken(issuer string, user oauth.User, audience, scope, grantID, clientID string) (string, error) + func (s *AccessTokenService) IssueAccessTokenTTL(issuer string, user oauth.User, audience, scope, grantID, clientID string, ...) (string, error) + func (s *AccessTokenService) IssueClientCredentialsAccessToken(issuer, clientID, audience, scope, grantID, dpopJKT string) (string, error) + func (s *AccessTokenService) IssueDPoPAccessToken(issuer string, user oauth.User, ...) (string, error) + func (s *AccessTokenService) IssueRegistrationAccessToken(issuer, clientID string) (string, error) + func (s *AccessTokenService) JWK() []oauth.JWK + func (s *AccessTokenService) RotateKey() (string, error) + func (s *AccessTokenService) RotateKeyWithAlg(alg string) (string, error) + func (s *AccessTokenService) VerifyAccessToken(token, issuer, audience string, now time.Time, touchGrant GrantTouchFunc, ...) (*oauth.BearerClaims, error) + func (s *AccessTokenService) VerifyRegistrationAccessToken(token, issuer, audience string, now time.Time) (clientID string, err error) + type AuditRecorder interface + RecordOAuth func(ctx context.Context, userID, operation, name, decision, status string, ...) + type AuthorizationUI interface + LoginStartURL func(r *http.Request) string + ProviderLabel func(provider string) string + RenderOAuthConsent func(w http.ResponseWriter, data *ConsentPageData) error + type Client struct + CreatedAt time.Time + GrantTypes []string + ID string + JWKS []oauth.JWK + JWKSURI string + Name string + Provenance ClientProvenance + RedirectURIs []string + TokenEndpointAuthMethod string + type ClientMetadataNetwork interface + DialContext func(ctx context.Context, network, address string) (net.Conn, error) + LookupNetIP func(ctx context.Context, network, host string) ([]netip.Addr, error) + type ClientProvenance string + const ClientProvenanceDynamic + const ClientProvenanceMetadata + type ConsentPageData struct + Action string + ClientHostname string + ClientID string + ClientMetadataDocument bool + ClientName string + ConsentToken string + ProviderLabel string + RedirectURI string + Resource string + ScopeItems []ScopeItem + UserInitial string + Username string + type DPoPClaims struct + ATH string + HTM string + HTU string + IAT int64 + JTI string + Nonce string + type DPoPHeader struct + Alg string + JWK oauth.JWK + Typ string + type DPoPJTICache struct + func NewDPoPJTICache(ttl time.Duration) *DPoPJTICache + func (c *DPoPJTICache) CheckAndStore(jti string) bool + type DPoPNonceManager struct + func NewDPoPNonceManager(ttl time.Duration) *DPoPNonceManager + func (m *DPoPNonceManager) HasNonce(nonce string) bool + func (m *DPoPNonceManager) Issue() (string, error) + func (m *DPoPNonceManager) Validate(nonce string) bool + type DeviceCode struct + Authority string + ClientID string + Scope string + UserCodeKey string + type Grant struct + ClientID string + ClientName string + CreatedAt time.Time + ExpiresAt time.Time + ID string + LastUsedAt time.Time + Resource string + RevokedAt time.Time + Scope string + UserID string + type GrantTouchFunc func(grantID string, now time.Time) (active bool, clientID string, err error) + type IntrospectionAuthenticator func(*http.Request) (IntrospectionPrincipal, bool) + type IntrospectionPrincipal struct + ClientID string + type RateLimiter interface + Allow func(key string) bool + type ScopeItem struct + Checked bool + ID string + Label string + type Server struct + func NewServer(c ServerConfig) (*Server, error) + func (s *Server) BearerAuth(next http.Handler) http.Handler + func (s *Server) Close() + func (s *Server) IssueNarrowToken(user oauth.User, audience, scope string, ttl time.Duration) (string, error) + func (s *Server) ListUserGrants(userID string) []Grant + func (s *Server) RegisterWellKnownRoutes(mux *http.ServeMux) + func (s *Server) RevokeAllUserGrants(userID string) error + func (s *Server) RevokeUserGrant(userID, grantID string) (bool, error) + func (s *Server) Routes() http.Handler + type ServerConfig struct + AccessTokenTTL time.Duration + Audit AuditRecorder + AuthCodeTTL time.Duration + ClientIDPrefix string + ClientMetadataNetwork ClientMetadataNetwork + ClientMetadataRootCAs *x509.CertPool + DPoPNonceTTL time.Duration + DefaultScopes []string + IntrospectionAuth IntrospectionAuthenticator + Issuer string + KeyID string + KeyPEM []byte + RateLimiter RateLimiter + RefreshTokenStorePath string + RefreshTokenTTL time.Duration + ResourceMetadataURLPath string + ResourceURLPath string + ScopeLabels map[string]string + Session SessionManager + SupportedScopes []string + UI AuthorizationUI + type SessionManager interface + AttachUser func(ctx context.Context, u oauth.User) context.Context + CurrentUser func(ctx context.Context) (oauth.User, bool) + EndSession func(ctx context.Context, r *http.Request, u oauth.User) (redirectURL string) + FindUser func(id string) (oauth.User, bool) + type Store struct + ClientAssertionJTIs map[string]time.Time + Clients map[string]Client + Codes map[string]v5.Code + Consents map[string]v5.ConsentParams + DPoPNonces map[string]time.Time + DPoPProofs map[string]time.Time + DeviceCodes map[string]*DeviceCode + Grants map[string]v5.Grant + RefreshTokens map[string]v5.RefreshToken + func LoadStore(path string) (store *Store, err error) + func (s *Store) ListUserGrants(userID string) []Grant + func (s *Store) Path() string + func (s *Store) PruneExpiredRefreshTokens(now time.Time) bool + func (s *Store) RevokeAllUserGrants(userID string, now time.Time) bool + func (s *Store) RevokeUserGrant(userID, grantID string, now time.Time) bool + func (s *Store) Save() error + type UserAuthority interface + WithUserAuthority func(user oauth.User, publish func() error) error