Documentation
¶
Index ¶
- Variables
- func DBOutputUserToPBUser(row DBOutputUser) *pbv1beta1.User
- func PreparePostgresDB(db *sql.DB) error
- type CreateSessionRequest
- type CreateUserRequest
- type DBOutputSession
- type DBOutputUser
- type DBOutputUserWithPassword
- type DBSession
- type DBUser
- type DBUserRole
- type LoginInfo
- type Memory
- func (m *Memory) CreateSession(ctx context.Context, req *CreateSessionRequest) error
- func (m *Memory) CreateUser(ctx context.Context, req *CreateUserRequest) error
- func (m *Memory) DeleteUser(ctx context.Context, req *pbv1beta1.DeleteUserRequest) error
- func (m *Memory) GetActiveSession(ctx context.Context, sessionKey string) (*Session, error)
- func (m *Memory) GrantUserRoles(ctx context.Context, req *pbv1beta1.GrantUserRoleRequest) error
- func (m *Memory) ListUserRoles(ctx context.Context, userId string) ([]string, error)
- func (m *Memory) ListUsers(ctx context.Context, req *pbv1beta1.ListUsersRequest) ([]*pbv1beta1.User, error)
- func (m *Memory) Purge(ctx context.Context) error
- func (m *Memory) ReadLoginInfo(ctx context.Context, userID *string, email *string) (*LoginInfo, error)
- func (m *Memory) ReadUser(ctx context.Context, userId string) (*pbv1beta1.User, error)
- func (m *Memory) RemoveSession(ctx context.Context, sessionKey string) error
- func (m *Memory) RevokeUserRoles(ctx context.Context, req *pbv1beta1.RevokeUserRoleRequest) error
- func (m *Memory) SetUserPassword(ctx context.Context, req *SetUserPasswordRequest) error
- func (m *Memory) UpdateUser(ctx context.Context, user *pbv1beta1.User) error
- type MemoryConfig
- type MemoryStoreOpts
- type Postgres
- func (p *Postgres) CreateSession(ctx context.Context, req *CreateSessionRequest) error
- func (p *Postgres) CreateUser(ctx context.Context, req *CreateUserRequest) error
- func (p *Postgres) DeleteUser(ctx context.Context, req *pbv1beta1.DeleteUserRequest) error
- func (p *Postgres) GetActiveSession(ctx context.Context, sessionKey string) (*Session, error)
- func (p *Postgres) GrantUserRoles(ctx context.Context, req *pbv1beta1.GrantUserRoleRequest) error
- func (p *Postgres) ListUserRoles(ctx context.Context, userId string) ([]string, error)
- func (p *Postgres) ListUsers(ctx context.Context, req *pbv1beta1.ListUsersRequest) ([]*pbv1beta1.User, error)
- func (p *Postgres) Purge(ctx context.Context) error
- func (p *Postgres) ReadLoginInfo(ctx context.Context, userID *string, email *string) (*LoginInfo, error)
- func (p *Postgres) ReadUser(ctx context.Context, userId string) (*pbv1beta1.User, error)
- func (p *Postgres) RemoveSession(ctx context.Context, sessionKey string) error
- func (p *Postgres) RevokeUserRoles(ctx context.Context, req *pbv1beta1.RevokeUserRoleRequest) error
- func (p *Postgres) SetUserPassword(ctx context.Context, req *SetUserPasswordRequest) error
- func (p *Postgres) UpdateUser(ctx context.Context, user *pbv1beta1.User) error
- type PostgresConfig
- type PostgresStoreConnectionOpts
- type PostgresStoreOpts
- type Session
- type SetUserPasswordRequest
- type Storer
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrUserAlreadyExistsError = errors.New("a user with this id already exists") ErrUnknownUserError = errors.New("unknown user") ErrIncorrectPasswordError = errors.New("password does not match") ErrNoPasswordConfiguredError = errors.New("no password configured") ErrSessionUnknownOrInactiveError = errors.New("session unknwon or inactive") ErrInvalidConfigurationError = errors.New("invalid configuration") ErrNoHostError = fmt.Errorf("%w: no host given", ErrIncorrectPasswordError) ErrNoDBNameError = fmt.Errorf("%w: no dbname given", ErrInvalidConfigurationError) ErrNoUserError = fmt.Errorf("%w: no user given", ErrInvalidConfigurationError) ErrNoPasswordError = fmt.Errorf("%w: no password given", ErrInvalidConfigurationError) )
Functions ¶
func DBOutputUserToPBUser ¶
func DBOutputUserToPBUser(row DBOutputUser) *pbv1beta1.User
func PreparePostgresDB ¶
Types ¶
type CreateSessionRequest ¶
type CreateUserRequest ¶
type DBOutputSession ¶
type DBOutputSession struct {
DBOutputUser
ID string `db:"session_id"`
ExpiresAt time.Time `db:"expires_at"`
}
type DBOutputUser ¶
type DBOutputUser struct {
DBUser
Roles pq.StringArray `db:"roles"`
}
type DBOutputUserWithPassword ¶
type DBOutputUserWithPassword struct {
DBOutputUser
Password sql.Null[string] `db:"password"`
}
type DBSession ¶
type DBSession struct {
ID string `db:"id"`
UserID string `db:"user_id"`
ExpiresAt time.Time `db:"expires_at"`
}
func CreateSessionRequestToDBSession ¶
func CreateSessionRequestToDBSession(req *CreateSessionRequest) DBSession
type DBUser ¶
type DBUser struct {
ID string `db:"id"`
Email sql.Null[string] `db:"email"`
FullName sql.Null[string] `db:"full_name"`
}
func PBUserToDBUser ¶
type DBUserRole ¶
func GrantUserRoleRequestToDBUserRole ¶
func GrantUserRoleRequestToDBUserRole(req *pbv1beta1.GrantUserRoleRequest) DBUserRole
type LoginInfo ¶
func DBOutputUserWithPasswordToLoginInfo ¶
func DBOutputUserWithPasswordToLoginInfo(row DBOutputUserWithPassword) *LoginInfo
type Memory ¶
type Memory struct {
// contains filtered or unexported fields
}
func NewMemory ¶
func NewMemory(conf MemoryConfig) *Memory
func (*Memory) CreateSession ¶
func (m *Memory) CreateSession(ctx context.Context, req *CreateSessionRequest) error
func (*Memory) CreateUser ¶
func (m *Memory) CreateUser(ctx context.Context, req *CreateUserRequest) error
func (*Memory) DeleteUser ¶
func (*Memory) GetActiveSession ¶
func (*Memory) GrantUserRoles ¶
func (*Memory) ListUserRoles ¶
func (*Memory) ReadLoginInfo ¶
func (*Memory) RemoveSession ¶
func (*Memory) RevokeUserRoles ¶
func (*Memory) SetUserPassword ¶
func (m *Memory) SetUserPassword(ctx context.Context, req *SetUserPasswordRequest) error
type MemoryConfig ¶
type MemoryStoreOpts ¶
type Postgres ¶
type Postgres struct {
// contains filtered or unexported fields
}
func NewPostgres ¶
func NewPostgres(conf PostgresConfig) *Postgres
func (*Postgres) CreateSession ¶
func (p *Postgres) CreateSession(ctx context.Context, req *CreateSessionRequest) error
func (*Postgres) CreateUser ¶
func (p *Postgres) CreateUser(ctx context.Context, req *CreateUserRequest) error
func (*Postgres) DeleteUser ¶
func (*Postgres) GetActiveSession ¶
func (*Postgres) GrantUserRoles ¶
func (*Postgres) ListUserRoles ¶
func (*Postgres) ReadLoginInfo ¶
func (*Postgres) RemoveSession ¶
func (*Postgres) RevokeUserRoles ¶
func (*Postgres) SetUserPassword ¶
func (p *Postgres) SetUserPassword(ctx context.Context, req *SetUserPasswordRequest) error
type PostgresStoreOpts ¶
type PostgresStoreOpts struct {
Logger *logr.Logger
// DB is an existing database handle. Either DB or ConnectionOpts is required
DB *sql.DB
// ConnectionOpts is a set of params to connect to a postgres database. Either DB or ConnectionOpts is required
ConnectionOpts *PostgresStoreConnectionOpts
// NowFunc optionally overrides "now" for the storage layer. Exposed only for unit tests
NowFunc func() time.Time
}
type Session ¶
func DBOutputSessionToSession ¶
func DBOutputSessionToSession(row DBOutputSession) *Session
type SetUserPasswordRequest ¶
type Storer ¶
type Storer interface {
Purge(ctx context.Context) error
CreateUser(ctx context.Context, req *CreateUserRequest) error
ReadUser(ctx context.Context, userId string) (*pbv1beta1.User, error)
ReadLoginInfo(ctx context.Context, userID *string, email *string) (*LoginInfo, error)
ListUsers(ctx context.Context, req *pbv1beta1.ListUsersRequest) ([]*pbv1beta1.User, error)
SetUserPassword(ctx context.Context, req *SetUserPasswordRequest) error
UpdateUser(ctx context.Context, user *pbv1beta1.User) error
DeleteUser(ctx context.Context, req *pbv1beta1.DeleteUserRequest) error
ListUserRoles(ctx context.Context, userId string) ([]string, error)
GrantUserRoles(ctx context.Context, req *pbv1beta1.GrantUserRoleRequest) error
RevokeUserRoles(ctx context.Context, req *pbv1beta1.RevokeUserRoleRequest) error
GetActiveSession(ctx context.Context, sessionKey string) (*Session, error)
CreateSession(ctx context.Context, req *CreateSessionRequest) error
RemoveSession(ctx context.Context, sessionKey string) error
}
func NewMemoryStore ¶
func NewMemoryStore(opts MemoryStoreOpts) (Storer, func(), error)
func NewPostgresStore ¶
func NewPostgresStore(opts PostgresStoreOpts) (Storer, func(), error)
Click to show internal directories.
Click to hide internal directories.