Documentation
¶
Overview ¶
Package oauthserver turns a togo app into an OAuth2 / OIDC authorization server — an identity provider that issues tokens to client apps (the togo answer to Laravel Passport / Doorkeeper / django-oauth-toolkit).
Supported grants: authorization_code (with PKCE S256), client_credentials, and refresh_token. Access tokens are signed JWTs (HS256); refresh tokens are opaque + rotated. Endpoints: /oauth/authorize, /oauth/token, /oauth/introspect, /oauth/revoke, /oauth/userinfo, /.well-known/{openid-configuration,jwks.json}.
Index ¶
- type Client
- type Introspection
- type Server
- func (s *Server) Client(id string) (*Client, bool)
- func (s *Server) ClientCredentials(clientID, clientSecret, scope string) (*Tokens, error)
- func (s *Server) ExchangeCode(code, verifier, redirectURI, clientID, clientSecret string) (*Tokens, error)
- func (s *Server) Introspect(token string) Introspection
- func (s *Server) IssueCode(clientID, userID, scope, redirectURI, challenge, method string) (string, error)
- func (s *Server) RefreshExchange(refreshTok, clientID, clientSecret string) (*Tokens, error)
- func (s *Server) RegisterClient(name string, redirectURIs, scopes, grants []string, confidential bool) (*Client, string)
- func (s *Server) Revoke(token string)
- type Tokens
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
ID string `json:"client_id"`
SecretHash string `json:"-"` // sha256-hex of the secret ("" = public client)
Name string `json:"name"`
RedirectURIs []string `json:"redirect_uris"`
Scopes []string `json:"scopes"`
Grants []string `json:"grants"`
}
Client is a registered OAuth2 client application.
type Introspection ¶
type Introspection struct {
Active bool `json:"active"`
Scope string `json:"scope,omitempty"`
ClientID string `json:"client_id,omitempty"`
Sub string `json:"sub,omitempty"`
Exp int64 `json:"exp,omitempty"`
TokenType string `json:"token_type,omitempty"`
}
Introspection is the RFC 7662 token-introspection response.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the OAuth2 authorization server stored on the kernel.
func FromKernel ¶
FromKernel returns the OAuth Server registered on the kernel.
func (*Server) ClientCredentials ¶
ClientCredentials runs the client_credentials grant.
func (*Server) ExchangeCode ¶
func (s *Server) ExchangeCode(code, verifier, redirectURI, clientID, clientSecret string) (*Tokens, error)
ExchangeCode runs the authorization_code grant (with PKCE if a challenge was set).
func (*Server) Introspect ¶
func (s *Server) Introspect(token string) Introspection
Introspect reports whether a token (access JWT or refresh) is active.
func (*Server) IssueCode ¶
func (s *Server) IssueCode(clientID, userID, scope, redirectURI, challenge, method string) (string, error)
IssueCode issues an authorization code after the resource owner authorizes.
func (*Server) RefreshExchange ¶
RefreshExchange runs the refresh_token grant (rotating the refresh token).