mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-05 19:59:37 -06:00
feat(graph): validate identity backend value
This commit is contained in:
committed by
Ralf Haferkamp
parent
7e86d85d62
commit
b1c50ea5a0
@@ -3,6 +3,7 @@ package parser
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"slices"
|
||||
|
||||
"github.com/go-ldap/ldap/v3"
|
||||
|
||||
@@ -42,6 +43,10 @@ func Validate(cfg *config.Config) error {
|
||||
return shared.MissingJWTTokenError(cfg.Service.Name)
|
||||
}
|
||||
|
||||
if !slices.Contains([]string{"ldap", "cs3"}, cfg.Identity.Backend) {
|
||||
return fmt.Errorf("'%s' is not a valid identity backend for the 'graph' service", cfg.Identity.Backend)
|
||||
}
|
||||
|
||||
// ensure that the "cs3" identity backend is used in multi-tenant setups
|
||||
if cfg.Commons.MultiTenantEnabled && cfg.Identity.Backend != "cs3" {
|
||||
return fmt.Errorf("Multi-tenant support is enabled. The identity backend must be set to 'cs3' for the 'graph' service.")
|
||||
|
||||
@@ -60,4 +60,10 @@ var _ = Describe("Validate", func() {
|
||||
})
|
||||
})
|
||||
|
||||
It("rejcts a setup with an invalid identity backend", func() {
|
||||
cfg.Identity.Backend = "invalid-backend"
|
||||
err := parser.Validate(cfg)
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err).To(MatchError(ContainSubstring("is not a valid identity backend")))
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user