oauth2server

package
v0.0.21 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2025 License: MIT Imports: 21 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildOauthRedirect

func BuildOauthRedirect(cfg *config.Config, redirectType RedirectType, queryParams map[string]string) (string, error)

Types

type LoginPageData

type LoginPageData struct {
	ClientID     string
	LoginURI     string
	RedirectURI  string
	ResponseType string
	State        string
	Scope        string
	Error        string
	ErrorMessage string
	PageKey      string
}

LoginPageData holds the data to be passed to the login template

type Oauth2Server

type Oauth2Server struct {
	Ctx         context.Context
	Cfg         *config.Config
	Repository  repositories.RepositoriesInterface
	Srv         *server.Server
	PrivateKey  *rsa.PrivateKey
	Kid         string
	StringCache *cache.RedisCache[string]
}

func (*Oauth2Server) HandleAuthorize

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

HandleAuthorize handles the OAuth2 authorization request

func (*Oauth2Server) HandleJWKS

func (self *Oauth2Server) HandleJWKS(w http.ResponseWriter, r *http.Request)

HandleJWKS returns your server's public key in JWKS format

func (*Oauth2Server) HandleLoginPage

func (self *Oauth2Server) HandleLoginPage(w http.ResponseWriter, r *http.Request)

HandleLoginPage renders a styled login form

func (*Oauth2Server) HandleOpenIDConfiguration

func (self *Oauth2Server) HandleOpenIDConfiguration(w http.ResponseWriter, r *http.Request)

HandleWellKnown serves the OIDC Discovery document at /.well-known/openid-configuration

func (*Oauth2Server) HandleToken

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

func (*Oauth2Server) HandleUserinfo

func (self *Oauth2Server) HandleUserinfo(w http.ResponseWriter, r *http.Request)

func (*Oauth2Server) PasswordAuthorizationHandler

func (self *Oauth2Server) PasswordAuthorizationHandler(ctx context.Context, clientID, username, password string) (userID string, err error)

type RedirectType

type RedirectType string
const (
	RedirectLogin     RedirectType = "login"
	RedirectAuthorize RedirectType = "authorize"
)

type WellKnownConfig

type WellKnownConfig struct {
	Issuer                           string   `json:"issuer"`
	AuthorizationEndpoint            string   `json:"authorization_endpoint"`
	TokenEndpoint                    string   `json:"token_endpoint"`
	UserinfoEndpoint                 string   `json:"userinfo_endpoint,omitempty"`
	JWKSURI                          string   `json:"jwks_uri,omitempty"`
	ResponseTypesSupported           []string `json:"response_types_supported,omitempty"`
	SubjectTypesSupported            []string `json:"subject_types_supported,omitempty"`
	IDTokenSigningAlgValuesSupported []string `json:"id_token_signing_alg_values_supported,omitempty"`
	ScopesSupported                  []string `json:"scopes_supported,omitempty"`
}

WellKnownConfig holds the fields you want to return in /.well-known/openid-configuration

Jump to

Keyboard shortcuts

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