Documentation ¶
Overview ¶
Package for working with corpora with private login required.
Index ¶
- func IsAuthorized(user UserInfo, permission string) bool
- func NewSessionId() string
- func SendPasswordReset(toUser UserInfo, token string, c config.WebAppConfig) error
- type Authenticator
- type AuthenticatorDBImpl
- func (a *AuthenticatorDBImpl) ChangePassword(ctx context.Context, userInfo UserInfo, oldPassword, password string) ChangePasswordResult
- func (a *AuthenticatorDBImpl) CheckLogin(ctx context.Context, username, password string) ([]UserInfo, error)
- func (a *AuthenticatorDBImpl) CheckSession(ctx context.Context, sessionid string) SessionInfo
- func (a *AuthenticatorDBImpl) GetUser(ctx context.Context, username string) ([]UserInfo, error)
- func (a *AuthenticatorDBImpl) Logout(ctx context.Context, sessionid string)
- func (a *AuthenticatorDBImpl) RequestPasswordReset(ctx context.Context, email string) RequestResetResult
- func (a *AuthenticatorDBImpl) ResetPassword(ctx context.Context, token, password string) bool
- func (a *AuthenticatorDBImpl) SaveSession(ctx context.Context, sessionid string, userInfo UserInfo, authenticated int) SessionInfo
- func (a *AuthenticatorDBImpl) UpdateSession(ctx context.Context, sessionid string, userInfo UserInfo, authenticated int) SessionInfo
- type ChangePasswordResult
- type RequestResetRecord
- type RequestResetResult
- type SessionInfo
- type SessionRecord
- type UserInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsAuthorized ¶
Generate a new session id after login
func SendPasswordReset ¶ added in v0.0.30
func SendPasswordReset(toUser UserInfo, token string, c config.WebAppConfig) error
Types ¶
type Authenticator ¶ added in v0.0.15
type Authenticator interface { ChangePassword(ctx context.Context, userInfo UserInfo, oldPassword, password string) ChangePasswordResult CheckLogin(ctx context.Context, username, password string) ([]UserInfo, error) CheckSession(ctx context.Context, sessionid string) SessionInfo GetUser(ctx context.Context, username string) ([]UserInfo, error) Logout(ctx context.Context, sessionid string) RequestPasswordReset(ctx context.Context, email string) RequestResetResult ResetPassword(ctx context.Context, token, password string) bool SaveSession(ctx context.Context, sessionid string, userInfo UserInfo, authenticated int) SessionInfo UpdateSession(ctx context.Context, sessionid string, userInfo UserInfo, authenticated int) SessionInfo }
func NewAuthenticator ¶ added in v0.0.17
func NewAuthenticator(client fsClient, corpus string) Authenticator
Create a new Authenticator with a Firestore client
func NewAuthenticatorDB ¶ added in v0.0.154
func NewAuthenticatorDB(ctx context.Context) (Authenticator, error)
NewAuthenticator creates but does not initialize an Authenticator object.
Params:
isProtected - set this to true if only the site is password protected
type AuthenticatorDBImpl ¶ added in v0.0.154
type AuthenticatorDBImpl struct {
// contains filtered or unexported fields
}
Authenticator holds stateful items needed for user authentication.
func (*AuthenticatorDBImpl) ChangePassword ¶ added in v0.0.154
func (a *AuthenticatorDBImpl) ChangePassword(ctx context.Context, userInfo UserInfo, oldPassword, password string) ChangePasswordResult
ChangePassword enables the user to change passwords.
func (*AuthenticatorDBImpl) CheckLogin ¶ added in v0.0.154
func (a *AuthenticatorDBImpl) CheckLogin(ctx context.Context, username, password string) ([]UserInfo, error)
CheckLogin checks the password when the user logs in.
func (*AuthenticatorDBImpl) CheckSession ¶ added in v0.0.154
func (a *AuthenticatorDBImpl) CheckSession(ctx context.Context, sessionid string) SessionInfo
CheckSession checks the session when the user requests a page.
func (*AuthenticatorDBImpl) Logout ¶ added in v0.0.154
func (a *AuthenticatorDBImpl) Logout(ctx context.Context, sessionid string)
Logout logs the user out of the current session.
func (*AuthenticatorDBImpl) RequestPasswordReset ¶ added in v0.0.154
func (a *AuthenticatorDBImpl) RequestPasswordReset(ctx context.Context, email string) RequestResetResult
RequestPasswordReset requests a password reset, to be sent by email.
func (*AuthenticatorDBImpl) ResetPassword ¶ added in v0.0.154
func (a *AuthenticatorDBImpl) ResetPassword(ctx context.Context, token, password string) bool
ResetPassword resets a password.
func (*AuthenticatorDBImpl) SaveSession ¶ added in v0.0.154
func (a *AuthenticatorDBImpl) SaveSession(ctx context.Context, sessionid string, userInfo UserInfo, authenticated int) SessionInfo
SaveSession saves an authenticated session to the database
func (*AuthenticatorDBImpl) UpdateSession ¶ added in v0.0.154
func (a *AuthenticatorDBImpl) UpdateSession(ctx context.Context, sessionid string, userInfo UserInfo, authenticated int) SessionInfo
UpdateSession logs a user in when they already have an unauthenticated session.
type ChangePasswordResult ¶
func OldPasswordDoesNotMatch ¶
func OldPasswordDoesNotMatch() ChangePasswordResult
Old password does not match
type RequestResetRecord ¶ added in v0.0.154
type RequestResetResult ¶
type SessionInfo ¶
func InvalidSession ¶
func InvalidSession() SessionInfo
InvalidSession creates an empty session struct.