Documentation
¶
Overview ¶
Package oauth2 provides OAuth2/OIDC authentication using the golang.org/x/oauth2 and coreos/go-oidc libraries.
It implements the usermgmt.OAuth2Provider interface via structural typing — no import of the core usermgmt package is required. Consumers inject a *Provider into usermgmt.ServiceConfig.OAuth2 to enable OAuth2/OIDC login with external identity providers (Google, GitHub, Microsoft, etc.).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Providers map[string]ProviderConfig
}
Config configures multi-provider OAuth2/OIDC authentication.
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider manages multiple OAuth2/OIDC providers and implements the usermgmt.OAuth2Provider interface via structural typing.
func New ¶
New initializes all configured providers (performing OIDC discovery if needed) and returns a Provider ready for use.
func (*Provider) BeginLogin ¶
func (p *Provider) BeginLogin(_ context.Context, providerName, state string) (string, string, error)
BeginLogin generates PKCE and builds the authorization URL for the given provider. state is the CSRF state token (generated by the Service). Returns the redirect URL and PKCE verifier (stored by the Service).
type ProviderConfig ¶
type ProviderConfig struct {
ClientID string
ClientSecret string
RedirectURL string
Scopes []string
IssuerURL string
AuthURL string
TokenURL string
UserInfoURL string
}
ProviderConfig configures a single OAuth2/OIDC identity provider.
For OIDC providers (Google, Microsoft, etc.), set IssuerURL — the provider's discovery endpoint will be queried at startup to fill in endpoints automatically.
For pure OAuth2 providers (GitHub without OIDC), set AuthURL, TokenURL, and UserInfoURL explicitly.
func (ProviderConfig) Validate ¶
func (c ProviderConfig) Validate() error
Validate returns an error if the configuration is incomplete or inconsistent.