chore: use interfaces for all other services

This commit is contained in:
Christoph Haas
2025-03-23 23:09:47 +01:00
parent 02ed7b19df
commit 7d0da4e7ad
40 changed files with 1337 additions and 406 deletions

View File

@@ -8,6 +8,7 @@ import (
"github.com/go-ldap/ldap/v3"
)
// Auth contains all authentication providers.
type Auth struct {
// OpenIDConnect contains a list of OpenID Connect providers.
OpenIDConnect []OpenIDConnectProvider `yaml:"oidc"`
@@ -17,6 +18,7 @@ type Auth struct {
Ldap []LdapProvider `yaml:"ldap"`
}
// BaseFields contains the basic fields that are used to map user information from the authentication providers.
type BaseFields struct {
// UserIdentifier is the name of the field that contains the user identifier.
UserIdentifier string `yaml:"user_identifier"`
@@ -32,6 +34,7 @@ type BaseFields struct {
Department string `yaml:"department"`
}
// OauthFields contains extra fields that are used to map user information from OAuth providers.
type OauthFields struct {
BaseFields `yaml:",inline"`
// IsAdmin is the name of the field that contains the admin flag.
@@ -107,12 +110,14 @@ func (o *OauthAdminMapping) GetAdminGroupRegex() *regexp.Regexp {
return o.adminGroupRegex
}
// LdapFields contains extra fields that are used to map user information from LDAP providers.
type LdapFields struct {
BaseFields `yaml:",inline"`
// GroupMembership is the name of the LDAP field that contains the groups to which the user belongs.
GroupMembership string `yaml:"memberof"`
}
// LdapProvider contains the configuration for the LDAP connection.
type LdapProvider struct {
// ProviderName is an internal name that is used to distinguish LDAP servers. It must not contain spaces or special characters.
ProviderName string `yaml:"provider_name"`
@@ -163,6 +168,7 @@ type LdapProvider struct {
LogUserInfo bool `yaml:"log_user_info"`
}
// OpenIDConnectProvider contains the configuration for the OpenID Connect provider.
type OpenIDConnectProvider struct {
// ProviderName is an internal name that is used to distinguish oauth endpoints. It must not contain spaces or special characters.
ProviderName string `yaml:"provider_name"`
@@ -196,6 +202,7 @@ type OpenIDConnectProvider struct {
LogUserInfo bool `yaml:"log_user_info"`
}
// OAuthProvider contains the configuration for the OAuth provider.
type OAuthProvider struct {
// ProviderName is an internal name that is used to distinguish oauth endpoints. It must not contain spaces or special characters.
ProviderName string `yaml:"provider_name"`

View File

@@ -10,6 +10,7 @@ import (
"gopkg.in/yaml.v3"
)
// Config is the main configuration struct.
type Config struct {
Core struct {
// AdminUser defines the default administrator account that will be created
@@ -179,6 +180,7 @@ func GetConfig() (*Config, error) {
return cfg, nil
}
// loadConfigFile loads the configuration from a YAML file into the given cfg struct.
func loadConfigFile(cfg any, filename string) error {
data, err := envsubst.ReadFile(filename)
if err != nil {

View File

@@ -2,6 +2,8 @@ package config
import "time"
// SupportedDatabase is a type for the supported database types.
// Supported: mysql, mssql, postgres, sqlite
type SupportedDatabase string
const (
@@ -11,6 +13,7 @@ const (
DatabaseSQLite SupportedDatabase = "sqlite"
)
// DatabaseConfig contains the configuration for the database connection.
type DatabaseConfig struct {
// Debug enables logging of all database statements
Debug bool `yaml:"debug"`

View File

@@ -1,5 +1,7 @@
package config
// MailEncryption is the type of the SMTP encryption.
// Supported: none, tls, starttls
type MailEncryption string
const (
@@ -8,6 +10,8 @@ const (
MailEncryptionStartTLS MailEncryption = "starttls"
)
// MailAuthType is the type of the SMTP authentication.
// Supported: plain, login, crammd5
type MailAuthType string
const (
@@ -16,6 +20,7 @@ const (
MailAuthCramMD5 MailAuthType = "crammd5"
)
// MailConfig contains the configuration for the mail server which is used to send emails.
type MailConfig struct {
// Host is the hostname or IP of the SMTP server
Host string `yaml:"host"`

View File

@@ -1,5 +1,6 @@
package config
// WebConfig contains the configuration for the web server.
type WebConfig struct {
// RequestLogging enables logging of all HTTP requests.
RequestLogging bool `yaml:"request_logging"`