Documentation ¶
Index ¶
- Variables
- func Login(m models.AuthModel) (*models.User, error)
- func OnBoardGroup(userGroup *models.UserGroup, altGroupName string) error
- func OnBoardUser(user *models.User) error
- func PostAuthenticate(u *models.User) error
- func Register(name string, h AuthenticateHelper)
- func SearchAndOnBoardGroup(groupKey, altGroupName string) (int, error)
- func SearchAndOnBoardUser(username string) (int, error)
- func SearchGroup(groupKey string) (*models.UserGroup, error)
- func SearchUser(username string) (*models.User, error)
- type AuthenticateHelper
- type DefaultAuthenticateHelper
- func (d *DefaultAuthenticateHelper) Authenticate(m models.AuthModel) (*models.User, error)
- func (d *DefaultAuthenticateHelper) OnBoardGroup(u *models.UserGroup, altGroupName string) error
- func (d *DefaultAuthenticateHelper) OnBoardUser(u *models.User) error
- func (d *DefaultAuthenticateHelper) PostAuthenticate(u *models.User) error
- func (d *DefaultAuthenticateHelper) SearchGroup(groupKey string) (*models.UserGroup, error)
- func (d *DefaultAuthenticateHelper) SearchUser(username string) (*models.User, error)
- type ErrAuth
- type UserLock
Constants ¶
This section is empty.
Variables ¶
var ErrorGroupNotExist = errors.New("Group does not exist")
ErrorGroupNotExist ...
var ErrorUserNotExist = errors.New("User does not exist")
ErrorUserNotExist ...
Functions ¶
func OnBoardGroup ¶
OnBoardGroup - Create a user group in harbor db, if altGroupName is not empty, take the altGroupName as groupName in harbor DB
func OnBoardUser ¶
OnBoardUser will check if a user exists in user table, if not insert the user and put the id in the pointer of user model, if it does exist, return the user's profile.
func Register ¶
func Register(name string, h AuthenticateHelper)
Register add different authenticators to registry map.
func SearchAndOnBoardGroup ¶
SearchAndOnBoardGroup ... if altGroupName is not empty, take the altGroupName as groupName in harbor DB
func SearchAndOnBoardUser ¶
SearchAndOnBoardUser ... Search user and OnBoard user, if user exist, return the ID of current user.
func SearchGroup ¶
SearchGroup -- Search group in authenticator, groupKey is the unique attribute of group in authenticator, for LDAP, the key is group DN
Types ¶
type AuthenticateHelper ¶
type AuthenticateHelper interface { // Authenticate authenticate the user based on data in m. Only when the error returned is an instance // of ErrAuth, it will be considered a bad credentials, other errors will be treated as server side error. Authenticate(m models.AuthModel) (*models.User, error) // OnBoardUser will check if a user exists in user table, if not insert the user and // put the id in the pointer of user model, if it does exist, fill in the user model based // on the data record of the user OnBoardUser(u *models.User) error // Create a group in harbor DB, if altGroupName is not empty, take the altGroupName as groupName in harbor DB. OnBoardGroup(g *models.UserGroup, altGroupName string) error // Get user information from account repository SearchUser(username string) (*models.User, error) // Search a group based on specific authentication SearchGroup(groupDN string) (*models.UserGroup, error) // Update user information after authenticate, such as OnBoard or sync info etc PostAuthenticate(u *models.User) error }
AuthenticateHelper provides interface for user management in different auth modes.
type DefaultAuthenticateHelper ¶
type DefaultAuthenticateHelper struct { }
DefaultAuthenticateHelper - default AuthenticateHelper implementation
func (*DefaultAuthenticateHelper) Authenticate ¶
Authenticate ...
func (*DefaultAuthenticateHelper) OnBoardGroup ¶
func (d *DefaultAuthenticateHelper) OnBoardGroup(u *models.UserGroup, altGroupName string) error
OnBoardGroup - OnBoardGroup, it will set the ID of the user group, if altGroupName is not empty, take the altGroupName as groupName in harbor DB.
func (*DefaultAuthenticateHelper) OnBoardUser ¶
func (d *DefaultAuthenticateHelper) OnBoardUser(u *models.User) error
OnBoardUser will check if a user exists in user table, if not insert the user and put the id in the pointer of user model, if it does exist, fill in the user model based on the data record of the user
func (*DefaultAuthenticateHelper) PostAuthenticate ¶
func (d *DefaultAuthenticateHelper) PostAuthenticate(u *models.User) error
PostAuthenticate - Update user information after authenticate, such as OnBoard or sync info etc
func (*DefaultAuthenticateHelper) SearchGroup ¶
func (d *DefaultAuthenticateHelper) SearchGroup(groupKey string) (*models.UserGroup, error)
SearchGroup - Search ldap group by group key, groupKey is the unique attribute of group in authenticator, for LDAP, the key is group DN
func (*DefaultAuthenticateHelper) SearchUser ¶
func (d *DefaultAuthenticateHelper) SearchUser(username string) (*models.User, error)
SearchUser - Get user information from account repository
type ErrAuth ¶
type ErrAuth struct {
// contains filtered or unexported fields
}
ErrAuth is the type of error to indicate a failed authentication due to user's error.
type UserLock ¶
type UserLock struct {
// contains filtered or unexported fields
}
UserLock maintains a lock to block user from logging in within a short period of time.