Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var OAuthProviders map[string]Provider
OAuthProviders contains maps of all participated providers
Functions ¶
func TokenMiddleware ¶
func TokenMiddleware(clientId string, verbose int) gin.HandlerFunc
gin cookies https://gin-gonic.com/docs/examples/cookie/ more advanced use-case: https://stackoverflow.com/questions/66289603/use-existing-session-cookie-in-gin-router
Types ¶
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
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
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