Documentation ¶
Index ¶
- Constants
- Variables
- func FormatBuildVersion(version string, commit string, buildTime time.Time) string
- type Auth
- type AuthAction
- type AuthConfig
- type AuthGroups
- type BaseVariables
- type Config
- type DB
- func (d *DB) Close() error
- func (d *DB) CreateFile(ctx context.Context, path string, size uint64, contentType string, ...) (*File, error)
- func (d *DB) DeleteFile(ctx context.Context, path string) error
- func (d *DB) FindFiles(ctx context.Context, path string) ([]File, error)
- func (d *DB) GetAllUsers(ctx context.Context) ([]User, error)
- func (d *DB) GetFile(ctx context.Context, path string) (*File, error)
- func (d *DB) GetUser(ctx context.Context, id string) (*User, error)
- func (d *DB) GetUserByName(ctx context.Context, username string) (*User, error)
- func (d *DB) GetUsers(ctx context.Context, ids []string) ([]User, error)
- func (d *DB) UpdateFile(ctx context.Context, path string, newPath string, size uint64, ...) error
- func (d *DB) UpsertUser(ctx context.Context, id string, username string, email string, home string) error
- type DatabaseConfig
- type DatabaseType
- type ErrorResponse
- type ExecuteTemplateFunc
- type File
- type FileRequest
- type IndexVariables
- type LogConfig
- type MetricsConfig
- type OtelConfig
- type Server
- func (s *Server) Auth(next http.Handler) http.Handler
- func (s *Server) Callback(w http.ResponseWriter, r *http.Request)
- func (s *Server) CheckAuth(allowedFunc func(r *http.Request, info *UserInfo) AuthAction) func(next http.Handler) http.Handler
- func (s *Server) Close()
- func (s *Server) DeleteFiles(w http.ResponseWriter, r *http.Request)
- func (s *Server) GetFiles(w http.ResponseWriter, r *http.Request)
- func (s *Server) GetSettings(w http.ResponseWriter, r *http.Request)
- func (s *Server) GetVersion(w http.ResponseWriter, _ *http.Request)
- func (s *Server) Login(w http.ResponseWriter, r *http.Request)
- func (s *Server) Logout(w http.ResponseWriter, r *http.Request)
- func (s *Server) MoveFiles(w http.ResponseWriter, r *http.Request)
- func (s *Server) PatchFile(w http.ResponseWriter, r *http.Request)
- func (s *Server) PostFile(w http.ResponseWriter, r *http.Request)
- func (s *Server) Routes() http.Handler
- func (s *Server) Start()
- func (s *Server) ToTemplateUser(info *UserInfo) TemplateUser
- type Session
- type SettingsVariables
- type Storage
- type StorageConfig
- type StorageType
- type TemplateFile
- type TemplateUser
- type TraceConfig
- type UpdateFile
- type User
- type UserInfo
- type WarningResponse
- type WriterFunc
Constants ¶
View Source
const SessionCookieName = "X-Session-ID"
Variables ¶
View Source
var ( ErrFileNotFound = errors.New("file not found") ErrFileAlreadyExists = errors.New("file already exists") ErrUserNotFound = errors.New("user not found") )
View Source
var UserInfoKey = authKey{}
Functions ¶
Types ¶
type AuthAction ¶
type AuthAction string
const ( AuthActionDeny AuthAction = "deny" AuthActionAllow AuthAction = "allow" AuthActionLogin AuthAction = "login" )
type AuthConfig ¶
type AuthConfig struct { Secure bool `cfg:"secure"` Issuer string `cfg:"issuer"` ClientID string `cfg:"client_id"` ClientSecret string `cfg:"client_secret"` RedirectURL string `cfg:"redirect_url"` RefreshTokenLifespan time.Duration `cfg:"refresh_token_lifespan"` DefaultHome string `cfg:"default_home"` Groups AuthGroups `cfg:"groups"` }
func (AuthConfig) String ¶
func (c AuthConfig) String() string
type AuthGroups ¶
type AuthGroups struct { Admin string `cfg:"admin"` User string `cfg:"user"` Viewer string `cfg:"viewer"` Guest bool `cfg:"guest"` }
func (AuthGroups) String ¶
func (c AuthGroups) String() string
type BaseVariables ¶
type BaseVariables struct { Theme string Auth bool User TemplateUser }
type Config ¶
type Config struct { Log LogConfig `cfg:"log"` DevMode bool `cfg:"dev_mode"` Debug bool `cfg:"debug"` ListenAddr string `cfg:"listen_addr"` Database DatabaseConfig `cfg:"database"` Storage StorageConfig `cfg:"storage"` Auth *AuthConfig `cfg:"auth"` Otel *OtelConfig `cfg:"otel"` }
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
func (*DB) CreateFile ¶
func (*DB) GetUserByName ¶
func (*DB) UpdateFile ¶
type DatabaseConfig ¶
type DatabaseConfig struct { Type DatabaseType `cfg:"type"` Debug bool `cfg:"debug"` // SQLite Path string `cfg:"path"` // PostgreSQL Host string `cfg:"host"` Port int `cfg:"port"` Username string `cfg:"username"` Password string `cfg:"password"` Database string `cfg:"database"` SSLMode string `cfg:"ssl_mode"` }
func (DatabaseConfig) PostgresDataSourceName ¶
func (c DatabaseConfig) PostgresDataSourceName() string
func (DatabaseConfig) String ¶
func (c DatabaseConfig) String() string
type DatabaseType ¶
type DatabaseType string
const ( DatabaseTypePostgres DatabaseType = "postgres" DatabaseTypeSQLite DatabaseType = "sqlite" )
type ErrorResponse ¶
type FileRequest ¶
type IndexVariables ¶
type IndexVariables struct { BaseVariables Path string PathParts []string Files []TemplateFile }
type LogConfig ¶
type MetricsConfig ¶
type MetricsConfig struct {
ListenAddr string `cfg:"listen_addr"`
}
func (MetricsConfig) String ¶
func (c MetricsConfig) String() string
type OtelConfig ¶
type OtelConfig struct { InstanceID string `cfg:"instance_id"` Trace *TraceConfig `cfg:"trace"` Metrics *MetricsConfig `cfg:"metrics"` }
func (OtelConfig) String ¶
func (c OtelConfig) String() string
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func NewServer ¶
func NewServer(version string, cfg Config, db *DB, auth *Auth, storage Storage, tracer trace.Tracer, meter metric.Meter, assets http.FileSystem, tmpl ExecuteTemplateFunc, js WriterFunc, css WriterFunc) *Server
func (*Server) DeleteFiles ¶
func (s *Server) DeleteFiles(w http.ResponseWriter, r *http.Request)
func (*Server) GetSettings ¶
func (s *Server) GetSettings(w http.ResponseWriter, r *http.Request)
func (*Server) GetVersion ¶
func (s *Server) GetVersion(w http.ResponseWriter, _ *http.Request)
func (*Server) ToTemplateUser ¶
func (s *Server) ToTemplateUser(info *UserInfo) TemplateUser
type SettingsVariables ¶
type SettingsVariables struct { BaseVariables Users []TemplateUser }
type Storage ¶
type Storage interface { GetObject(ctx context.Context, filePath string, start *int64, end *int64) (io.ReadCloser, error) MoveObject(ctx context.Context, from string, to string) error PutObject(ctx context.Context, filePath string, size uint64, reader io.Reader, contentType string) error DeleteObject(ctx context.Context, filePath string) error }
func NewStorage ¶
type StorageConfig ¶
type StorageConfig struct { Type StorageType `cfg:"type"` Debug bool `cfg:"debug"` // Local Path string `cfg:"path"` Umask int `cfg:"umask"` // S3 Endpoint string `cfg:"endpoint"` AccessKeyID string `cfg:"access_key_id"` SecretAccessKey string `cfg:"secret_access_key"` Bucket string `cfg:"bucket"` Region string `cfg:"region"` Secure bool `cfg:"secure"` }
func (StorageConfig) String ¶
func (c StorageConfig) String() string
type StorageType ¶
type StorageType string
const ( StorageTypeLocal StorageType = "local" StorageTypeS3 StorageType = "s3" )
type TemplateFile ¶
type TemplateUser ¶
type TraceConfig ¶
func (TraceConfig) String ¶
func (c TraceConfig) String() string
type UpdateFile ¶
type UserInfo ¶
type UserInfo struct { oidc.UserInfo Home string `json:"home"` Audience []string `json:"aud"` Groups []string `json:"groups"` Username string `json:"preferred_username"` }
func GetUserInfo ¶
type WarningResponse ¶
type WriterFunc ¶
Click to show internal directories.
Click to hide internal directories.