authhttp

package
v0.0.0-...-a7ad5ca Latest Latest
Warning

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

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

Documentation

Overview

Package authhttp adapts authentication HTTP requests to the auth usecase.

Index

Constants

View Source
const (
	// LoginSessionCookieName is the HttpOnly browser credential for login
	// sessions. The composition root injects this name into the login-session
	// middleware so read and write sides share one declaration.
	LoginSessionCookieName = "login_session"
	// CSRFCookieName is the browser-readable double-submit CSRF cookie.
	CSRFCookieName = "csrf_token"
)

Variables

This section is empty.

Functions

func CSRFMiddlewareConfig

func CSRFMiddlewareConfig(exemptions []middlewares.RouteExemption, secure bool) middleware.CSRFConfig

CSRFMiddlewareConfig returns the Echo CSRF middleware configuration used for browser login-session requests. It shares the login-session exemptions because a route without a login session has no CSRF obligation.

func ClearCSRFCookie

func ClearCSRFCookie(c *echo.Context, secure bool)

ClearCSRFCookie removes the browser-readable CSRF token.

func ClearLoginSessionCookie

func ClearLoginSessionCookie(c *echo.Context, secure bool)

ClearLoginSessionCookie removes the browser session credential.

func NewCSRFToken

func NewCSRFToken() (string, error)

NewCSRFToken creates a browser-readable CSRF token for login responses.

func Register

func Register(group *echo.Group, handler *Handler)

Register mounts authentication routes on group.

func SetCSRFCookie

func SetCSRFCookie(c *echo.Context, token string, expiresAt time.Time, secure bool)

SetCSRFCookie stores the browser-readable CSRF token used by Echo's CSRF middleware.

func SetLoginSessionCookie

func SetLoginSessionCookie(c *echo.Context, token string, expiresAt time.Time, secure bool)

SetLoginSessionCookie stores the opaque browser session credential.

Types

type Handler

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

Handler adapts auth HTTP requests to the auth usecase.

func New

func New(uc *usecase.Usecase, secureCookies bool) *Handler

New creates an auth HTTP handler.

func (*Handler) ChangePassword

func (h *Handler) ChangePassword(c *echo.Context) error

ChangePassword updates the current administrator password and revokes other login sessions for the same administrator.

func (*Handler) Login

func (h *Handler) Login(c *echo.Context) error

Login handles administrator login.

func (*Handler) Logout

func (h *Handler) Logout(c *echo.Context) error

Logout revokes the current login session on the server.

func (*Handler) LogoutOthers

func (h *Handler) LogoutOthers(c *echo.Context) error

LogoutOthers revokes the current administrator's other login sessions.

func (*Handler) Me

func (h *Handler) Me(c *echo.Context) error

Me returns the authenticated administrator profile.

func (*Handler) SwitchRole

func (h *Handler) SwitchRole(c *echo.Context) error

SwitchRole changes the active role for the current administrator.

func (*Handler) UpdateProfile

func (h *Handler) UpdateProfile(c *echo.Context) error

UpdateProfile updates the current administrator's profile fields.

Jump to

Keyboard shortcuts

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