Documentation
¶
Index ¶
- Constants
- Variables
- func IsAdmin(ctx context.Context) bool
- func ValidateNewPassword(password string) error
- func ValidateUserInput(input UserInput) error
- type LoggedInUser
- type PageQuery
- type PostgresAuthService
- func (a *PostgresAuthService) CreateInitialAdminUser(ctx context.Context) error
- func (a *PostgresAuthService) CreateUser(ctx context.Context, input UserInput) (User, string, error)
- func (a *PostgresAuthService) DeleteUser(ctx context.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 PageQuery) ([]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, password string) error
- func (a *PostgresAuthService) UpdateUser(ctx context.Context, id uuid.UUID, input UserInput) (User, error)
- func (a *PostgresAuthService) UserHasAccessToProject(ctx context.Context, userID, projectID string) (bool, error)
- type PostgresSessionStore
- type Role
- type User
- type UserContext
- type UserInput
Constants ¶
View Source
const ( UsernameMaxLength = 255 UserProfileNameMaxLength = 255 UserSearchMaxLength = 1024 )
View Source
const SVAROG_SESSION = "svarog_session"
Variables ¶
View Source
var ( ErrUserNotFound = errors.New("User not found") ErrUserExists = errors.New("User already exists") ErrLoginTokenInvalid = errors.New("Login token not valid") ErrPasswordBlank = errors.New("password must contain at least 8 non-space characters") ErrPasswordTooLong = errors.New("Password must contain between 8 and 72 bytes") ErrInvalidPassword = errors.New("Invalid password") ErrProjectSelectionMissing = errors.New("project selection missing") )
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 ValidateUserInput ¶ added in v0.0.11
Types ¶
type LoggedInUser ¶
type PageQuery ¶ added in v0.0.11
type PageQuery struct {
// contains filtered or unexported fields
}
PageQuery is constructed by NewPageQuery. Its zero value is the default first page.
func NewPageQuery ¶ added in v0.0.11
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) CreateUser ¶ added in v0.0.11
func (*PostgresAuthService) DeleteUser ¶
func (a *PostgresAuthService) DeleteUser(ctx context.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 (*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 (*PostgresAuthService) UpdateUser ¶ added in v0.0.11
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.