auth

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2024 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CsrfMiddleware = csrf.New(csrf.Config{
	KeyLookup:      "header:X-Csrf-Token",
	CookieName:     "csrf_",
	CookieSameSite: "Lax",
	Expiration:     1 * time.Hour,
	KeyGenerator:   utils.UUIDv4,

	ErrorHandler: func(c fiber.Ctx, err error) error {
		if err.Error() == "forbidden" {

			c.Cookie(&fiber.Cookie{
				Name:     "csrf_",
				Value:    "",
				Expires:  time.Now().Add(-1 * time.Hour),
				SameSite: "Lax",
			})
		}
		return c.Status(fiber.StatusForbidden).JSON(fiber.Map{
			"error": "CSRF token is invalid or missing",
		})
	},
})
View Source
var UserSessionStore *session.Store

Functions

func CreateRouter

func CreateRouter(app fiber.Router)

func CreateSessionStore

func CreateSessionStore()

func GetUsername

func GetUsername(c fiber.Ctx) (string, error)

func IsAuthenticated

func IsAuthenticated(c fiber.Ctx) error

func Login

func Login(c fiber.Ctx) error

func Logout

func Logout(c fiber.Ctx) error

func Protected

func Protected(c fiber.Ctx) error

func Register

func Register(c fiber.Ctx) error

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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