auth

package
v0.0.0-...-049935a Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2018 License: Apache-2.0 Imports: 14 Imported by: 0

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

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

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

func NewToken

func NewToken(id, name string) *Token

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

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

type TokenType

type TokenType string

TokenType represents one of the possible token Types

Jump to

Keyboard shortcuts

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