client

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2020 License: MIT Imports: 18 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// TokenKey defines the key that shall be used to store a token in a requests' context
	TokenKey key = "token"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ConsentRequestInfo

type ConsentRequestInfo struct {
	ACR                          string                 `json:"acr,omitempty"`
	Challenge                    string                 `json:"challenge,omitempty"`
	Client                       OAuth2Client           `json:"client,omitempty"`
	Context                      map[string]interface{} `json:"context,omitempty"`
	LoginChallenge               string                 `json:"login_challenge,omitempty"`
	LoginSessionID               string                 `json:"login_session_id,omitempty"`
	OIDCContext                  interface{}            `json:"oidc_context,omitempty"`
	RequestURL                   string                 `json:"request_url,omitempty"`
	RequestedAccessTokenAudience []string               `json:"requested_access_token_audience,omitempty"`
	RequestedScope               []string               `json:"requested_scope,omitempty"`
	Skip                         bool                   `json:"skip,omitempty"`
	Subject                      string                 `json:"subject,omitempty"`
}

ConsentRequestInfo holds ory hydra's information with regards to a consent request

type IntrospectTokenRequestPayload

type IntrospectTokenRequestPayload struct {
	Token string `json:"token"`
	Scope string `json:"scope"`
}

IntrospectTokenRequestPayload holds the data to communicate with hydra's introspect token api

type LoginRequestInfo

type LoginRequestInfo struct {
	Challenge                    string               `json:"challenge,omitempty"`
	Client                       OAuth2Client         `json:"client,omitempty"`
	OIDCContext                  OpenIDConnectContext `json:"oidc_context,omitempty"`
	RequestURL                   string               `json:"request_url,omitempty"`
	RequestedAccessTokenAudience []string             `json:"requested_access_token_audience,omitempty"`
	RequestedScope               []string             `json:"requested_scope,omitempty"`
	SessionID                    string               `json:"session_id,omitempty"`
	Skip                         bool                 `json:"skip,omitempty"`
	Subject                      string               `json:"subject,omitempty"`
}

LoginRequestInfo holds ory hydra's information with regards to a login request

type OAuth2Client

type OAuth2Client struct {
	AllowedCorsOrigins        []string             `json:"allowed_cors_origins,omitempty"`
	Audience                  []string             `json:"audience,omitempty"`
	ClientID                  string               `json:"client_id,omitempty"`
	ClientName                string               `json:"client_name,omitempty"`
	ClientSecret              string               `json:"client_secret,omitempty"`
	ClientSecretExpiresAt     int64                `json:"client_secret_expires_at,omitempty"`
	ClientURI                 string               `json:"client_uri,omitempty"`
	Contacts                  []string             `json:"contacts,omitempty"`
	CreatedAt                 string               `json:"created_at,omitempty"`
	GrantTypes                []string             `json:"grant_types,omitempty"`
	JWKs                      SwaggerJSONWebKeySet `json:"jwks,omitempty"`
	JWKsURI                   string               `json:"jwks_uri,omitempty"`
	LogoURI                   string               `json:"logo_uri,omitempty"`
	Owner                     string               `json:"owner,omitempty"`
	PolicyURI                 string               `json:"policy_uri,omitempty"`
	PostLogoutRedirectURIs    []string             `json:"post_logout_redirect_uris,omitempty"`
	RedirectURIs              []string             `json:"redirect_uris,omitempty"`
	RequestObjectSigningAlg   string               `json:"request_object_signing_alg,omitempty"`
	RequestURIs               []string             `json:"request_uris,omitempty"`
	ResponseTypes             []string             `json:"response_types,omitempty"`
	Scopes                    string               `json:"scope,omitempty"`
	SectorIdentifierURI       string               `json:"sector_identifier_uri,omitempty"`
	SubjectType               string               `json:"subject_type,omitempty"`
	TokenEndpointAuthMethod   string               `json:"token_endpoint_auth_method,omitempty"`
	TosURI                    string               `json:"tos_uri,omitempty"`
	UpdatedAt                 string               `json:"updated_at,omitempty"`
	UserinfoSignedResponseAlg string               `json:"userinfo_signed_response_alg,omitempty"`
}

OAuth2Client holds the data of an oauth2 hydra client

type OpenIDConnectContext

type OpenIDConnectContext struct {
	ACRValues         []string               `json:"acr_values,omitempty"`
	Display           string                 `json:"display,omitempty"`
	IDTokenHintClaims map[string]interface{} `json:"id_token_hint_claims,omitempty"`
	LoginHint         string                 `json:"login_hint,omitempty"`
	UILocales         []string               `json:"ui_locales,omitempty"`
}

OpenIDConnectContext optional information about the OpenID connect request

type SwaggerJSONWebKey

