models

package
v0.0.0-...-dae269f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 5, 2023 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package contains all database models

Index

Constants

View Source
const (
	// Content Security Policy used by the internal server
	ContentSecurityPolicyNothing = "base-uri 'self'; default-src 'none';"

	// Content Security policy used by the distillery admin server
	ContentSecurityPolicyDistilery = "" /* 137-byte string literal not displayed */
)
View Source
const DefaultPHPVersion = "8.1"

DefaultPHPVersion is the default php version

View Source
const ExportTable = "snapshot"

ExportTable is the name of the table the Export model is stored in. NOTE(twiesing): It is called snapshot for legacy reasons

View Source
const GrantTable = "grant"

GrantTable is the name of the table the 'Grant' model is stored in.

View Source
const InstanceTable = "distillery"

InstanceTable is the name of the table the 'Instance' model is stored in.

View Source
const KeysTable = "keys"

KeysTable is the name of the table the Keys model is stored in.

View Source
const LockTable = "locks"

LockTable is the name of the table the 'Metadatum' model is stored in.

View Source
const MetadataTable = "metadatum"

MetadataTable is the name of the table the 'Metadatum' model is stored in.

View Source
const TokensTable = "tokens"

TokensTable is the name of the table the 'Token' model is stored in.

View Source
const UserTable = "users"

UserTable is the name of the table the [`User`] model is stored in.

Variables

This section is empty.

Functions

func ContentSecurityPolicyExamples

func ContentSecurityPolicyExamples() []string

func KnownPHPVersions

func KnownPHPVersions() []string

KnownPHPVersions returns a slice of php versions.

Types

type Export

type Export struct {
	Pk uint `gorm:"column:pk;primaryKey"`

	Slug    string    `gorm:"column:slug"`    // slug of instance
	Created time.Time `gorm:"column:created"` // time the backup was created

	Path   string `gorm:"column:path;not null"`   // path the export is stored at
	Packed bool   `gorm:"column:packed;not null"` // was the export packed, or was it staging only?
}

Export represents an entry in the export log

type Grant

type Grant struct {
	Pk uint `gorm:"column:pk;primaryKey"`

	User string `gorm:"column:user;not null;index:user_slug,unique"`            // (distillery) username
	Slug string `gorm:"column:slug;not null;index:user_slug;index:drupal_slug"` // (distillery) instance slug

	DrupalUsername  string `gorm:"column:drupal_user;not null;index:drupal_slug,unique"` // drupal username
	DrupalAdminRole bool   `gorm:"column:admin;not null"`                                // drupal admin rights
}

Grant represents an access grant to a specific user

type Instance

type Instance struct {

	// Primary key for the instance
	Pk uint `gorm:"column:pk;primaryKey"`

	// time the instance was created
	Created time.Time `gorm:"column:created;autoCreateTime"`

	// slug of the system
	Slug string `gorm:"column:slug;not null;unique"`

	// email address of the system owner (if any)
	OwnerEmail string `gorm:"column:owner_email;type:varchar(320)"`

	// should we automatically enable updates for the system?
	AutoBlindUpdateEnabled SQLBit1 `gorm:"column:auto_blind_update_enabled;default:1"`

	// The filesystem path the system can be found under
	FilesystemBase string `gorm:"column:filesystem_base;not null"`

	// information about the system being used
	System `gorm:"embed"`

	// SQL Database credentials for the system
	SqlDatabase string `gorm:"column:sql_database;not null"`
	SqlUsername string `gorm:"column:sql_user;not null"`
	SqlPassword string `gorm:"column:sql_password;not null"`

	// GraphDB Repository
	GraphDBRepository string `gorm:"column:graphdb_repository;not null"`
	GraphDBUsername   string `gorm:"column:graphdb_user;not null"`
	GraphDBPassword   string `gorm:"column:graphdb_password;not null"`
}

Instance is a WissKI Instance stored inside the sql database.

It does not represent a running instance; it does not perform any validation.

func (Instance) IsBlindUpdateEnabled

func (i Instance) IsBlindUpdateEnabled() bool

type Keys

type Keys struct {
	Pk uint `gorm:"column:pk;primaryKey"`

	User string `gorm:"column:user;not null"` // username of the ssh key

	Signature []byte `gorm:"column:signature;not null"` // signature of the ssh key
	Comment   string `gorm:"column:comment"`
}

