auth

package module
v0.0.0-...-4462017 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var OAuthProviders map[string]Provider

OAuthProviders contains maps of all participated providers

Functions

func Init

func Init(providers []string, verbose int)

Init initializes map of OAuth providers

Types

type Certs

type Certs struct {
	Keys []Keys
}

Certs represents structure of JWKS uri

type Claims

type Claims struct {
	Login string `json:"login"`
	jwt.RegisteredClaims
}

type Keys

type Keys struct {
	Kid     string   `json:"kid"`
	Kty     string   `json:"kty"`
	Alg     string   `json:"alg"`
	Use     string   `json:"use"`
	N       string   `json:"n"`
	E       string   `json:"e"`
	X5c     []string `json:"x5c"`
	X5y     string   `json:"x5y"`
	Xt5S256 string   `json:"x5t#S256"`
}

JWKSKeys struct represent structure of JWKS Keys

type OpenIDConfiguration

type OpenIDConfiguration struct {
	Issuer                string   `json:"issuer"`
	AuthorizationEndpoint string   `json:"authorization_endpoint"`
	TokenEndpoint         string   `json:"token_endpoint"`
	IntrospectionEndpoint string   `json:"introspection_endpoint"`
	UserInfoEndpoint      string   `json:"userinfo_endpoint"`
	EndSessionEndpoint    string   `json:"end_session_endpoint"`
	JWKSUri               string   `json:"jwks_uri"`
	ClaimsSupported       []string `json:"claims_supported"`
	ScopeSupported        []string `json:"scopes_supported"`
	RevocationEndpoint    string   `json:"revocation_endpoint"`
}

OpenIDConfiguration holds configuration for OpenID Provider

type Provider

type Provider struct {
	URL           string              // provider url
	Configuration OpenIDConfiguration // provider OpenID configuration
	PublicKeys    []publicKey         // Public keys of the provider
	JWKSBody      []byte              // jwks body content of the provider
}

Provider holds all information about given provider

func (*Provider) Init

func (p *Provider) Init(purl string, verbose int) error

Init function initialize provider configuration

func (*Provider) String

func (p *Provider) String() string

String provides string representation of provider

type Response

type Response struct {
	Status string `json:"status"`
	Uid    int    `json:"uid,omitempty"`
	Error  string `json:"error,omitempty"`
}

type Token

type Token struct {
	AccessToken string `json:"access_token"`
	Expires     int    `json:"expires_in"`
	Scope       string `json:"scope"`
	TokenType   string `json:"token_type"`
}

Token represents access token structure

func (*Token) Validate

func (t *Token) Validate(clientId string) error

type TokenAttributes

type TokenAttributes struct {
	Subject      string `json:"sub"`           // token subject
	Audiences    string `json:"aud"`           // token audience
	Issuer       string `json:"iss"`           // token issuer
	UserName     string `json:"username"`      // user name
	Active       bool   `json:"active"`        // is token active or not
	SessionState string `json:"session_state"` // session state fields
	ClientID     string `json:"clientId"`      // client id
	Email        string `json:"email"`         // client email address
	Scope        string `json:"scope"`         // scope of the token
	Expiration   int64  `json:"exp"`           // token expiration
	ClientHost   string `json:"clientHost"`    // client host
}

TokenAttributes contains structure of access token attributes

func InspectToken

func InspectToken(provider Provider, token string, verbose int) (TokenAttributes, error)

InspectToken extracts token attributes

func InspectTokenProviders

func InspectTokenProviders(token string, providers []string, verbose int) (TokenAttributes, error)

InspectTokenProviders inspects token against all participated providers and return TokenAttributes

type TokenInfo

type TokenInfo struct {
	AccessToken   string `json:"access_token"`       // access token
	AccessExpire  int64  `json:"expires_in"`         // access token expiration
	RefreshToken  string `json:"refresh_token"`      // refresh token
	RefreshExpire int64  `json:"refresh_expires_in"` // refresh token expireation
	IDToken       string `json:"id_token"`           // id token
}

TokenInfo contains information about all tokens

func (*TokenInfo) String

func (t *TokenInfo) String() string

String convert TokenInfo into html snippet

Jump to

Keyboard shortcuts

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