Documentation
¶
Index ¶
- Constants
- func IsAdmin(ctx context.Context) bool
- func ValidateNewPassword(password string) error
- func ValidateUserForm(ctx context.Context, form types.CreateUserForm) error
- func ValidateUserPage(ctx context.Context, query types.GetUserPageInput) error
- type AuthService
- type LoggedInUser
- type PostgresAuthService
- func (a *PostgresAuthService) CreateInitialAdminUser(ctx context.Context) error
- func (a *PostgresAuthService) CreateOrUpdateUser(ctx context.Context, form types.CreateUserForm) (User, error)
- func (a *PostgresAuthService) DeleteUser(ctx *echo.Context, id string) error
- func (a *PostgresAuthService) GenerateLoginToken(ctx context.Context, userID string) (string, error)
- func (a *PostgresAuthService) GetCurrentUser(ctx *echo.Context) (LoggedInUser, error)
- func (a *PostgresAuthService) GetProjectIDsForUser(ctx context.Context, userID string) ([]string, error)
- func (a *PostgresAuthService) GetUserByID(ctx context.Context, id string) (User, error)
- func (a *PostgresAuthService) GetUserByUsername(ctx context.Context, username string) (User, error)
- func (a *PostgresAuthService) GetUserPage(ctx context.Context, query types.GetUserPageInput) ([]User, int64, error)
- func (a *PostgresAuthService) Login(ctx *echo.Context, username, password string) error
- func (a *PostgresAuthService) LoginWithToken(ctx *echo.Context, token string) error
- func (a *PostgresAuthService) Logout(ctx *echo.Context) error
- func (a *PostgresAuthService) ResetPassword(ctx context.Context, userID string, form types.ResetPasswordForm) error
- func (a *PostgresAuthService) UserHasAccessToProject(ctx context.Context, userID, projectID string) (bool, error)
- type PostgresSessionStore
- type Role
- type User
- type UserContext
Constants ¶
View Source
const ( ErrUserNotFound = "User not found" UserAlreadyExists = "User already exists" LoginTokenNotValid = "Login token not valid" PasswordsDoNotMatch = "Passwords do not match" ErrPasswordBlank = "password must contain at least 8 non-space characters" )
View Source
const SVAROG_SESSION = "svarog_session"
Variables ¶
This section is empty.
Functions ¶
func ValidateNewPassword ¶
ValidateNewPassword rejects a password whose meaningful content is shorter than 8 characters. Eight spaces pass a raw length check and can then be used to log in. The stored value is not trimmed: surrounding spaces in an otherwise long password stay significant.
func ValidateUserForm ¶
func ValidateUserForm(ctx context.Context, form types.CreateUserForm) error
func ValidateUserPage ¶
func ValidateUserPage(ctx context.Context, query types.GetUserPageInput) error
Types ¶
type AuthService ¶
type AuthService interface {
Login(ctx *echo.Context, username string, password string) error
LoginWithToken(ctx *echo.Context, token string) error
Logout(ctx *echo.Context) error
ResetPassword(ctx context.Context, userId string, form types.ResetPasswordForm) error
GenerateLoginToken(ctx context.Context, userId string) (string, error)
DeleteUser(ctx *echo.Context, id string) error
GetCurrentUser(ctx *echo.Context) (LoggedInUser, error)
GetUserByID(ctx context.Context, id string) (User, error)
GetUserByUsername(ctx context.Context, username string) (User, error)
GetUserPage(ctx context.Context, query types.GetUserPageInput) ([]User, int64, error)
CreateOrUpdateUser(ctx context.Context, form types.CreateUserForm) (User, error)
UserHasAccessToProject(ctx context.Context, userId, projectId string) (bool, error)
GetProjectIDsForUser(ctx context.Context, userId string) ([]string, error)
}
type LoggedInUser ¶
type PostgresAuthService ¶
type PostgresAuthService struct {
// contains filtered or unexported fields
}
func NewPostgresAuthService ¶
func NewPostgresAuthService(pool *pgxpool.Pool, sessionStore *PostgresSessionStore) *PostgresAuthService
func (*PostgresAuthService) CreateInitialAdminUser ¶
func (a *PostgresAuthService) CreateInitialAdminUser(ctx context.Context) error
func (*PostgresAuthService) CreateOrUpdateUser ¶
func (a *PostgresAuthService) CreateOrUpdateUser(ctx context.Context, form types.CreateUserForm) (User, error)
func (*PostgresAuthService) DeleteUser ¶
func (a *PostgresAuthService) DeleteUser(ctx *echo.Context, id string) error
func (*PostgresAuthService) GenerateLoginToken ¶
func (*PostgresAuthService) GetCurrentUser ¶
func (a *PostgresAuthService) GetCurrentUser(ctx *echo.Context) (LoggedInUser, error)
func (*PostgresAuthService) GetProjectIDsForUser ¶
func (*PostgresAuthService) GetUserByID ¶
func (*PostgresAuthService) GetUserByUsername ¶
func (*PostgresAuthService) GetUserPage ¶
func (a *PostgresAuthService) GetUserPage(ctx context.Context, query types.GetUserPageInput) ([]User, int64, error)
func (*PostgresAuthService) Login ¶
func (a *PostgresAuthService) Login(ctx *echo.Context, username, password string) error
func (*PostgresAuthService) LoginWithToken ¶
func (a *PostgresAuthService) LoginWithToken(ctx *echo.Context, token string) error
func (*PostgresAuthService) ResetPassword ¶
func (a *PostgresAuthService) ResetPassword(ctx context.Context, userID string, form types.ResetPasswordForm) error
func (*PostgresAuthService) UserHasAccessToProject ¶
type PostgresSessionStore ¶
type PostgresSessionStore struct {
// contains filtered or unexported fields
}
func NewPostgresSessionStore ¶
func NewPostgresSessionStore(pool *pgxpool.Pool, secretKey []byte) *PostgresSessionStore
func (*PostgresSessionStore) Save ¶
func (s *PostgresSessionStore) Save(r *http.Request, w http.ResponseWriter, sess *sessions.Session) error
type User ¶
type User struct {
ID uuid.UUID `json:"id"`
FirstName string `json:"firstName"`
LastName string `json:"lastName"`
Username string `json:"username"`
Password string `json:"-"`
Role Role `json:"role"`
NeedsPasswordReset bool `json:"needsPasswordReset"`
ProjectIDs []string `json:"projectIds,omitempty"`
}
type UserContext ¶
type UserContext int
const ( UserKey UserContext = iota IsAdminKey )
func (UserContext) String ¶
func (c UserContext) String() string
Click to show internal directories.
Click to hide internal directories.