oauth2

package
v0.7.8 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ParameterResponseType     string = "response_type"
	ParameterRedirectUri      string = "redirect_uri"
	ParameterState            string = "state"
	ParameterScope            string = "scope"
	ParameterClientId         string = "client_id"
	ParameterClientSecret     string = "client_secret"
	ParameterGrantType        string = "grant_type"
	ParameterTokenType        string = "token_type"
	ParameterAccessToken      string = "access_token"
	ParameterRefreshToken     string = "refresh_token"
	ParameterExpiresIn        string = "expires_in"
	ParameterCode             string = "code"
	ParameterUsername         string = "username"
	ParameterPassword         string = "password"
	ParameterToken            string = "token"
	ParameterTokenTypeHint    string = "token_type_hint"
	ParameterError            string = "error"
	ParameterErrorDescription string = "error_description"
	ParameterErrorUri         string = "error_uri"
)

Variables

This section is empty.

Functions

func AuthorizationErrorResponseHandler

func AuthorizationErrorResponseHandler(w http.ResponseWriter, redirectURL *url.URL, state string, errorResponseParameter *AuthorizationErrorResponseParameter)

func TokenErrorResponseHandler

func TokenErrorResponseHandler(w http.ResponseWriter, r *http.Request, errorResponseParameter *TokenErrorResponseParameter)

func TokenErrorStatusResponseHandler

func TokenErrorStatusResponseHandler(w http.ResponseWriter, r *http.Request, statusCode int, errorResponseParameter *TokenErrorResponseParameter)

Types

type AccessToken

type AccessToken struct {
	Key       string
	TokenType TokenType
	Username  string
	ClientId  string
	Scopes    []string
}

type AccessTokenResponse

type AccessTokenResponse struct {
	AccessTokenValue  string    `json:"access_token,omitempty"`
	TokenType         TokenType `json:"token_type,omitempty"`
	ExpiresIn         int       `json:"expires_in,omitempty"` // seconds
	RefreshTokenValue string    `json:"refresh_token,omitempty"`
	IdTokenValue      string    `json:"id_token,omitempty"` // https://openid.net/specs/openid-connect-core-1_0.html#IDToken
}

AccessTokenResponse as described in https://datatracker.ietf.org/doc/html/rfc6749#section-4.1.4

type AuthorizationErrorResponseParameter

type AuthorizationErrorResponseParameter struct {
	Error       AuthorizationErrorType
	Description string
	Uri         string
}

AuthorizationErrorResponseParameter related to https://datatracker.ietf.org/doc/html/rfc6749#section-4.1.2.1

type AuthorizationErrorType

type AuthorizationErrorType string

AuthorizationErrorType as described in multiple places e.g. https://datatracker.ietf.org/doc/html/rfc6749#section-4.1.2.1

const (
	AuthorizationEtInvalidRequest          AuthorizationErrorType = "invalid_request"
	AuthorizationEtUnauthorizedClient      AuthorizationErrorType = "unauthorized_client"
	AuthorizationEtAccessDenied            AuthorizationErrorType = "access_denied"
	AuthorizationEtUnsupportedResponseType AuthorizationErrorType = "unsupported_response_type"
	AuthorizationEtInvalidScope            AuthorizationErrorType = "invalid_scope"
	AuthorizationEtServerError             AuthorizationErrorType = "server_error"
	AuthorizationEtTemporaryUnavailable    AuthorizationErrorType = "temporarily_unavailable"

	// AuthorizationEtInteractionRequired and following extended by https://openid.net/specs/openid-connect-core-1_0.html#AuthError
	AuthorizationEtInteractionRequired      AuthorizationErrorType = "interaction_required"
	AuthorizationEtLoginRequired            AuthorizationErrorType = "login_required"
	AuthorizationEtAccountSelectionRequired AuthorizationErrorType = "account_selection_required"
	AuthorizationEtConsentRequired          AuthorizationErrorType = "consent_required"
	AuthorizationEtInvalidRequestUri        AuthorizationErrorType = "invalid_request_uri"
	AuthorizationEtInvalidRequestObject     AuthorizationErrorType = "invalid_request_object"
	AuthorizationEtRequestNotSupported      AuthorizationErrorType = "request_not_supported"
	AuthorizationEtRequestUriNotSupported   AuthorizationErrorType = "request_uri_not_supported"
	AuthorizationEtRegistrationNotSupported AuthorizationErrorType = "registration_not_supported"
)

