access

package
v0.0.0-...-0456d95 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2017 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Access

type Access struct {
	Signature string
	Issuer    string
	// contains filtered or unexported fields
}

Access grant access to db and jwt

func New

func New(configpath string) (*Access, error)

New - given a path to a configuration file grants Access to the caller

func (Access) FindUserByEmail

func (a Access) FindUserByEmail(email string) (User, error)

FindUserByEmail - use email to retrieve user's details from DB and return a user struct

func (Access) NewToken

func (a Access) NewToken(name, email string) (string, int64, error)

NewToken - returns a new JWT

func (Access) RegisterUser

func (a Access) RegisterUser(name, email, passwordHash string) error

RegisterUser - add user to DB

func (Access) UpdateToken

func (a Access) UpdateToken(email, token string) error

UpdateToken - update the token document related to an user giving it a new token

type Claim

type Claim struct {
	User  string `json:"user"`
	Email string `json:"email"`
	jwt.StandardClaims
}

Claim wraps the info we want to pass in the JWT

type Credential

type Credential struct {
	Token     string `json:"token"`
	CreatedAt string `json:"created_at"`
}

Credential wraps data related to user access to api

type User

type User struct {
	Name         string `json:"name"`
	Email        string `json:"email"`
	PasswordHash string `json:"passwordhash"`
	CreatedAt    string `json:"createdat"`
}

User wraps data related to an auth user

Jump to

Keyboard shortcuts

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