auth

package module
v0.0.6 Latest Latest
Warning

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

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

README

auth

Packetframe Authentication Service

API Reference:
Signup

POST /signup

Required parameters:

Name Description Validation
email User's email address Email address
password User's password Min 10 characters

Example response (HTTP 200):

{
  "message": "Signup success"
}
Login

POST /login

Required parameters:

Name Description Validation
email User's email address Email address
password User's password Min 10 characters

Example response (HTTP 200):

{
  "key": "Epk3Xq9X4dPvQjTjY3Odskx17EiiitVSvBTfwla0REC4AvcU"
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PasswordHash

func PasswordHash(plaintext string) ([]byte, error)

PasswordHash hashes a plaintext string and returns an argon2 hash byte slice

func RandomString

func RandomString(length int) string

RandomString returns a securely generated random string

func ValidHash

func ValidHash(payload []byte, plaintext string) bool

ValidHash validates a hash and provided plaintext password

Types

type User

type User struct {
	ID       primitive.ObjectID `json:"-" bson:"_id,omitempty"`
	Email    string             `json:"email" validate:"required,email"`
	Password string             `json:"password" bson:"-" validate:"required,gte=10"`
	APIKey   string             `json:"-"`
	Enabled  bool               `json:"-"`
	Roles    []string           `json:"-" bson:"roles,omitempty"`
	Hash     []byte             `json:"-"`
}

User stores a user account

func GetUser

func GetUser(ctx *fiber.Ctx, db *database.Database) (*User, error)

GetUser checks if a user is authenticated and is present in the database

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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