auth

package
v0.378.1-next.3 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2024 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	HttpClient   HTTPClient
	RequestCache *cache.Cache
	JwkCache     *jwk.Cache
)

Functions

func ExtractClaimFromToken added in v0.372.0

func ExtractClaimFromToken(token string, claim string) (string, error)

func ExtractJWKSPublicKey

func ExtractJWKSPublicKey(ctx context.Context, jwks jwk.Set, tokenKid string) (*rsa.PublicKey, error)

func FetchJWKS added in v0.368.0

func FetchJWKS(ctx context.Context, url string) (*jwk.Set, error)

func GetJWKS

func GetJWKS(ctx context.Context, issuer string) (jwk.Set, error)

func IsAuthenticated added in v0.368.0

func IsAuthenticated(ctx context.Context) bool

func PublicKeyForIssuer

func PublicKeyForIssuer(ctx context.Context, issuerUri string, tokenKid string) (*rsa.PublicKey, error)

func RegisterAndFetchJWKS added in v0.368.0

func RegisterAndFetchJWKS(ctx context.Context, issuer string, url string) (*jwk.Set, error)

func WithIdentity added in v0.368.0

func WithIdentity(ctx context.Context, identity *Identity) context.Context

Types

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
	Get(string) (*http.Response, error)
}

type Identity added in v0.368.0

type Identity struct {
	Id            string    `json:"id"`
	ExternalId    string    `json:"externalId"`
	Email         string    `json:"email"`
	EmailVerified bool      `json:"email_verified"`
	Password      string    `json:"-"`
	Issuer        string    `json:"issuer"`
	CreatedAt     time.Time `json:"createdAt"`
	UpdatedAt     time.Time `json:"updatedAt"`
}

func GetIdentity added in v0.368.0

func GetIdentity(ctx context.Context) (*Identity, error)

type OpenidConfig

type OpenidConfig struct {
	Issuer   string `json:"issuer"`
	AuthURL  string `json:"authorization_endpoint"`
	TokenURL string `json:"token_endpoint"`

	JWKSURL     string   `json:"jwks_uri"`
	UserInfoURL string   `json:"userinfo_endpoint"`
	Algorithms  []string `json:"id_token_signing_alg_values_supported"`
}

func GetOpenIDConnectConfig

func GetOpenIDConnectConfig(ctx context.Context, issuer string) (*OpenidConfig, error)

type UserInfo

type UserInfo struct {
	Subject       string `json:"sub"`
	Profile       string `json:"profile"`
	Email         string `json:"email"`
	EmailVerified bool   `json:"email_verified"`

	// OIDC Standard claims (non-exhaustive)
	GivenName  string `json:"given_name"`
	FamilyName string `json:"family_name"`
	Name       string `json:"name"`
	Picture    string `json:"picture"`
	Gender     string `json:"gender"`
	Zoneinfo   string `json:"zoneinfo"`
	Locale     string `json:"locale"`
	UpdatedAt  string `json:"updated_at"`

	Claims []byte
}

func GetUserInfo

func GetUserInfo(ctx context.Context, issuer string, token string) (*UserInfo, error)

Jump to

Keyboard shortcuts

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