oidc

package
v0.4.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2022 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CallbackPath is the API path for receiving callback tokens from external OIDC providers
	CallbackPath = "/auth/callback"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Claims

type Claims struct {
	Email         string   `json:"email"`
	EmailVerified bool     `json:"email_verified"`
	Groups        []string `json:"groups"`
	Name          string   `json:"name"`
}

Claims represents claims as found in an id_token returned from an OIDC flow.

type IDP

type IDP interface {
	// HandleCallback accepts a context (pass the context from the http.Request), and an oauth2 code as returned from a successful
	// login through an OIDC provider. It uses the code to request a token from the OIDC provider, which should contain an id_token
	// with a set of claims.
	//
	// Note that this function *does not* verify state. That should be handled by the caller *before* this function is called.
	HandleCallback(ctx context.Context, code string) (*Claims, gtserror.WithCode)
	// AuthCodeURL returns the proper redirect URL for this IDP, for redirecting requesters to the correct OIDC endpoint.
	AuthCodeURL(state string) string
}

IDP contains logic for parsing an OIDC access code into a set of claims by calling an external OIDC provider.

func NewIDP

func NewIDP(ctx context.Context) (IDP, error)

NewIDP returns a new IDP configured with the given config. If the passed config contains a nil value for the OIDCConfig, or OIDCConfig.Enabled is set to false, then nil, nil will be returned. If OIDCConfig.Enabled is true, then the other OIDC config fields must also be set.

Jump to

Keyboard shortcuts

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