auth

package
v0.0.0-...-c042da3 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2021 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPasswordHash

func CheckPasswordHash(password, hash string) bool

compares a plain text password with a hash and returns true for matches otherwise false

func HashPassword

func HashPassword(password string) (string, error)

generates an encrypted password

Types

type RoleType

type RoleType int

RoleType defines role for a User

const (
	ADMIN RoleType = iota
	USER
)

func (*RoleType) ToRole

func (r *RoleType) ToRole(t string) RoleType

ToRole converts string to RoleType

func (*RoleType) ToString

func (r *RoleType) ToString(rt RoleType) string

ToString converts RoleType to string

type User

type User struct {
	ID       string `json:"_id"`
	Name     string `json:"name" binding:"required"`
	Password string `json:"password" binding:"required"`
	Email    string `json:"email,omitempty"`
	Role     string `json:"role"`
	Type     string `json:"type"`
}

User is basic authentication information

func (*User) AuthMiddleware

func (u *User) AuthMiddleware(bucket string, d ds.DataSource) *jwt.GinJWTMiddleware

AuthMiddleware initializes our jwt components

func (*User) BootstrapUsers

func (u *User) BootstrapUsers(defaultuser *string, d ds.DataSource) error

add a user named 'bfpdadmin' with ADMIN role

Jump to

Keyboard shortcuts

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