oidc

package
v0.7.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2023 License: AGPL-3.0 Imports: 9 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 {
	Sub               string   `json:"sub"`
	Email             string   `json:"email"`
	EmailVerified     bool     `json:"email_verified"`
	Groups            []string `json:"groups"`
	Name              string   `json:"name"`
	PreferredUsername string   `json:"preferred_username"`
}

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.

Jump to

Keyboard shortcuts

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