oauth2

package
v0.22.2 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AuthCodeExpiry = 10 * time.Minute // OAuth2 spec recommends max 10 minutes
)

Variables

This section is empty.

Functions

func HandleAuthorizationServerMetadata

func HandleAuthorizationServerMetadata(w http.ResponseWriter, r *http.Request)

func HandleAuthorize

func HandleAuthorize(w http.ResponseWriter, r *http.Request)

HandleAuthorize handles the OAuth2 authorization endpoint

func HandleGrant

func HandleGrant(w http.ResponseWriter, r *http.Request)

HandleGrant handles the OAuth2 grant approval

func HandleToken

func HandleToken(w http.ResponseWriter, r *http.Request)

HandleToken handles the OAuth2 token endpoint

Types

type AuthCode

type AuthCode struct {
	Code        string
	UserId      string
	ClientId    string
	RedirectURI string
	Scope       string
	ExpiresAt   time.Time
}

type AuthCodeStore

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

func GetAuthCodeStore

func GetAuthCodeStore() *AuthCodeStore

func (*AuthCodeStore) ConsumeAuthCode

func (s *AuthCodeStore) ConsumeAuthCode(code string) (*AuthCode, bool)

func (*AuthCodeStore) CreateAuthCode

func (s *AuthCodeStore) CreateAuthCode(userId, clientId, redirectURI, scope string) (*AuthCode, error)

type AuthorizationServerMetadata

type AuthorizationServerMetadata struct {
	Issuer                            string   `json:"issuer"`
	AuthorizationEndpoint             string   `json:"authorization_endpoint"`
	TokenEndpoint                     string   `json:"token_endpoint"`
	ResponseTypesSupported            []string `json:"response_types_supported"`
	GrantTypesSupported               []string `json:"grant_types_supported"`
	TokenEndpointAuthMethodsSupported []string `json:"token_endpoint_auth_methods_supported"`
	ScopesSupported                   []string `json:"scopes_supported,omitempty"`
	CodeChallengeMethodsSupported     []string `json:"code_challenge_methods_supported,omitempty"`
}

type ErrorResponse

type ErrorResponse struct {
	Error            string `json:"error"`
	ErrorDescription string `json:"error_description,omitempty"`
}

type OpenIDConfiguration

type OpenIDConfiguration struct {
	Issuer                            string   `json:"issuer"`
	AuthorizationEndpoint             string   `json:"authorization_endpoint"`
	TokenEndpoint                     string   `json:"token_endpoint"`
	UserinfoEndpoint                  string   `json:"userinfo_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"`
}

type TokenResponse

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

Jump to

Keyboard shortcuts

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