auth

package module
v0.0.0-...-950aa7d Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2015 License: MIT Imports: 12 Imported by: 0

README

Go Auth Library

Auth is a library for implementing HTTP authentication in Go. This fork is trying to add LDAP authentication.

Authors

License

MIT (see LICENSE)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetToken

func GetToken(role Role) (string, error)

GetToken returns a string that contain the token

Types

type Config

type Config struct {
	Driver     loginFn
	DriverName string
}

Config struct contains the authentication configuration

func New

func New() 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) GetIdentification

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

GetIdentification retrieves the user & pass from a POST and authenticates the user against the Identification driver

func (*Config) GetUser

func (a *Config) GetUser(t, e string) map[string]string

func (*Config) LdapAd

func (a *Config) LdapAd(u, p string)

func (*Config) LdapIpa

func (a *Config) LdapIpa(u, p string)

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, p string)

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

type Role

type Role struct {
	Get   bool
	Post  bool
	Admin bool
}

Role ...

type User

type User struct {
	ID           int64  `db:"id"`
	Username     string `db:"username"`
	FullName     string `db:"fullName"`
	Email        string `db:"email"`
	Org          string `db:"company"`
	Password     string `db:"-"`
	PasswordHash string `db:"passwordHash"`
	PasswordSalt string `db:"passwordSalt"`
	Role         string `db:"role"`
	Token        string `db:"-"`
}

User structure

Jump to

Keyboard shortcuts

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