Documentation ¶
Index ¶
- Variables
- func ApplyPermissions(db *gorm.DB, permissions []Permission) ([]string, error)
- func ExportConfig(db *gorm.DB) ([]byte, error)
- func ImportConfig(db *gorm.DB, bs []byte) error
- func ImportPermissions(db *gorm.DB, permissions []Permission) error
- func ImportSources(db *gorm.DB, sources []Source) error
- func NewDB(dbpath string) (*gorm.DB, error)
- func NewToken(db *gorm.DB, userID string, token *Token) (secret string, err error)
- func Run(options Options) error
- type APIKey
- type Config
- type DeleteResponse
- type Destination
- type ErrorResponse
- type Handlers
- func (h *Handlers) APIKeyMiddleware() gin.HandlerFunc
- func (h *Handlers) AdminMiddleware() gin.HandlerFunc
- func (h *Handlers) ApiKeyOrTokenMiddleware() gin.HandlerFunc
- func (h *Handlers) CreateCreds(c *gin.Context)
- func (h *Handlers) CreateDestination(c *gin.Context)
- func (h *Handlers) CreateSource(c *gin.Context)
- func (h *Handlers) CreateUser(c *gin.Context)
- func (h *Handlers) DeleteSource(c *gin.Context)
- func (h *Handlers) DeleteUser(c *gin.Context)
- func (h *Handlers) Healthz(c *gin.Context)
- func (h *Handlers) ListAPIKeys(c *gin.Context)
- func (h *Handlers) ListDestinations(c *gin.Context)
- func (h *Handlers) ListPermissions(c *gin.Context)
- func (h *Handlers) ListSources(c *gin.Context)
- func (h *Handlers) ListUsers(c *gin.Context)
- func (h *Handlers) Login(c *gin.Context)
- func (h *Handlers) Logout(c *gin.Context)
- func (h *Handlers) Signup(c *gin.Context)
- func (h *Handlers) TokenMiddleware() gin.HandlerFunc
- func (h *Handlers) WellKnownJWKs(c *gin.Context)
- type Options
- type Permission
- type Settings
- type Source
- type Token
- type User
Constants ¶
This section is empty.
Variables ¶
View Source
var ( DefaultRoleView = "view" DefaultRoleEdit = "edit" DefaultRoleAdmin = "admin" DefaultInfraSourceKind = "infra" )
Functions ¶
func ApplyPermissions ¶
func ApplyPermissions(db *gorm.DB, permissions []Permission) ([]string, error)
func ExportConfig ¶
GetConfig serializes a config from the database
func ImportPermissions ¶
func ImportPermissions(db *gorm.DB, permissions []Permission) error
Types ¶
type APIKey ¶
type Config ¶
type Config struct { Sources []Source `yaml:"sources"` Permissions []Permission `yaml:"permissions"` }
type DeleteResponse ¶
type DeleteResponse struct {
Deleted bool `json:"deleted"`
}
type Destination ¶
type Destination struct { ID string `gorm:"primaryKey"` Created int64 `json:"created" gorm:"autoCreateTime"` Updated int64 `json:"updated" gorm:"autoUpdateTime"` Kind string `json:"kind"` Name string `json:"name"` KubernetesCA string `json:"kubernetesCA"` KubernetesEndpoint string `json:"kubernetesEndpoint"` }
func (*Destination) AfterCreate ¶
func (d *Destination) AfterCreate(tx *gorm.DB) (err error)
func (*Destination) BeforeCreate ¶
func (r *Destination) BeforeCreate(tx *gorm.DB) (err error)
func (*Destination) BeforeDelete ¶
func (d *Destination) BeforeDelete(tx *gorm.DB) (err error)
type ErrorResponse ¶
type ErrorResponse struct {
Error string `json:"error"`
}
type Handlers ¶
type Handlers struct {
// contains filtered or unexported fields
}
func (*Handlers) APIKeyMiddleware ¶
func (h *Handlers) APIKeyMiddleware() gin.HandlerFunc
func (*Handlers) AdminMiddleware ¶
func (h *Handlers) AdminMiddleware() gin.HandlerFunc
func (*Handlers) ApiKeyOrTokenMiddleware ¶
func (h *Handlers) ApiKeyOrTokenMiddleware() gin.HandlerFunc
func (*Handlers) CreateCreds ¶
func (*Handlers) CreateDestination ¶
func (*Handlers) CreateSource ¶
func (*Handlers) CreateUser ¶
func (*Handlers) DeleteSource ¶
func (*Handlers) DeleteUser ¶
func (*Handlers) ListAPIKeys ¶
func (*Handlers) ListDestinations ¶
func (*Handlers) ListPermissions ¶
func (*Handlers) ListSources ¶
func (*Handlers) TokenMiddleware ¶
func (h *Handlers) TokenMiddleware() gin.HandlerFunc
func (*Handlers) WellKnownJWKs ¶
type Permission ¶
type Permission struct { ID string `gorm:"primaryKey"` Created int64 `json:"created" yaml:"-" gorm:"autoCreateTime"` Updated int64 `json:"updated" yaml:"-" gorm:"autoUpdateTime"` UserEmail string `json:"-" yaml:"user"` User User `json:"user,omitempty" yaml:"-" gorm:"foreignKey:UserEmail;references:Email"` DestinationName string `json:"-" yaml:"destination"` Destination Destination `json:"destination,omitempty" yaml:"-" gorm:"foreignKey:DestinationName;references:Name"` Role string `json:"role" yaml:"role"` FromConfig bool `json:"-" yaml:"-"` }
func (*Permission) BeforeCreate ¶
func (g *Permission) BeforeCreate(tx *gorm.DB) (err error)
type Settings ¶
type Source ¶
type Source struct { ID string `gorm:"primaryKey"` Created int64 `json:"created" yaml:"-" gorm:"autoCreateTime"` Updated int64 `json:"updated" yaml:"-" gorm:"autoUpdateTime"` Kind string `json:"kind" yaml:"kind"` Domain string `json:"domain" yaml:"domain,omitempty" gorm:"unique"` ClientID string `json:"clientID" yaml:"clientID,omitempty"` ClientSecret string `json:"-" yaml:"clientSecret,omitempty"` ApiToken string `json:"-" yaml:"apiToken,omitempty"` Users []User `json:"-" yaml:"-" gorm:"many2many:users_sources"` }
func (*Source) CreateUser ¶
CreateUser will create a user and associate them with the source If the user already exists, they will not be created, instead an association will be added instead
func (*Source) DeleteUser ¶
Delete will delete a user's association with a source If this is their only source, then the user will be deleted entirely TODO (jmorganca): wrap this in a transaction or at least find out why there seems to cause a bug when used in a nested transaction
type Token ¶
type Token struct { ID string `gorm:"primaryKey"` Created int64 `json:"created" gorm:"autoCreateTime"` Updated int64 `json:"updated" gorm:"autoUpdateTime"` Expires int64 `json:"expires"` Secret []byte `json:"-" gorm:"autoCreateTime"` UserID string User User `json:"-"` }
func (*Token) CheckSecret ¶
type User ¶
type User struct { ID string `gorm:"primaryKey"` Created int64 `json:"created" gorm:"autoCreateTime"` Updated int64 `json:"updated" gorm:"autoUpdateTime"` Email string `json:"email" gorm:"unique"` Password []byte `json:"-"` Admin bool `json:"admin"` Sources []Source `json:"sources,omitempty" gorm:"many2many:users_sources"` Permissions []Permission `json:"permissions,omitempty" gorm:"foreignKey:UserEmail;references:Email"` }
Click to show internal directories.
Click to hide internal directories.