Documentation ¶
Index ¶
- Variables
- func InitWithOptions(options ...Options)
- func NMiddleware(store PublicKeyStore) func(c *gin.Context)
- func WithMaxAccessTokenAge(maxAge time.Duration) func(c *Config)
- func WithMaxRefreshTokenAge(maxAge time.Duration) func(c *Config)
- func ZHandler(accesses []Access) gin.HandlerFunc
- func ZMiddleware(accessMap map[string][]Access) gin.HandlerFunc
- type Access
- type AccessTokenClaims
- type Config
- type DataSource
- type ExpirableClaims
- type KeyInfo
- type NEndpointOptions
- type NEndpoints
- type NRefreshRequest
- type NRequest
- type NResponse
- type Options
- type PublicKeyStore
- type RefreshTokenClaims
- type User
Constants ¶
This section is empty.
Variables ¶
View Source
var ( UserIdXAuthKey = "auth_user_id" AccessesXAuthKey = "accesses_user_id" )
Functions ¶
func InitWithOptions ¶
func InitWithOptions(options ...Options)
func NMiddleware ¶
func NMiddleware(store PublicKeyStore) func(c *gin.Context)
func WithMaxAccessTokenAge ¶
func WithMaxRefreshTokenAge ¶
func ZHandler ¶
func ZHandler(accesses []Access) gin.HandlerFunc
ZHandler is a gin middleware creator that checks if the user has the required access. ZHandler is similar to ZMiddleware, but it is used to check the access of a single API.
func ZMiddleware ¶
func ZMiddleware(accessMap map[string][]Access) gin.HandlerFunc
ZMiddleware is a gin middleware creator that checks if the user has the required access. ZMiddleware is similar to ZHandler, but it is used to check the access of multiple APIs and supports path matching.
Types ¶
type AccessTokenClaims ¶
type AccessTokenClaims struct { ExpirableClaims Account string `json:"sub"` UserId interface{} `json:"uid"` Audience string `json:"aud,omitempty"` Issuer string `json:"iss,omitempty"` Accesses []Access `json:"accesses,omitempty"` }
type DataSource ¶
type ExpirableClaims ¶
type ExpirableClaims struct {
ExpiresAt int64 `json:"exp,omitempty"`
}
func (*ExpirableClaims) Valid ¶
func (t *ExpirableClaims) Valid() error
func (*ExpirableClaims) VerifyExpiresAt ¶
func (t *ExpirableClaims) VerifyExpiresAt(cmp int64) bool
type NEndpointOptions ¶
func NewNEndpointOptions ¶
func NewNEndpointOptions() *NEndpointOptions
type NEndpoints ¶
type NEndpoints struct {
// contains filtered or unexported fields
}
func NewNEndpoints ¶
func NewNEndpoints(ctx context.Context, keystore PublicKeyStore, authDs DataSource, options *NEndpointOptions) *NEndpoints
func (*NEndpoints) LoginEndpoint ¶
func (n *NEndpoints) LoginEndpoint(c *gin.Context)
func (*NEndpoints) RefreshKey ¶
func (n *NEndpoints) RefreshKey(ctx context.Context)
func (*NEndpoints) RefreshTokenEndpoint ¶
func (n *NEndpoints) RefreshTokenEndpoint(c *gin.Context)
type NRefreshRequest ¶
type NRefreshRequest struct {
RefreshToken string `form:"refresh_token" json:"refresh_token"`
}
type PublicKeyStore ¶
type RefreshTokenClaims ¶
type RefreshTokenClaims struct { ExpirableClaims UserId interface{} `json:"uid"` Account string `json:"sub"` }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.