auth

package
v0.0.0-...-e78e600 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2020 License: GPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Admin

func Admin(handlerFunc http.HandlerFunc) http.HandlerFunc

Checks if user is admin. If not, the handlerFunc won't be called.

func Auth

func Auth(handlerFunc http.HandlerFunc) http.HandlerFunc

Checks if user is logged in. If not, the handlerFunc won't be called.

func Check

func Check(token string) (user *database.User, expiration time.Time, err error)

Checks, if the given JWT is valid. Returns true if it is valid. Returns the user which belongs to the JWT. If the JWT is not valid, the user will be nil.

func SaveUser

func SaveUser(user *database.User) error

func Serve

Serve function for this package.

Types

type AdminUser

type AdminUser struct {
	Email string `json:"email"`
	Admin bool   `json:"admin"`
}

type Credentials

type Credentials struct {
	Email    string
	Password string
}

use for plainttext passwords only

type JWTHeader

type JWTHeader struct {
	Algorithm string `json:"alg"`
	Type      string `json:"typ"`
}

Defines the JWT header.

type JWTPayload

type JWTPayload struct {
	Email      string    `json:"Email"`
	Expiration time.Time `json:"exp"`
	LastChange time.Time `json:"lastChange"`
}

Defines the JWT payload which is used to communicate between server and client.

Jump to

Keyboard shortcuts

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