func AuthorizationErrorTypeFromString

func AuthorizationErrorTypeFromString(value string) (AuthorizationErrorType, bool)

type ClientType

type ClientType string

ClientType as described in https://datatracker.ietf.org/doc/html/rfc6749#section-2.1

const (
	CtConfidential ClientType = "confidential"
	CtPublic       ClientType = "public"
)

func ClientTypeFromString

func ClientTypeFromString(value string) (ClientType, bool)

type GrantType

type GrantType string

GrantType as described in - https://datatracker.ietf.org/doc/html/rfc6749#appendix-A.10 - https://datatracker.ietf.org/doc/html/rfc7591#section-2

const (
	GtAuthorizationCode GrantType = "authorization_code"
	GtClientCredentials GrantType = "client_credentials"
	GtPassword          GrantType = "password"
	GtRefreshToken      GrantType = "refresh_token"
	GtImplicit          GrantType = "implicit" // RFC7591
)

func GrantTypeFromString

func GrantTypeFromString(value string) (GrantType, bool)

type IntrospectTokenType

type IntrospectTokenType string

IntrospectTokenType as described in https://datatracker.ietf.org/doc/html/rfc7662#section-2.1

const (
	ItAccessToken  IntrospectTokenType = "access_token"
	ItRefreshToken IntrospectTokenType = "refresh_token"
)

func IntrospectTokenTypeFromString

func IntrospectTokenTypeFromString(value string) (IntrospectTokenType, bool)

type RefreshToken

type RefreshToken struct {
	Key      string
	Username string
	ClientId string
	Scopes   []string
	AuthTime time.Time
}

type ResponseType

type ResponseType string

ResponseType as described in https://datatracker.ietf.org/doc/html/rfc6749#appendix-A.3

const (
	RtCode              ResponseType = "code"
	RtToken             ResponseType = "token"
	RtPassword          ResponseType = "password" // aka "implicit" grant
	RtClientCredentials ResponseType = "client_credentials"
	RtIdToken           ResponseType = "id_token"
)

func ResponseTypeFromString

func ResponseTypeFromString(value string) (ResponseType, bool)

type TokenErrorResponseParameter

type TokenErrorResponseParameter struct {
	Error       TokenErrorType `json:"error"`
	Description string         `json:"error_description,omitempty"`
	Uri         string         `json:"error_uri,omitempty"`
}

TokenErrorResponseParameter related to https://datatracker.ietf.org/doc/html/rfc6749#section-5.2

type TokenErrorType

type TokenErrorType string

TokenErrorType as described in multiple places e.g. https://datatracker.ietf.org/doc/html/rfc6749#section-5.2

const (
	TokenEtInvalidRequest       TokenErrorType = "invalid_request"
	TokenEtInvalidClient        TokenErrorType = "invalid_client"
	TokenEtInvalidGrant         TokenErrorType = "invalid_grant"
	TokenEtUnauthorizedClient   TokenErrorType = "unauthorized_client"
	TokenEtUnsupportedGrandType TokenErrorType = "unsupported_grant_type"
	TokenEtInvalidScope         TokenErrorType = "invalid_scope"
	// TokenEtUnsupportedTokenType https://datatracker.ietf.org/doc/html/rfc7009#section-2.2.1
	TokenEtUnsupportedTokenType TokenErrorType = "unsupported_token_type"
)

func TokenErrorTypeFromString

func TokenErrorTypeFromString(value string) (TokenErrorType, bool)

Jump to

Keyboard shortcuts

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