middleware

package
v0.0.0-...-2ba808a Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AccessKey  = "education_jwt_access"
	RefreshKey = "education_jwt_refresh"
)

token keys

Variables

This section is empty.

Functions

func DeleteAccessCookie

func DeleteAccessCookie(ctx *gin.Context)

func DeleteRefreshCookie

func DeleteRefreshCookie(ctx *gin.Context)

func GetAllCookies

func GetAllCookies(ctx *gin.Context) []*http.Cookie

func InitCookieOptions

func InitCookieOptions(sameSite http.SameSite, secure bool)

InitCookieOptions initializes cookieOption

func PrintAllCookies

func PrintAllCookies(ctx *gin.Context)

func SetAccessCookie

func SetAccessCookie(ctx *gin.Context, token string)

SetAccessCookie is expected to create & refresh JWT. Ex: SessionHandler

func SetRefreshCookie

func SetRefreshCookie(ctx *gin.Context, token string)

SetRefreshCookie is expected to create & refresh JWT. Ex: SessionHandler

func SetUserAccessCookie

func SetUserAccessCookie(ctx *gin.Context, token string)

SetUserAccessCookie to set access token for user

Types

type ClaimsValidator

type ClaimsValidator interface {
	// contains filtered or unexported methods
}

ClaimsValidator contains methods for verifying claims

func NewCSRFValidator

func NewCSRFValidator(csrfRepository repository.CSRFRepository) ClaimsValidator

NewCSRFValidator return a claims validator for checking whether claims contain the correct csrf token

func NewRolesValidator

func NewRolesValidator() ClaimsValidator

NewRolesValidator return a claims validator for checking whether claims contains roles information

func NewTermsOfUseValidator

func NewTermsOfUseValidator() ClaimsValidator

NewTermsOfUseValidator return a claims validator for term of use agreement

func NewUserValidator

func NewUserValidator() ClaimsValidator

NewUserValidator return a claims validator for checking whether claims contains user id information

type CookieAuthenticator

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

CookieAuthenticator is for User/Office Authentication and CSRF protection

func NewCookieAuthenticator

func NewCookieAuthenticator(jwt services.JWT, validators ...ClaimsValidator) CookieAuthenticator

NewCookieAuthenticator returns CookieAuthenticator

func (*CookieAuthenticator) Authenticate

func (m *CookieAuthenticator) Authenticate(ctx *gin.Context)

Authenticate validates JWT and CSRF token, set userID and officeID this function is likely to replace Authenticate function because we will not check error in context anymore

type UserAuthenticator

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

func NewUserAuthenticator

func NewUserAuthenticator(jwt services.JWT) *UserAuthenticator

func (*UserAuthenticator) Authenticate

func (au *UserAuthenticator) Authenticate(ctx *gin.Context)

Jump to

Keyboard shortcuts

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