auth

package
v0.0.0-...-f07dfbc Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2022 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidCredentials is an error message when credentials are invalid
	ErrInvalidCredentials = errors.New("Invalid Username or Password")
	// ErrUsernameAlreadyTaken is an error message when the username is already used by someone else
	ErrUsernameAlreadyTaken = errors.New("Username already taken")
	// ErrUsernameAlreadyTakenOnLDAP is an error message when the username is already used by someone else on LDAP
	ErrUsernameAlreadyTakenOnLDAP = errors.New("Username already taken in the configured LDAP server. Try login instead")
)

Functions

func SendWelcomeEmail

func SendWelcomeEmail(user types.User)

SendWelcomeEmail sends a welcome email after a user's registration

Types

type Attributes

type Attributes struct {
	Username  string
	Firstname string
	Lastname  string
	Realname  string
	Email     string
}

Attributes list all LDAP attributes names in the LDAP

type Authentication

type Authentication struct {
	Users types.UserRepo
	LDAP  *LDAP
}

Authentication contains all APIs entrypoints needed for authentication

func (*Authentication) AuthenticateUser

func (a *Authentication) AuthenticateUser(query *LoginUserQuery) error

AuthenticateUser authenticates a user

func (*Authentication) CreateLoginToken

func (a *Authentication) CreateLoginToken(username string) (string, error)

CreateLoginToken generates a signed JWT Token from user to get the token when logged in.

type LDAP

type LDAP struct {
	// contains filtered or unexported fields
}

LDAP is an LDAP entry point allowing authentication with an LDAP server

func NewLDAP

func NewLDAP(server *LDAPConf) *LDAP

NewLDAP create a LDAP entrypoint

func (*LDAP) Login

func (a *LDAP) Login(query *LoginUserQuery) (*LDAPUserInfo, error)

Login log the user in

func (*LDAP) Search

func (a *LDAP) Search(username string) (*LDAPUserInfo, error)

Search search existence of username in LDAP Returns the info about the user if found, error otherwize

type LDAPConf

type LDAPConf struct {
	LdapServer   string
	BaseDN       string
	BindDN       string
	BindPassword string
	SearchFilter string
	Attr         Attributes
}

LDAPConf contains data used to connect to an LDAP directory service

type LDAPUserInfo

type LDAPUserInfo struct {
	DN        string
	Username  string
	FirstName string
	LastName  string
	RealName  string
	Email     string
}

LDAPUserInfo contains LDAP attributes values for a user

type LoginUserQuery

type LoginUserQuery struct {
	Username string
	Password string
}

LoginUserQuery represents connection data

type MyCustomClaims

type MyCustomClaims struct {
	Username string `json:"username"`
	jwt.StandardClaims
}

MyCustomClaims contains data that will be signed in the JWT token

Jump to

Keyboard shortcuts

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