Documentation ¶
Index ¶
Constants ¶
View Source
const ( AccessTokenCookiesName = "access_token" RefreshTokenCookiesName = "refresh_token" )
View Source
const PayloadKey = "payload"
Variables ¶
View Source
var ( ErrTokenAbscent = errors.New("token abscent") ErrTokenExpired = errors.New("token expired") ErrTokenInvalid = errors.New("token invalid") ErrPayloadMismatch = errors.New("payload mismatch") ErrNeedPayloadType = errors.New("need payload type to construct it on decode time") ErrNeedRefreshTokenStorage = errors.New("must have persistent refresh token storage. without it security level will be to low") ErrNeedRBAC = errors.New("must have RBAC checker function") ErrDoAutoRefresh = errors.New("successfully do autorefresh access token") // there is no success logging, so do error )
Functions ¶
This section is empty.
Types ¶
type AccessToken ¶
type AccessToken struct {
// contains filtered or unexported fields
}
type Config ¶
type Config struct { RefreshURL string LoginURL string ReturnToRef bool // will refresh produce 307 redirect in case of noon empty referer DisableAutoRefresh bool // will automatically refresh access token in case of expire or do 401 or redirect PrivateKey ed25519.PrivateKey // is necessary only for NewSession & Refresh to generate new access & refresh tockens PublicKey ed25519.PublicKey ExpirationAccess time.Duration ExpirationRefresh time.Duration ErrorLogger ErrorLogger StoreRefreshAtStorage StoreRefreshAtStorage RemoveRefreshAtStorage RemoveRefreshAtStorage ReplaceRefreshAtStorage ReplaceRefreshAtStorage PayloadType reflect.Type // necessary to convert from token to struct RBAC RBAC }
type ErrorLogger ¶
type Middleware ¶
type Middleware struct {
// contains filtered or unexported fields
}
func New ¶
func New(cfg Config) (*Middleware, error)
func (Middleware) Access ¶
func (m Middleware) Access(c *gin.Context)
func (Middleware) ExtractPayload ¶
func (m Middleware) ExtractPayload(c context.Context) interface{}
func (Middleware) Logout ¶
func (m Middleware) Logout(c *gin.Context)
func (Middleware) NewSession ¶
func (m Middleware) NewSession(c *gin.Context, payload interface{}) error
func (Middleware) Refresh ¶
func (m Middleware) Refresh(c *gin.Context)
type RefreshToken ¶
type RefreshToken struct { Generation uint64 // contains filtered or unexported fields }
type RemoveRefreshAtStorage ¶
type ReplaceRefreshAtStorage ¶
Click to show internal directories.
Click to hide internal directories.