Documentation
¶
Overview ¶
Package oidc is a provider which is an OpenID Connect issuer, such as Google, Microsoft or Keycloak, which is signed in with at its own pages, and whose ID tokens are checked against its keys.
Index ¶
Constants ¶
const (
// GoogleIssuer is Google's issuer
GoogleIssuer = "https://accounts.google.com"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Opt ¶
Opt is an option of a provider
func WithClient ¶
WithClient sets options of the client which discovers the issuer, gets its keys, and exchanges codes, such as client.OptTracer, or OptTimeout
func WithGroupsClaim ¶
WithGroupsClaim takes the identity's groups from the claim, such as groups, which some issuers, such as Keycloak, make
func WithScopes ¶
WithScopes asks for scopes, other than openid, email and profile
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider is an OpenID Connect issuer, which is discovered when it's first used, so the server starts without it
func New ¶
func New(name, label, issuer string, credentials credential.CredentialProvider, key string, opts ...Opt) (*Provider, error)
New returns a provider, with a name, which is in its paths, and a label, to show, of the issuer, whose client, which it's registered with at the issuer, is the credential at the key: an OAuthClient, with its ID and secret. It asks for openid, email and profile.
func NewGoogle ¶
func NewGoogle(credentials credential.CredentialProvider, key string, opts ...Opt) (*Provider, error)
NewGoogle returns a provider of Google, named google, whose client, from the Google Cloud Console, is the credential at the key
func (*Provider) AuthCodeURL ¶
func (p *Provider) AuthCodeURL(ctx context.Context, redirectURL, state, verifier string) (string, error)
AuthCodeURL returns the URL of the issuer's sign-in page, which redirects to the redirect URL with a code, and the state, with the S256 challenge of the verifier
func (*Provider) Exchange ¶
func (p *Provider) Exchange(ctx context.Context, credential schema.Credential) (*schema.Identity, error)
Exchange exchanges the code, with its verifier, for tokens, and returns the identity of the ID token, which is checked against the issuer's keys, and is for this client