auth

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BasicAuth

func BasicAuth(username, password string, realm ...string) egor.Middleware

Basic Auth middleware. If the username and password are not correct, a 401 status code is sent. The realm is the realm to display in the login box. Default is "Restricted".

func CreateJWTToken

func CreateJWTToken(secret string, payload any, exp time.Duration) (string, error)

CreateToken creates a new JWT token with the given payload and expiry duration. JWT is signed with the given secret using the HMAC256 alegorithm.

func GetClaims

func GetClaims(req *http.Request) jwt.MapClaims

GetClaims returns the claims from the request context or nil if not found.

func JWT

func JWT(secret string) egor.Middleware

JWT creates a JWT middleware with the given secret and options.

func VerifyJWToken

func VerifyJWToken(secret, tokenString string) (jwt.MapClaims, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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