authentication

package
v0.0.0-...-d249aa4 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2016 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Roles contains the roles for the active auth driver
	Roles []Role
)

Functions

func GetJWTFromContext

func GetJWTFromContext(r *http.Request) *jwt.Token

GetJWTFromContext retrieves the JWT Token from the request

func GetToken

func GetToken(role *Role, username string) (string, error)

GetToken returns a string that contain the token

Types

type Config

type Config struct {
	Auth       structs.Auth
	DriverFn   loginFn
	DriverName string
}

Config contains the authentication configuration

func New

func New(auth structs.Auth) Config

New function initalizes and returns a Config struct

func (*Config) Advanced

func (a *Config) Advanced(driver loginFn, driverName string)

Advanced function allows a third party Identification driver

func (*Config) Authenticate

func (a *Config) Authenticate(next http.Handler) http.Handler

Authenticate calls the proper handler based on whether authentication is enabled or not

func (*Config) Login

func (a *Config) Login() http.Handler

Login authenticates a user against the authentication driver

func (*Config) None

func (a *Config) None()

None function sets the Config struct in order to disable authentication

func (*Config) Simple

func (a *Config) Simple(u []User)

Simple function sets the Config struct in order to enable simple authentication based on provided user and pass

type Role

type Role struct {
	AccessToken   string
	Datacenters   []string
	Fallback      bool
	Members       []string
	Name          string
	Readonly      bool
	Scope         Scope
	Subscriptions []string
}

Role contains the attributes of a role

func GetRoleFromToken

func GetRoleFromToken(token *jwt.Token) (*Role, error)

GetRoleFromToken ...

type Scope

type Scope struct {
	Delete []string
	Head   []string
	Get    []string
	Post   []string
}

Scope contains the type of access of a role

type TokenLocation

type TokenLocation func(r *http.Request) (string, error)

TokenLocation represents a function that accepts a request as input and returns either a token or an error.

type User

type User struct {
	ID           int64
	AccessToken  string
	Email        string
	FullName     string
	Password     string
	PasswordHash string
	PasswordSalt string
	Readonly     bool
	Role         Role
	Token        string
	Username     string
}

User contains the attributes of a user

Jump to

Keyboard shortcuts

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