auth

package
v0.0.0-...-383e6fc Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2020 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package auth is the responsible of user authentication and authorization.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(ctx *context.Context)

Init checks whether the tokens secret is set and secure or not. It also creates the admin user if it doesn't exist

Types

type Token

type Token string

Token is a JWT token

func LoginLocal

func LoginLocal(ctx *context.Context, usr, pwd string) (Token, time.Time, error)

LoginLocal authenticates the user against the DB

func NewToken

func NewToken(ctx *context.Context, usr string) (Token, time.Time, error)

NewToken issues a new token

func (*Token) Renew

func (t *Token) Renew(ctx *context.Context) (time.Time, error)

Renew renews the validity of the token

func (Token) String

func (t Token) String() string

String returns the token as a string

func (*Token) Validate

func (t *Token) Validate(ctx *context.Context) bool

Validate checks whether a token is valid or not

func (*Token) ValidateAgent

func (t *Token) ValidateAgent(ctx *context.Context) (string, bool)

ValidateAgent checks whether an agent token (secret) is valid or not

type TokenClaims

type TokenClaims struct {
	Usr         string
	FirstIssued time.Time
	jwt.StandardClaims
}

TokenClaims are going to be embedded inside the JWT Token

Directories

Path Synopsis
Package types has all the different authentication types
Package types has all the different authentication types

Jump to

Keyboard shortcuts

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