auth

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2018 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateApplicationToken

func GenerateApplicationToken() string

GenerateApplicationToken generates an application token.

func GenerateClientToken

func GenerateClientToken() string

GenerateClientToken generates a client token.

func GenerateImageName added in v1.1.3

func GenerateImageName() string

GenerateImageName generates an image name.

func GetTokenID

func GetTokenID(ctx *gin.Context) string

GetTokenID returns the tokenID

func GetUserID

func GetUserID(ctx *gin.Context) uint

GetUserID returns the user id which was previously registered by RegisterAuthentication.

func RegisterAuthentication

func RegisterAuthentication(ctx *gin.Context, user *model.User, userID uint, tokenID string)

RegisterAuthentication registers the user id, user and or token.

Types

type Auth

type Auth struct {
	DB Database
}

Auth is the provider for authentication middleware

func (*Auth) RequireAdmin

func (a *Auth) RequireAdmin() gin.HandlerFunc

RequireAdmin returns a gin middleware which requires a client token or basic authentication header to be supplied with the request. Also the authenticated user must be an administrator.

func (*Auth) RequireApplicationToken

func (a *Auth) RequireApplicationToken() gin.HandlerFunc

RequireApplicationToken returns a gin middleware which requires an application token to be supplied with the request.

func (*Auth) RequireClient

func (a *Auth) RequireClient() gin.HandlerFunc

RequireClient returns a gin middleware which requires a client token or basic authentication header to be supplied with the request.

type Database

type Database interface {
	GetApplicationByToken(token string) *model.Application
	GetClientByToken(token string) *model.Client
	GetUserByName(name string) *model.User
	GetUserByID(id uint) *model.User
}

The Database interface for encapsulating database access.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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