login

package
v0.8.21 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2026 License: MIT Imports: 25 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"`
}

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:"-"`
}

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) 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) 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) 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) 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"`
	InfoUI string `cfg:"info_ui"`
	Status string `cfg:"status"`
}

type PathFixed

type PathFixed struct {
	Code   string
	InfoUI string
	Token  string
	Status 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