type SwaggerJSONWebKey struct {
	ALG string   `json:"alg"`
	CRV string   `json:"crv"`
	D   string   `json:"d"`
	DP  string   `json:"dp"`
	DQ  string   `json:"dq"`
	E   string   `json:"e"`
	K   string   `json:"k"`
	KID string   `json:"kid"`
	KTY string   `json:"kty"`
	N   string   `json:"n"`
	P   string   `json:"p"`
	Q   string   `json:"q"`
	QI  string   `json:"qi"`
	USE string   `json:"use"`
	X   string   `json:"x"`
	X5C []string `json:"x5c"`
	Y   string   `json:"y"`
}

SwaggerJSONWebKey holds the informationf of a JSON Web key

type SwaggerJSONWebKeySet

type SwaggerJSONWebKeySet struct {
	Keys []interface{} `json:"keys"`
}

SwaggerJSONWebKeySet holds the information of a JSON Web Key Set

type Token

type Token struct {
	Active            bool                   `json:"active"`
	Audiences         []string               `json:"aud,omitempty"`
	ClientID          string                 `json:"client_id"`
	Expiration        int64                  `json:"exp"`
	Extra             map[string]interface{} `json:"ext,omitempty"`
	IssuedAt          int64                  `json:"iat"`
	IssuerURL         string                 `json:"iss"`
	NotBefore         int64                  `json:"nbf"`
	ObfuscatedSubject string                 `json:"obfuscated_subject,omitempty"`
	Scope             string                 `json:"scope"`
	Subject           string                 `json:"sub"`
	TokenType         string                 `json:"token_type"`
	Username          string                 `json:"username"`
}

Token holds a hydra token's data

type Tokens added in v0.6.0

type Tokens struct {
	AccessToken  string
	RefreshToken string
	OpenIdToken  string
	Scope        string
}

Tokens holds all the returned tokens from an authcode flow

type Transporter

type Transporter struct {
	*http.Transport
	FakeTLSTermination bool
}

Transporter to enable the definition of a FakeTLSTermination

func (*Transporter) RoundTrip

func (t *Transporter) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip overwrites the parent transport round trip to enable/disable fake tls termination

type WhisperClient

type WhisperClient struct {
	Token *oauth2.Token
	// contains filtered or unexported fields
}

WhisperClient holds the info and structures a whisper client must

func (*WhisperClient) CheckCredentials

func (client *WhisperClient) CheckCredentials() (t *oauth2.Token, err error)

CheckCredentials talks to the admin service to check weather the informed client_id should be created and fires a client credentials flow accordingly client credentials flow is not fired if a password is not provided client credentials flow is also not fired if app is not first-party client

func (*WhisperClient) DoClientCredentialsFlow

func (client *WhisperClient) DoClientCredentialsFlow() (t *oauth2.Token, err error)

DoClientCredentialsFlow calls hydra's oauth2/token and starts a client credentials flow this method is only correctly executed if the registered client is not public, i.e, has non-empty client secret

func (*WhisperClient) ExchangeCodeForToken added in v0.3.0

func (client *WhisperClient) ExchangeCodeForToken(code, codeVerifier, state string) (token Tokens, err error)

ExchangeCodeForToken retrieves a token provided a valid code

func (*WhisperClient) GetMuxSecurityMiddleware

func (client *WhisperClient) GetMuxSecurityMiddleware() mux.MiddlewareFunc

GetMuxSecurityMiddleware verifies if the client is authorized to make this request

func (*WhisperClient) GetOAuth2LoginParams added in v0.7.0

func (client *WhisperClient) GetOAuth2LoginParams() (loginURL, codeVerifier, state string)

GetOAuth2LoginParams retrieves the hydra login url as well as the code_verifier and the state values used to generate such URL

func (*WhisperClient) GetOAuth2LogoutURL added in v0.4.0

func (client *WhisperClient) GetOAuth2LogoutURL(openidToken, postLogoutRedirectURIs string) string

GetOAuth2LogoutURL retrieves the hydra revokeLoginSessions url

func (*WhisperClient) GetTokenAsJSONStr

func (client *WhisperClient) GetTokenAsJSONStr(t *oauth2.Token) string

GetTokenAsJSONStr stores the token in the environment variables as a json string

func (*WhisperClient) InitFromConfig added in v0.2.0

func (client *WhisperClient) InitFromConfig(config *config.Config) *WhisperClient

InitFromConfig initialize a whisper client from flags

func (*WhisperClient) InitFromParams

func (client *WhisperClient) InitFromParams(whisperURL, clientName, clientID, clientSecret, publicURL, loginRedirectURL, logoutRedirectURL string, scopes []string) *WhisperClient

InitFromParams initializes a whisper client from normal params

func (*WhisperClient) IntrospectToken

func (client *WhisperClient) IntrospectToken(token string) (result Token, err error)

IntrospectToken calls hydra to introspect a access or refresh token

func (*WhisperClient) RevokeLoginSessions added in v0.4.0

func (client *WhisperClient) RevokeLoginSessions(subject string) error

RevokeLoginSessions logs out

Jump to

Keyboard shortcuts

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