Documentation
¶
Index ¶
Constants ¶
View Source
const ( SourceConfig = "config" SourceAdmin = "admin" SourceGitHub = "github" )
User source constants.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GitHubOrgMapping ¶
type GitHubOrgMapping struct {
ID uint `gorm:"primaryKey" json:"id"`
Org string `gorm:"uniqueIndex;not null" json:"org"`
Role string `gorm:"not null" json:"role"`
}
GitHubOrgMapping maps a GitHub organization to a role.
type GitHubUserMapping ¶
type GitHubUserMapping struct {
ID uint `gorm:"primaryKey" json:"id"`
Username string `gorm:"uniqueIndex;not null" json:"username"`
Role string `gorm:"not null" json:"role"`
}
GitHubUserMapping maps a GitHub username to a role.
type Session ¶
type Session struct {
ID uint `gorm:"primaryKey" json:"id"`
Token string `gorm:"uniqueIndex;not null" json:"-"`
UserID uint `gorm:"not null" json:"user_id"`
ExpiresAt time.Time `gorm:"not null" json:"expires_at"`
CreatedAt time.Time `json:"created_at"`
}
Session represents an active user session.
type Store ¶
type Store interface {
Start(ctx context.Context) error
Stop() error
// User CRUD.
GetUserByID(ctx context.Context, id uint) (*User, error)
GetUserByUsername(ctx context.Context, username string) (*User, error)
ListUsers(ctx context.Context) ([]User, error)
CreateUser(ctx context.Context, user *User) error
UpdateUser(ctx context.Context, user *User) error
DeleteUser(ctx context.Context, id uint) error
// Session CRUD.
CreateSession(ctx context.Context, session *Session) error
GetSessionByToken(ctx context.Context, token string) (*Session, error)
DeleteSession(ctx context.Context, token string) error
DeleteExpiredSessions(ctx context.Context) error
// GitHub org mapping CRUD.
ListGitHubOrgMappings(ctx context.Context) ([]GitHubOrgMapping, error)
UpsertGitHubOrgMapping(ctx context.Context, m *GitHubOrgMapping) error
DeleteGitHubOrgMapping(ctx context.Context, id uint) error
// GitHub user mapping CRUD.
ListGitHubUserMappings(ctx context.Context) ([]GitHubUserMapping, error)
UpsertGitHubUserMapping(ctx context.Context, m *GitHubUserMapping) error
DeleteGitHubUserMapping(ctx context.Context, id uint) error
// Seeding from config.
SeedUsers(ctx context.Context, users []config.BasicAuthUser) error
SeedGitHubMappings(
ctx context.Context,
orgMappings map[string]string,
userMappings map[string]string,
) error
}
Store provides persistence for API resources.
func NewStore ¶
func NewStore( log logrus.FieldLogger, cfg *config.APIDatabaseConfig, ) Store
NewStore creates a new Store backed by the configured database driver.
type User ¶
type User struct {
ID uint `gorm:"primaryKey" json:"id"`
Username string `gorm:"uniqueIndex;not null" json:"username"`
PasswordHash string `gorm:"not null" json:"-"`
Role string `gorm:"not null" json:"role"`
Source string `gorm:"not null" json:"source"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
User represents an authenticated user in the system.
Click to show internal directories.
Click to hide internal directories.