login

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Info

type Info struct {
	Title string `cfg:"title"`
}

type InfoProvider

type InfoProvider struct {
	Password []Link `json:"password"`
	Code     []Link `json:"code"`
	Passkey  []Link `json:"passkey"`
}

type InfoUIResponse

type InfoUIResponse struct {
	Title    string       `json:"title"`
	Provider InfoProvider `json:"provider"`
	Error    string       `json:"error,omitempty"`
}
type Link struct {
	Name     string `json:"name"`
	URL      string `json:"url"`
	Priority int    `json:"-"`

	// optional signup / forgot-password proxy endpoints; only set on
	// password providers whose auth middleware enables those flows.
	SignupURL               string `json:"signup_url,omitempty"`
	SignupVerifyURL         string `json:"signup_verify_url,omitempty"`
	PasswordResetURL        string `json:"password_reset_url,omitempty"`
	PasswordResetConfirmURL string `json:"password_reset_confirm_url,omitempty"`
	// PasswordMinLength is advertised so the signup/reset forms can enforce
	// and display the configured minimum; 0 means the UI default applies.
	PasswordMinLength int `json:"password_min_length,omitempty"`
}

type Login

type Login struct {
	Path     Path     `cfg:"path"`
	Redirect Redirect `cfg:"redirect"`
	UI       UI       `cfg:"ui"`
	Info     Info     `cfg:"info"`
	Request  Request  `cfg:"request"`

	SessionMiddleware string `cfg:"session_middleware"`

	StateCookie   auth.Cookie `cfg:"state_cookie"`
	SuccessCookie auth.Cookie `cfg:"success_cookie"`

	// Store for effect code, only for code flow and works with redis.
	Store             store.Store `cfg:"store"`
	RedirectWhiteList []string    `cfg:"redirect_white_list"`
	// contains filtered or unexported fields
}

Login middleware gives a login page.

func (*Login) AuthCodeRedirectURL

func (m *Login) AuthCodeRedirectURL(r *http.Request, providerName string) (string, error)

func (*Login) AuthCodeReturn added in v0.8.14

func (m *Login) AuthCodeReturn(w http.ResponseWriter, r *http.Request, customClaim *claims.Custom)

func (*Login) AuthCodeURL

func (m *Login) AuthCodeURL(r *http.Request, state, providerName string, oauth2 *session.Oauth2) (string, error)

func (*Login) CheckState

func (m *Login) CheckState(w http.ResponseWriter, r *http.Request, check string) error

func (*Login) CodeFlow

func (m *Login) CodeFlow(w http.ResponseWriter, r *http.Request)

func (*Login) CodeFlowInit

func (m *Login) CodeFlowInit(w http.ResponseWriter, r *http.Request, providerName string)

func (*Login) CodeToken

func (m *Login) CodeToken(r *http.Request, code, providerName string, oauth2 *session.Oauth2) ([]byte, int, error)

CodeToken get token and set the cookie/session.

func (*Login) GetState

func (m *Login) GetState(r *http.Request) (string, error)

func (*Login) GetSuccess

func (m *Login) GetSuccess(r http.Request) (string, error)

func (*Login) InformationUI

func (m *Login) InformationUI(w http.ResponseWriter, r *http.Request)

func (*Login) Init added in v0.8.14

func (m *Login) Init() error

func (*Login) IsForRedirection added in v0.8.14

func (m *Login) IsForRedirection(r *http.Request) bool

func (*Login) IsValidRedirectURI added in v0.8.14

func (m *Login) IsValidRedirectURI(redirectURI string) bool

func (*Login) IssuerPasswordToken added in v0.9.0

func (m *Login) IssuerPasswordToken(ctx context.Context, issuerName, username, password string, oauth2 *session.Oauth2) ([]byte, int, error)

IssuerPasswordToken runs the password grant in-process against a registered issuer (auth middleware) instead of calling token_url over HTTP.

func (*Login) Logout

func (m *Login) Logout(w http.ResponseWriter, r *http.Request)

func (*Login) Middleware

func (m *Login) Middleware(ctx context.Context) (func(http.Handler) http.Handler, error)

func (*Login) PasskeyFlow added in v0.9.0

func (m *Login) PasskeyFlow(w http.ResponseWriter, r *http.Request)

PasskeyFlow proxies WebAuthn begin/finish ceremonies to an in-process auth middleware; a finish response with tokens is stored in the session.

func (*Login) PasswordFlow

func (m *Login) PasswordFlow(w http.ResponseWriter, r *http.Request)

func (*Login) PasswordToken

func (m *Login) PasswordToken(ctx context.Context, username, password string, oauth2 *session.Oauth2) ([]byte, int, error)

func (*Login) RemotePasskeyToken added in v0.9.0

func (m *Login) RemotePasskeyToken(r *http.Request, passkeyURL string, body []byte) ([]byte, int, error)

RemotePasskeyToken proxies a WebAuthn begin/finish payload to a remote auth middleware's passkey endpoint. The original request's host/scheme is forwarded so the remote side derives the relying party from the login page. Non-2xx responses are passed through to the caller, not turned into errors.

func (*Login) RemoveState

func (m *Login) RemoveState(w http.ResponseWriter)

func (*Login) RemoveSuccess

func (m *Login) RemoveSuccess(w http.ResponseWriter)

func (*Login) SetFiles added in v0.8.14

func (m *Login) SetFiles() error

func (*Login) SetState

func (m *Login) SetState(w http.ResponseWriter, state string)

func (*Login) SetSuccess

func (m *Login) SetSuccess(w http.ResponseWriter, success string)

func (*Login) SetUI added in v0.8.14

func (m *Login) SetUI() (func(http.Handler) http.Handler, error)

func (*Login) SignupFlow added in v0.9.0

func (m *Login) SignupFlow(w http.ResponseWriter, r *http.Request, action string)

SignupFlow proxies signup/verify/password-reset requests to the provider's auth middleware, injecting the provider client credentials so the SPA never sees them. Responses are passed through unchanged.

func (*Login) StatusHandler added in v0.8.14

func (m *Login) StatusHandler(w http.ResponseWriter, r *http.Request)

func (*Login) UIHandler added in v0.8.14

func (m *Login) UIHandler(w http.ResponseWriter, r *http.Request)

type Path

type Path struct {
	Base string `cfg:"base"`
	// BaseURL for adding prefix like https://example.com
	BaseURL string `cfg:"base_url"`

	Code    string `cfg:"code"`
	Token   string `cfg:"token"`
	Passkey string `cfg:"passkey"`
	InfoUI  string `cfg:"info_ui"`
	Status  string `cfg:"status"`
}

type PathFixed

type PathFixed struct {
	Code         string
	InfoUI       string
	Token        string
	Passkey      string
	Status       string
	Signup       string
	SignupVerify string
	Reset        string
	ResetConfirm string
}

type Redirect

type Redirect struct {
	// BaseURL is the base URL to use for the redirect.
	// Default is the request Host with checking the X-Forwarded-Host header.
	BaseURL string `cfg:"base_url"`
	// Schema is the default schema to use for the redirect if no schema is provided.
	// Default is the https schema.
	Schema string `cfg:"schema"`
}

type Request

type Request struct {
	InsecureSkipVerify bool `cfg:"insecure_skip_verify"`
}

type TokenRequest

type TokenRequest struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

type UI

type UI struct {
	ExternalFolder bool `cfg:"external_folder"`
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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