Documentation
¶
Index ¶
- func AuthAdd(req *http.Request, clientID, clientSecret string, ...)
- func NewState() (string, error)
- func RemoveCookie(w http.ResponseWriter, cookie *Cookie)
- func SetBearerAuth(r *http.Request, token string)
- func SetCookie(w http.ResponseWriter, value string, cookie *Cookie)
- type Cookie
- type Info
- type InfoProvider
- type InfoUIResponse
- type Link
- type Login
- func (m *Login) AuthCodeRedirectURL(r *http.Request, providerName string) (string, error)
- func (m *Login) AuthCodeURL(r *http.Request, state, providerName string, oauth2 *session.Oauth2) (string, error)
- func (m *Login) CheckState(c echo.Context, check string) error
- func (m *Login) CodeFlow(c echo.Context) error
- func (m *Login) CodeFlowInit(c echo.Context, providerName string) error
- func (m *Login) CodeToken(c echo.Context, code, providerName string, oauth2 *session.Oauth2) ([]byte, int, error)
- func (m *Login) GetState(c echo.Context) (string, error)
- func (m *Login) GetSuccess(c echo.Context) (string, error)
- func (m *Login) InformationUI(c echo.Context) error
- func (m *Login) Logout(c echo.Context) error
- func (m *Login) Middleware(ctx context.Context, _ string) (echo.MiddlewareFunc, error)
- func (m *Login) PasswordFlow(c echo.Context) error
- func (m *Login) PasswordToken(ctx context.Context, username, password string, oauth2 *session.Oauth2) ([]byte, int, error)
- func (m *Login) RemoveState(c echo.Context)
- func (m *Login) RemoveSuccess(c echo.Context)
- func (m *Login) SetState(c echo.Context, state string)
- func (m *Login) SetSuccess(c echo.Context, success string)
- func (m *Login) SetView() (func(http.Handler) http.Handler, error)
- func (m *Login) View(w http.ResponseWriter, r *http.Request) error
- type Path
- type PathFixed
- type Provider
- type Redirect
- type Request
- type TokenRequest
- type UI
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AuthAdd ¶
func AuthAdd(req *http.Request, clientID, clientSecret string, style session.AuthHeaderStyle)
AuthAdd is a function to set Authorization header.
Style must be AuthHeaderStyleBasic or AuthHeaderStyleBearerSecret, otherwise it does nothing.
Default style is AuthHeaderStyleBasic.
func RemoveCookie ¶
func RemoveCookie(w http.ResponseWriter, cookie *Cookie)
func SetBearerAuth ¶
SetBearerAuth sets the Authorization header to use Bearer token.
Types ¶
type Cookie ¶
type Cookie struct {
// CookieName is the name of the cookie. Default is "auth_" + ClientID.
CookieName string `cfg:"cookie_name"`
// MaxAge the number of seconds until the cookie expires.
MaxAge int `cfg:"max_age"`
// Path that must exist in the requested URL for the browser to send the Cookie header.
Path string `cfg:"path"`
// Domain for defines the host to which the cookie will be sent.
Domain string `cfg:"domain"`
// Secure to cookie only sent over HTTPS.
Secure bool `cfg:"secure"`
// SameSite for Lax 2, Strict 3, None 4.
SameSite http.SameSite `cfg:"same_site"`
// HttpOnly for true for not accessible by JavaScript.
HttpOnly bool `cfg:"http_only"`
}
type InfoProvider ¶
type InfoUIResponse ¶
type InfoUIResponse struct {
Title string `json:"title"`
Provider InfoProvider `json:"provider"`
}
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 Cookie `cfg:"state_cookie"`
SuccessCookie Cookie `cfg:"success_cookie"`
// contains filtered or unexported fields
}
Login middleware gives a login page.
func (*Login) AuthCodeRedirectURL ¶
func (*Login) AuthCodeURL ¶
func (*Login) CodeFlowInit ¶
func (*Login) CodeToken ¶
func (m *Login) CodeToken(c echo.Context, code, providerName string, oauth2 *session.Oauth2) ([]byte, int, error)
CodeToken get token and set the cookie/session.
func (*Login) Middleware ¶
func (*Login) PasswordToken ¶
func (*Login) RemoveState ¶
func (*Login) RemoveSuccess ¶
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 TokenRequest ¶
Click to show internal directories.
Click to hide internal directories.