auth

package
v0.0.0-...-0b41048 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Auth

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

Auth definition

func New

func New(environ *env.ENV) *Auth

New returns a new auth with env

func (*Auth) GenerateToken

func (a *Auth) GenerateToken(id uint) (*AuthToken, error)

GenerateToken generates a new auth token with expired date computed with current time

func (*Auth) GenerateTokenWithTime

func (a *Auth) GenerateTokenWithTime(id uint, t time.Time) (*AuthToken, error)

GenerateTokenWithTime generates a new auth token with expired date computed with specified time

func (*Auth) GetContextUserID

func (a *Auth) GetContextUserID(ctx *gin.Context) uint

GetContextUserID returns auth user id from http context

func (*Auth) GetUserID

func (a *Auth) GetUserID(ctx *gin.Context, strictCookie, refresh bool) (uint, error)

GetUserID gets a user id from request context

func (*Auth) SetContextUserID

func (a *Auth) SetContextUserID(ctx *gin.Context, id uint)

SetContextUserID sets auth user id to http context

func (*Auth) SetCookieToken

func (a *Auth) SetCookieToken(ctx *gin.Context, token AuthToken, path string)

SetCookieToken sets a jwt token cookie in http header

type AuthToken

type AuthToken struct {
	Token        string
	RefreshToken string
}

AuthToken definition

Jump to

Keyboard shortcuts

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