Require access to Still via method

This commit adds a safeguard to accessing the still from a specific
component by requiring access via the component.GetStill method.
This commit is contained in:
Tom Wiesing 2024-04-08 22:39:32 +02:00
parent 81fa84c244
commit 8235ea9105
No known key found for this signature in database
63 changed files with 288 additions and 197 deletions

View file

@ -4,11 +4,12 @@ import (
"net/url"
"github.com/FAU-CDI/wisski-distillery/internal/config"
"github.com/FAU-CDI/wisski-distillery/internal/dis/component"
)
// Domain returns the full domain name of this WissKI
func (liquid *Liquid) Domain() string {
return liquid.Config.HTTP.HostFromSlug(liquid.Slug)
return component.GetStill(liquid).Config.HTTP.HostFromSlug(liquid.Slug)
}
func (liquid *Liquid) Hostname() string {
@ -29,7 +30,7 @@ func (liquid *Liquid) URL() *url.URL {
}
// use http or https scheme depending on if the distillery has it enabled
if liquid.Malt.Config.HTTP.HTTPSEnabled() {
if component.GetStill(liquid.Malt).Config.HTTP.HTTPSEnabled() {
url.Scheme = "https"
} else {
url.Scheme = "http"

View file

@ -9,7 +9,7 @@ import (
// Liquid is the core of a WissKI Instance and used in every ingredient.
type Liquid struct {
*malt.Malt
models.Instance
models.Instance // TODO: move this into an explicit field
DrupalUsername string
DrupalPassword string