idp

package
v0.0.0-...-109c033 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfOIDCWellKnownURL         = "OIDC_WELL_KNOWN_URL"
	ConfTokenIntrospectionURL    = "IDP_TOKEN_INTROSPECTION_URL"
	ConfIDPRequestTimeoutSeconds = "IDP_REQUEST_TIMEOUT_SECONDS"
	ConfIDPCacheEnabled          = "IDP_CACHE_ENABLED"
	ConfIDPCacheRetentionSeconds = "IDP_CACHE_RETENTION_SECONDS"
)

Variables

This section is empty.

Functions

func ConfigItems

func ConfigItems() []auconfigapi.ConfigItem

Types

type IdentityProviderClient

type IdentityProviderClient interface {
	// SetupFromWellKnown must be called at least once before any other methods can be used.
	SetupFromWellKnown(ctx context.Context) error

	Issuer() string

	// UserInfo extracts the token from the context and performs a user info lookup
	UserInfo(ctx context.Context) (*UserinfoResponse, int, error)

	// TokenIntrospection extracts the token from the context and performs a token info lookup
	TokenIntrospection(ctx context.Context) (*TokenIntrospectionResponse, int, error)
}

func New

func New(options Options) IdentityProviderClient

type Impl

type Impl struct {
	// contains filtered or unexported fields
}

func (*Impl) Issuer

func (i *Impl) Issuer() string

func (*Impl) SetupFromWellKnown

func (i *Impl) SetupFromWellKnown(ctx context.Context) error

func (*Impl) TokenIntrospection

func (i *Impl) TokenIntrospection(ctx context.Context) (*TokenIntrospectionResponse, int, error)

func (*Impl) UserInfo

func (i *Impl) UserInfo(ctx context.Context) (*UserinfoResponse, int, error)

type Options

type Options struct {
	RequestTimeout time.Duration

	CacheEnabled       bool
	CacheRetentionTime time.Duration

	OIDCWellKnownURL string

	TokenIntrospectionURL string
}

func OptionsFromConfig

func OptionsFromConfig() Options

type TokenIntrospectionResponse

type TokenIntrospectionResponse struct {
	Active    bool     `json:"active"`
	Scope     string   `json:"scope"`
	ClientId  string   `json:"client_id"`
	Sub       string   `json:"sub"`
	Exp       int64    `json:"exp"`
	Iat       int64    `json:"iat"`
	Nbf       int64    `json:"nbf"`
	Aud       []string `json:"aud"`
	Iss       string   `json:"iss"`
	TokenType string   `json:"token_type"`
	TokenUse  string   `json:"token_use"`

	// in case of error, you get these fields instead
	ErrorMessage string              `json:"message"`
	Errors       map[string][]string `json:"errors"`
}

type UserinfoResponse

type UserinfoResponse struct {
	// can leave out fields - we are using a tolerant reader
	Audience      []string `json:"aud"`
	AuthTime      int64    `json:"auth_time"`
	Email         string   `json:"email"`
	EmailVerified bool     `json:"email_verified"`
	Name          string   `json:"name"` // username
	Groups        []string `json:"groups"`
	Issuer        string   `json:"iss"`
	IssuedAt      int64    `json:"iat"`
	RequestedAt   int64    `json:"rat"`
	Subject       string   `json:"sub"`

	// in case of error, you get these fields instead
	ErrorCode        string `json:"error"`
	ErrorDescription string `json:"error_description"`
}

type WellKnownResponse

type WellKnownResponse struct {
	Issuer           string `json:"issuer"`
	UserinfoEndpoint string `json:"userinfo_endpoint"`
}

Jump to

Keyboard shortcuts

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