oidc

package
v0.0.18 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 12 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const (
	// GoogleIssuer is Google's issuer
	GoogleIssuer = "https://accounts.google.com"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Opt

type Opt func(*Provider) error

Opt is an option of a provider

func WithClient

func WithClient(opts ...client.ClientOpt) Opt

WithClient sets options of the client which discovers the issuer, gets its keys, and exchanges codes, such as client.OptTracer, or OptTimeout

func WithGroupsClaim

func WithGroupsClaim(claim string) Opt

WithGroupsClaim takes the identity's groups from the claim, such as groups, which some issuers, such as Keycloak, make

func WithScopes

func WithScopes(scopes ...string) Opt

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

func (*Provider) Meta

func (p *Provider) Meta() schema.ProviderMeta

Meta describes the provider

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL