bank-vaults: Index | Files

package auth

import ""


Package Files

auth.go tokenstore.go


const CurrentUser utils.ContextKey = "current_user"

CurrentUser context key to get current user from Request

func GetCurrentUser Uses

func GetCurrentUser(c *gin.Context) interface{}

GetCurrentUser tries to get the saved user from Context

func JWTAuth Uses

func JWTAuth(tokenStore TokenStore, signingKey string, claimConverter ClaimConverter, extractors ...jwtRequest.Extractor) gin.HandlerFunc

JWTAuth returns a new JWT authentication handler

type ClaimConverter Uses

type ClaimConverter func(*ScopedClaims) interface{}

ClaimConverter converts claims to another domain object for saving into Context

type ScopedClaims Uses

type ScopedClaims struct {
    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 Uses

type Token struct {
    ID        string     `json:"id"`
    Name      string     `json:"name"`
    ExpiresAt *time.Time `json:"expiresAt,omitempty"`
    CreatedAt *time.Time `json:"createdAt,omitempty"`
    Value     string     `json:"value,omitempty"`

Token represents an access token

func NewToken Uses

func NewToken(id, name string) *Token

NewToken Creates a new Token instance initialized ID and Name and CreatedAt fields

type TokenStore Uses

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)
    GC() error

TokenStore is general interface for storing access tokens

func NewInMemoryTokenStore Uses

func NewInMemoryTokenStore() TokenStore

NewInMemoryTokenStore is a basic in-memory TokenStore implementation (thread-safe)

func NewVaultTokenStore Uses

func NewVaultTokenStore(role string) TokenStore

NewVaultTokenStore creates a new Vault backed token store

type TokenType Uses

type TokenType string

TokenType represents one of the possible token Types

Package auth imports 14 packages (graph) and is imported by 1 packages. Updated 2018-12-14. Refresh now. Tools for package owners.