auth

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2020 License: MIT Imports: 5 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSecureJWTMiddleware

func GetSecureJWTMiddleware(realm, secretKey string) (*jwt.GinJWTMiddleware, error)

GetSecureJWTMiddleware instantiates a JWT middleware and all the necessary handlers

func IdentityHandler

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

IdentityHandler returns the Client structure

func PayloadMappingHandler

func PayloadMappingHandler(data interface{}) jwt.MapClaims

PayloadMappingHandler extracts the client_id, user_id and scope of the request

func ScopeAuthorizationHandler

func ScopeAuthorizationHandler(data interface{}, c *gin.Context) bool

ScopeAuthorizationHandler checks for required scopes

Types

type Authorization

type Authorization struct {
	ClientID  string `json:"client_id" binding:"required"`
	Name      string `json:"name"` // name of the domain, realm, tennant etc
	Token     string `json:"token" binding:"required"`
	TokenType string `json:"token_type" binding:"required"` // user,app,bot
	UserID    string `json:"user_id"`                       // depends on TokenType. UserID could equal ClientID
	Scope     string `json:"scope"`                         // a comma separated list of scopes, see below
	Expires   int64  `json:"expires"`                       // 0 = never
	// internal
	Created int64 `json:"-"`
	Updated int64 `json:"-"`
}

Authorization represents a user, app or bot and its permissions

type Client

type Client struct {
	ClientID string `json:"client_id"`
	UserID   string `json:"user_id"`
	Scope    string `json:"scope"`
}

Client represents the claim of the client calling the API

Jump to

Keyboard shortcuts

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