Remove prefix from special domains

Because LE doesn't issue certs for them
This commit is contained in:
Tom Wiesing 2023-11-02 14:31:08 +01:00
parent 5ef2e14ae9
commit 6b3460c702
No known key found for this signature in database
3 changed files with 14 additions and 7 deletions

View file

@ -39,7 +39,7 @@ http:
# This email address can be configured here. # This email address can be configured here.
certbot_email: null certbot_email: null
# Serve the panel also on the toplevel domain, and not only on the "_panel" domain. # Serve the panel also on the toplevel domain, and not only on the "panel" domain.
# Enabled by default. # Enabled by default.
panel: null panel: null
@ -47,7 +47,7 @@ http:
# In the future, it will be enabled by default, but at this point it is not. # In the future, it will be enabled by default, but at this point it is not.
api: null api: null
# Enable serving the triplestore webinterface publically under the "_ts" domain # Enable serving the triplestore webinterface publically under the "ts" domain
ts: null ts: null
# Enable serving the phpmyadmin webinterface publically under the "_phymyadmin" domain # Enable serving the phpmyadmin webinterface publically under the "_phymyadmin" domain

View file

@ -26,7 +26,7 @@ type HTTPConfig struct {
CertbotEmail string `yaml:"certbot_email" validate:"email"` CertbotEmail string `yaml:"certbot_email" validate:"email"`
// Also serve the panel on the toplevel domain. // Also serve the panel on the toplevel domain.
// Note that the panel is *always* servered under the "_panel" domain. // Note that the panel is *always* servered under the "panel" domain.
// Disabling this is not recommended. // Disabling this is not recommended.
Panel validators.NullableBool `yaml:"panel" validate:"bool" default:"true"` Panel validators.NullableBool `yaml:"panel" validate:"bool" default:"true"`
@ -113,8 +113,16 @@ var (
PHPMyAdminDomain SpecialDomain = "phpmyadmin" PHPMyAdminDomain SpecialDomain = "phpmyadmin"
) )
var RestrictedSlugs = []string{
"www",
"admin",
PanelDomain.Domain(),
TriplestoreDomain.Domain(),
PHPMyAdminDomain.Domain(),
}
func (sd SpecialDomain) Domain() string { func (sd SpecialDomain) Domain() string {
return "_" + string(sd) return string(sd)
} }
// Domains adds the given subdomain to the primary and alias domains. // Domains adds the given subdomain to the primary and alias domains.

View file

@ -5,6 +5,7 @@ import (
"path/filepath" "path/filepath"
"strings" "strings"
"github.com/FAU-CDI/wisski-distillery/internal/config"
"github.com/FAU-CDI/wisski-distillery/internal/config/validators" "github.com/FAU-CDI/wisski-distillery/internal/config/validators"
"github.com/FAU-CDI/wisski-distillery/internal/models" "github.com/FAU-CDI/wisski-distillery/internal/models"
"github.com/FAU-CDI/wisski-distillery/internal/wisski" "github.com/FAU-CDI/wisski-distillery/internal/wisski"
@ -75,8 +76,6 @@ func (instances *Instances) Create(slug string, system models.System) (wissKI *w
return wissKI, nil return wissKI, nil
} }
var restrictedSlugs = []string{"www", "admin"}
// IsValidSlug checks if slug represents a valid slug for an instance. // IsValidSlug checks if slug represents a valid slug for an instance.
func (instances *Instances) IsValidSlug(slug string) (string, error) { func (instances *Instances) IsValidSlug(slug string) (string, error) {
// check that it is a slug // check that it is a slug
@ -84,7 +83,7 @@ func (instances *Instances) IsValidSlug(slug string) (string, error) {
if err != nil { if err != nil {
return "", errInvalidSlug return "", errInvalidSlug
} }
for _, rs := range restrictedSlugs { for _, rs := range config.RestrictedSlugs {
if strings.EqualFold(rs, slug) { if strings.EqualFold(rs, slug) {
return "", errRestrictedSlug return "", errRestrictedSlug
} }