auth

package
v0.0.0-...-6b04d54 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const APIKeyLength = 32

APIKeyLength : API Key length

View Source
const (
	// NoDataFound : NDF error message text
	NoDataFound = "not found"
)
View Source
const (

	// SessionIDSeqName :
	SessionIDSeqName = "SESSION_ID_S"
)

Variables

This section is empty.

Functions

func GenerateToken

func GenerateToken(user *types.User) string

GenerateToken :

func IsNoDataFoundErr

func IsNoDataFoundErr(err error) bool

IsNoDataFoundErr : Check if given error is NDF

func VerifyToken

func VerifyToken(tokenString string) (*types.User, error)

VerifyToken : check token validity

Types

type LoginRequest

type LoginRequest struct {
	UserName string
	Password string
}

LoginRequest :

type LoginResponse

type LoginResponse struct {
	Jwt       string
	UserAttrs *types.UserAttrs
}

LoginResponse :

type Server

type Server interface {

	// Returns TRUE if auth is enabled.
	IsAuthEnabled() bool

	// CLI
	CreateUser(name, email, password string) (*types.UserAttrs, error)
	CreateTypedUser(usertype types.UserType, name, email, plainpass string) (*types.UserAttrs, error)
	DisableUser(username string) error
	EnableUser(username string) error
	GetUser(username string) (*types.UserAttrs, error)
	GetUserByAPIKey(apiKey string) (*types.UserAttrs, error)
	GetGuestUser() (*types.UserAttrs, error)
	// Web
	CreateJWT(name, txtPassword string) (jwtToken string, userAttrs *types.UserAttrs, fnError error)
	CreateAndLoginUser(name, email, password string) (*types.SessionAttrs, *types.UserAttrs, error)
	CreateSession(name, txtPassword string) (*types.SessionAttrs, error)
	SaveSession(jwt string, userAttrs *types.UserAttrs) (*types.SessionAttrs, error)
}

Server : Manage Authorization

func NewAuthServer

func NewAuthServer(q *qs.QueryServer, noAuth bool) Server

NewAuthServer : Returns new auth server object

type UserClaims

type UserClaims struct {
	User *types.User `json:"user"`
	jwt.StandardClaims
}

UserClaims : Session tokens

Jump to

Keyboard shortcuts

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