handler

package
v1.22.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package handler provides a HTTP handler for the OpenID Connect Provider.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthenticationRequest

type AuthenticationRequest struct {
	RedirectURI         string
	State               string
	Scope               string // space separated string
	Nonce               string
	CodeChallenge       string
	CodeChallengeMethod string
	RawQuery            url.Values
}

AuthenticationRequest represents a type of: https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest

type CertificatesResponse

type CertificatesResponse struct {
	Keys []*CertificatesResponseKey `json:"keys"`
}

type CertificatesResponseKey

type CertificatesResponseKey struct {
	Kty string `json:"kty"`
	Alg string `json:"alg"`
	Use string `json:"use"`
	Kid string `json:"kid"`
	N   string `json:"n"`
	E   string `json:"e"`
}

type DiscoveryResponse

type DiscoveryResponse struct {
	Issuer                            string   `json:"issuer"`
	AuthorizationEndpoint             string   `json:"authorization_endpoint"`
	TokenEndpoint                     string   `json:"token_endpoint"`
	UserinfoEndpoint                  string   `json:"userinfo_endpoint"`
	RevocationEndpoint                string   `json:"revocation_endpoint"`
	JwksURI                           string   `json:"jwks_uri"`
	ResponseTypesSupported            []string `json:"response_types_supported"`
	SubjectTypesSupported             []string `json:"subject_types_supported"`
	IDTokenSigningAlgValuesSupported  []string `json:"id_token_signing_alg_values_supported"`
	ScopesSupported                   []string `json:"scopes_supported"`
	TokenEndpointAuthMethodsSupported []string `json:"token_endpoint_auth_methods_supported"`
	ClaimsSupported                   []string `json:"claims_supported"`
	CodeChallengeMethodsSupported     []string `json:"code_challenge_methods_supported"`
}

type ErrorResponse

type ErrorResponse struct {
	Code        string `json:"error"`
	Description string `json:"error_description"`
}

ErrorResponse represents an error response described in the following section: 5.2 Error Response https://tools.ietf.org/html/rfc6749#section-5.2

func (*ErrorResponse) Error

func (err *ErrorResponse) Error() string

type Handler

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

Handler provides a HTTP handler for the OpenID Connect Provider. You need to implement the Provider interface. Note that this skips some security checks and is only for testing.

func New

func New(t *testing.T, provider Provider) *Handler

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Provider

type Provider interface {
	Discovery() *DiscoveryResponse
	GetCertificates() *CertificatesResponse
	AuthenticateCode(req AuthenticationRequest) (code string, err error)
	Exchange(req TokenRequest) (*TokenResponse, error)
	AuthenticatePassword(username, password, scope string) (*TokenResponse, error)
	Refresh(refreshToken string) (*TokenResponse, error)
}

Provider provides discovery and authentication methods. If an implemented method returns an ErrorResponse, the handler will respond 400 and corresponding json of the ErrorResponse. Otherwise, the handler will respond 500 and fail the current test.

type TokenRequest

type TokenRequest struct {
	Code         string
	CodeVerifier string
}

TokenRequest represents a type of: https://openid.net/specs/openid-connect-core-1_0.html#TokenRequest

type TokenResponse

type TokenResponse struct {
	AccessToken  string `json:"access_token"`
	TokenType    string `json:"token_type"`
	RefreshToken string `json:"refresh_token"`
	ExpiresIn    int    `json:"expires_in"`
	IDToken      string `json:"id_token"`
}

Jump to

Keyboard shortcuts

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