feat(graph): validate identity backend value

This commit is contained in:
Ralf Haferkamp
2025-09-24 15:55:04 +02:00
committed by Ralf Haferkamp
parent 7e86d85d62
commit b1c50ea5a0
2 changed files with 11 additions and 0 deletions

View File

@@ -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.")

View File

@@ -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")))
})
})