Keys represents a distillery ssh key

func (*Keys) PublicKey

func (keys *Keys) PublicKey() ssh.PublicKey

PublicKey returns the public key corresponding to this keys. If the key cannot be parsed, returns nil.

func (*Keys) SetPublicKey

func (keys *Keys) SetPublicKey(key ssh.PublicKey)

SetPublicKey stores a specific public key in this key

func (*Keys) SignatureString

func (keys *Keys) SignatureString() string

type Lock

type Lock struct {
	Pk uint `gorm:"column:pk;primaryKey"`

	Slug string `gorm:"column:slug;not null"` // slug of instance
}

Lock represents a log on WissKI Instances

type Metadatum

type Metadatum struct {
	Pk uint `gorm:"column:pk;primaryKey"`

	Key   string `gorm:"column:key;not null"` // key for the value, see the keys below
	Slug  string `gorm:"column:slug"`         // optional slug of instance
	Value []byte `gorm:"column:value"`        // serialized json value of the data
}

Metadatum represents a metadatum for a single model

type SQLBit1

type SQLBit1 bool

SQLBit1 implements a boolean as a BIT(1)

func (*SQLBit1) Scan

func (sb *SQLBit1) Scan(src interface{}) error

func (SQLBit1) Value

func (sb SQLBit1) Value() (driver.Value, error)

type System

type System struct {
	// NOTE(twiesing): Any changes here should be reflected in instance_{provision,rebuild}.html and remote/api.ts.
	PHP                string `gorm:"column:php;not null"`           // php version to use
	OpCacheDevelopment bool   `gorm:"column:opcache_devel;not null"` // opcache development

	ContentSecurityPolicy string `gorm:"column:csp;not null"` // content security policy for the system
}

System represents system information. It is embedded into the instances struct by gorm.

func (System) GetDockerBaseImage

func (system System) GetDockerBaseImage() string

GetDockerBaseImage returns the docker base image used by the given system.

func (System) OpCacheMode

func (system System) OpCacheMode() string

OpCacheMode returns the name of the `opcache-*.ini` configuration being included in the docker image

type Token

type Token struct {
	Pk uint `gorm:"column:pk;primaryKey"`

	Token   string `json:"-" gorm:"column:token;unique:true;not null"` // token used by the actual api (shown only once)
	TokenID string `gorm:"column:id;unique:true;not null"`             // token id (displayed to user, used for finding it)

	User string `gorm:"column:user;not null"` // (distillery) username

	Description string `gorm:"column:description"`

	AllScopes bool   `gorm:"column:all;not null"`
	Scopes    []byte `gorm:"column:scopes;not null"` // comma-seperated list of scopes
}

Token represents an access token for a specific user

func (*Token) GetScopes

func (token *Token) GetScopes() (scopes []string)

GetScopes returns the scopes associated with this Token.

If this token implicitly has all scopes, returns nil. If this token has no scopes, returns an empty string slice.

func (*Token) SetScopes

func (token *Token) SetScopes(scopes []string)

SetScopes sets the scopes associated to this token to scopes. It scopes is nil, sets the token to permit all scopes.

type User

type User struct {
	Pk uint `gorm:"column:pk;primaryKey"`

	User string `gorm:"column:user;not null;unique"` // name of the user

	PasswordHash []byte `gorm:"column:password" json:"-"`    // password of the user, hashed
	TOTPEnabled  *bool  `gorm:"column:totpenabled" json:"-"` // is totp enabled for the user
	TOTPURL      string `gorm:"column:totp" json:"-"`        // the totp of the user

	Enabled *bool `gorm:"enabled;not null" json:"enabled"`
	Admin   *bool `gorm:"column:admin;not null" json:"admin"`
}

User represents a distillery user

func (*User) HasPassword

func (user *User) HasPassword() bool

func (*User) IsAdmin

func (user *User) IsAdmin() bool

func (*User) IsEnabled

func (user *User) IsEnabled() bool

func (*User) IsTOTPEnabled

func (user *User) IsTOTPEnabled() bool

func (*User) SetAdmin

func (user *User) SetAdmin(v bool)

func (*User) SetEnabled

func (user *User) SetEnabled(v bool)

func (*User) SetTOTPEnabled

func (user *User) SetTOTPEnabled(v bool)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL