middleware

package
v0.0.0-...-8aa1d3a Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LoginUrlRedirect     = "/login"
	DashboardUrlRedirect = "/dashboard"
)
View Source
const (
	UserIDContext      = "x-user-id"
	UserRoleContext    = "x-user-role"
	AuthAccessContext  = "x-a-auth"
	AuthRefreshContext = "x-r-auth"
	RoleSuperAdmin     = "super_admin"
	RoleAdmin          = "admin"
	RoleStaff          = "staff"
	RoleAnonymous      = "anonymous"
	RefreshToken       = "refresh_token"
	AccessToken        = "access_token"
)

Variables

This section is empty.

Functions

func AuthMiddleware

func AuthMiddleware(secret string, casbinEnforcer *casbin.Enforcer, cryptos cryptos.Cryptos, accessTokenUsecase domain.AccessTokenUsecase, refreshTokenUsecase domain.RefreshTokenUsecase) gin.HandlerFunc

func AuthPublicMiddleware

func AuthPublicMiddleware(secret string, casbinEnforcer *casbin.Enforcer, cryptos cryptos.Cryptos, accessTokenUsecase domain.AccessTokenUsecase, refreshTokenUsecase domain.RefreshTokenUsecase) gin.HandlerFunc

func CorsMiddleware

func CorsMiddleware() gin.HandlerFunc

func GetAuthContext

func GetAuthContext(c *gin.Context, cryptos cryptos.Cryptos, tokenType string) (token string, err error)

func GetUserContext

func GetUserContext(c *gin.Context, cryptos cryptos.Cryptos) (userID string, userRole string)

func JwtAuthMiddleware

func JwtAuthMiddleware(secret string, casbinEnforcer *casbin.Enforcer, cryptos cryptos.Cryptos, accessTokenUsecase domain.AccessTokenUsecase, refreshTokenUsecase domain.RefreshTokenUsecase) gin.HandlerFunc

func SetAuthContext

func SetAuthContext(c *gin.Context, cryptos cryptos.Cryptos, accessToken string, refreshToken string) error

func SetAuthCookies

func SetAuthCookies(accessToken string, refreshToken string) gin.HandlerFunc

func SetUserContext

func SetUserContext(c *gin.Context, cryptos cryptos.Cryptos, userID, userRole string)

Types

This section is empty.

Jump to

Keyboard shortcuts

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