Documentation ¶
Index ¶
Constants ¶
View Source
const CurrentUser utils.ContextKey = "current_user"
CurrentUser context key to get current user from Request
Variables ¶
This section is empty.
Functions ¶
func GetCurrentUser ¶
GetCurrentUser tries to get the saved user from Context
func JWTAuth ¶
func JWTAuth(tokenStore TokenStore, signingKey string, claimConverter ClaimConverter) gin.HandlerFunc
JWTAuth returns a new JWT authentication handler
Types ¶
type ClaimConverter ¶
type ClaimConverter func(*ScopedClaims) interface{}
ClaimConverter converts claims to another domain object for saving into Context
type ScopedClaims ¶
type ScopedClaims struct { jwt.StandardClaims Scope string `json:"scope,omitempty"` // Drone fields Type TokenType `json:"type,omitempty"` Text string `json:"text,omitempty"` }
ScopedClaims struct to store the scoped claim related things
type Token ¶
type Token struct { ID string `json:"id"` Name string `json:"name"` CreatedAt *time.Time `json:"createdAt,omitempty"` }
Token represents an access token
type TokenStore ¶
type TokenStore interface { Store(userID string, token *Token) error Lookup(userID string, tokenID string) (*Token, error) Revoke(userID string, tokenID string) error List(userID string) ([]*Token, error) }
TokenStore is general interface for storing access tokens
func NewInMemoryTokenStore ¶
func NewInMemoryTokenStore() TokenStore
NewInMemoryTokenStore is a basic in-memory TokenStore implementation (thread-safe)
func NewVaultTokenStore ¶
func NewVaultTokenStore(role string) TokenStore
NewVaultTokenStore creates a new Vault backed token store
Click to show internal directories.
Click to hide internal directories.