Documentation ¶
Index ¶
- Variables
- func GetAuthTokenFromHeader(r *http.Request) (string, error)
- type Manager
- func (m *Manager) CheckUserPassword(email string, password string) (matches bool, err error)
- func (m *Manager) ConfirmUserAccount(id string, secret string, user types.UserSpec) (tokenString string, err error)
- func (m *Manager) Create(user types.UserSpec, allowEmptyPassword bool) (userInserted types.UserSpec, err error)
- func (m *Manager) DeleteByID(id string) (err error)
- func (m *Manager) GenerateJWTauthToken(id string, authNonce string, expiresIn time.Duration) (tokenString string, err error)
- func (m *Manager) GenerateNewAuthNonce(id string) (err error)
- func (m *Manager) Get(userSelect types.UserSpec, includePassword bool) (user types.UserSpec, err error)
- func (m *Manager) GetByEmail(email string, includePassword bool) (user types.UserSpec, err error)
- func (m *Manager) GetByID(id string, includePassword bool) (user types.UserSpec, err error)
- func (m *Manager) GetIDFromJWT(r *http.Request) (id string, err error)
- func (m *Manager) GetProfile(r *http.Request) (user types.UserSpec, err error)
- func (m *Manager) InvalidateAllAuthTokens(id string) (err error)
- func (m *Manager) List(includePassword bool, selectors types.UserSelector) (users []types.UserSpec, err error)
- func (m *Manager) Patch(id string, userAccount types.UserSpec) (userAccountPatched types.UserSpec, err error)
- func (m *Manager) PatchAsAdmin(id string, userAccount types.UserSpec) (userAccountPatched types.UserSpec, err error)
- func (m *Manager) PatchDisabledAsAdmin(id string, disabled bool) (userAccount types.UserSpec, err error)
- func (m *Manager) Update(id string, userAccount types.UserSpec) (userAccountUpdated types.UserSpec, err error)
- func (m *Manager) UpdateAsAdmin(id string, userAccount types.UserSpec) (userAccountUpdated types.UserSpec, err error)
- func (m *Manager) UserAccountExists(id string) (exists bool, err error)
- func (m *Manager) UserCreationSecrets() *userCreationSecretManager
- func (m *Manager) Validate(user types.UserSpec, allowEmptyPassword bool) (valid bool, err error)
- func (m *Manager) ValidateJWTauthToken(r *http.Request) (valid bool, tokenClaims *types.JWTclaim, err error)
Constants ¶
This section is empty.
Variables ¶
var ( ErrAuthInvalid = fmt.Errorf("Authentication has been invalidated, please log in again") ErrEmailAddressAlreadyUsed = fmt.Errorf("Email address is unable to be used") ErrFailedToCreateUserCreationSecret = fmt.Errorf("Failed to create a user creation secret") ErrFailedToFindAccount = fmt.Errorf("Failed to find user account") ErrFailedToFindUser = fmt.Errorf("Failed to find user") ErrFailedToListUserCreationSecrets = fmt.Errorf("Failed to list user creation secrets") ErrFailedToPatchProfile = fmt.Errorf("Failed to patch profile") ErrFailedToPatchUserAccount = fmt.Errorf("Failed to patch user account") ErrFailedToUpdateUserAccount = fmt.Errorf("Failed to update user account") ErrFailedToUpdateProfile = fmt.Errorf("Failed to update profile") ErrInvalidEmailAddress = fmt.Errorf("Invalid email address") ErrNoGroupsProvided = fmt.Errorf("No groups provided; please select at least one group") ErrUserAccountConfirmPasswordRequiredForRegistration = fmt.Errorf("Unable to confirm account, a password must be provided to complete registration") ErrUserAccountConfirmSecretDoesNotMatch = fmt.Errorf("Unable to confirm account, as the secret doesn't match") ErrFailedToFindSystemAuthSecret = fmt.Errorf("Unable to find FlatTrack system auth secret. Please contact system administrators or support") ErrFailedToFindAccountConfirmSecret = fmt.Errorf("Unable to find account confirmation secret") ErrFailedToFindAuthToken = fmt.Errorf("Unable to find authorization token") ErrFailedToFindAuthTokenAccountID = fmt.Errorf("Unable to find the user account which the authentication token belongs to") ErrFailedToFindUserAccount = fmt.Errorf("Unable to find user account") ErrFailedToReadJWTClaims = fmt.Errorf("Unable to read JWT claims") ErrAuthTokenExpired = fmt.Errorf("Unable to use existing login token as it is invalid") ErrAuthTokenFailed = fmt.Errorf("Unable to use login token provided, please log in again") ErrUserAccountNotFound = fmt.Errorf("Failed to find user account") ErrUserAccountInvalidBirthday = fmt.Errorf("Unable to use the provided birthday, your birthday year must not be within the last 15 years") ErrUserAccountInvalidEmail = fmt.Errorf("Unable to use the provided email, as it is either empty or not valid") ErrUserAccountInvalidGroup = fmt.Errorf("Unable to use the provided group as it is invalid") ErrUserAccountInvalidName = fmt.Errorf("Unable to use the provided name, as it is either empty or too long or too short") ErrUserAccountInvalidPassword = fmt.Errorf("Unable to use the provided password, as it is either empty of invalid") ErrUserAccountInvalidPhoneNumber = fmt.Errorf("Unable to use the provided phone number") ErrUserAccountMustBeInFlatmemberGroup = fmt.Errorf("User account must be in the flatmember group") ErrUserAccountIsDisabled = fmt.Errorf("Your user account is disabled") ErrAuthorizationHeaderNotFound = fmt.Errorf("Unable to find authorization token (header doesn't exist)") ErrUserAccountCreationSecretNotFound = fmt.Errorf("Failed to find user account creation secret") )
Functions ¶
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
UserManager manages user accounts
func NewManager ¶
func (*Manager) CheckUserPassword ¶
CheckUserPassword ... given an email and password, find the user account with the email, return if the password matches
func (*Manager) ConfirmUserAccount ¶
func (m *Manager) ConfirmUserAccount(id string, secret string, user types.UserSpec) (tokenString string, err error)
ConfirmUserAccount ... confirms the user account
func (*Manager) Create ¶
func (m *Manager) Create(user types.UserSpec, allowEmptyPassword bool) (userInserted types.UserSpec, err error)
Create ... given a UserSpec, create a user
func (*Manager) DeleteByID ¶
DeleteByID ... given an id, remove the user account from all the groups and then delete a user account
func (*Manager) GenerateJWTauthToken ¶
func (m *Manager) GenerateJWTauthToken(id string, authNonce string, expiresIn time.Duration) (tokenString string, err error)
GenerateJWTauthToken ... given an email, return a usable JWT token
func (*Manager) GenerateNewAuthNonce ¶
GenerateNewAuthNonce ... given a user account id, generates a new auth nonce to reset all logins and invalidate all issued JWTs
func (*Manager) Get ¶
func (m *Manager) Get(userSelect types.UserSpec, includePassword bool) (user types.UserSpec, err error)
Get ... given a UserSpec and an ID or Email, return a user from the database
func (*Manager) GetByEmail ¶
GetByEmail ... given a email, return a UserSpec
func (*Manager) GetIDFromJWT ¶
GetIDFromJWT ... return the userID in a JWT from a header in a HTTP request TODO move into internal/httpserver/common.go
func (*Manager) GetProfile ¶
GetProfile ... return user from ID in JWT from HTTP request TODO move into internal/httpserver/common.go
func (*Manager) InvalidateAllAuthTokens ¶
InvalidateAllAuthTokens ... updates the authNonce to invalidate auth tokens
func (*Manager) List ¶
func (m *Manager) List(includePassword bool, selectors types.UserSelector) (users []types.UserSpec, err error)
List ... return all users in the database
func (*Manager) Patch ¶
func (m *Manager) Patch(id string, userAccount types.UserSpec) (userAccountPatched types.UserSpec, err error)
Patch ... patches the profile of a user account
func (*Manager) PatchAsAdmin ¶
func (m *Manager) PatchAsAdmin(id string, userAccount types.UserSpec) (userAccountPatched types.UserSpec, err error)
PatchAsAdmin ... patches a profile with all fields
func (*Manager) PatchDisabledAsAdmin ¶
func (m *Manager) PatchDisabledAsAdmin(id string, disabled bool) (userAccount types.UserSpec, err error)
PatchDisabledAsAdmin ... patches is user account to be disabled
func (*Manager) Update ¶
func (m *Manager) Update(id string, userAccount types.UserSpec) (userAccountUpdated types.UserSpec, err error)
Update ... updates the profile of a user account
func (*Manager) UpdateAsAdmin ¶
func (m *Manager) UpdateAsAdmin(id string, userAccount types.UserSpec) (userAccountUpdated types.UserSpec, err error)
UpdateAsAdmin ... updates all fields of a profile
func (*Manager) UserAccountExists ¶
UserAccountExists ... returns bool if user account exists
func (*Manager) UserCreationSecrets ¶
func (m *Manager) UserCreationSecrets() *userCreationSecretManager