mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-06 12:19:37 -06:00
allow configuring addtional proxy routes
Signed-off-by: jkoberg <jkoberg@owncloud.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
Enhancement: Allow configuring additional routes
|
||||
|
||||
Allows adding custom routes to the ocis proxy. This enables customs ocis extensions
|
||||
|
||||
https://github.com/owncloud/ocis/pull/7740
|
||||
@@ -26,6 +26,7 @@ type Config struct {
|
||||
|
||||
RoleQuotas map[string]uint64 `yaml:"role_quotas"`
|
||||
Policies []Policy `yaml:"policies"`
|
||||
AdditionalPolicies []Policy `yaml:"additional_policies"`
|
||||
OIDC OIDC `yaml:"oidc"`
|
||||
ServiceAccount ServiceAccount `yaml:"service_account"`
|
||||
RoleAssignment RoleAssignment `yaml:"role_assignment"`
|
||||
|
||||
@@ -292,7 +292,7 @@ func EnsureDefaults(cfg *config.Config) {
|
||||
// Sanitize sanitizes the configuration
|
||||
func Sanitize(cfg *config.Config) {
|
||||
if cfg.Policies == nil {
|
||||
cfg.Policies = DefaultPolicies()
|
||||
cfg.Policies = mergePolicies(DefaultPolicies(), cfg.AdditionalPolicies)
|
||||
}
|
||||
|
||||
if cfg.PolicySelector == nil {
|
||||
@@ -307,3 +307,21 @@ func Sanitize(cfg *config.Config) {
|
||||
cfg.HTTP.Root = strings.TrimSuffix(cfg.HTTP.Root, "/")
|
||||
}
|
||||
}
|
||||
|
||||
func mergePolicies(policies []config.Policy, additionalPolicies []config.Policy) []config.Policy {
|
||||
for _, p := range additionalPolicies {
|
||||
found := false
|
||||
for i, po := range policies {
|
||||
if po.Name == p.Name {
|
||||
po.Routes = append(po.Routes, p.Routes...)
|
||||
policies[i] = po
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
policies = append(policies, p)
|
||||
}
|
||||
}
|
||||
return policies
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user