Skip to content

Commit

Permalink
Disable local directory services when using a remote directory (#375)
Browse files Browse the repository at this point in the history
  • Loading branch information
carabasdaniel committed May 8, 2024
1 parent 4d888c1 commit a02deb9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
17 changes: 8 additions & 9 deletions pkg/app/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,19 @@ func (e *ConsoleService) Cleanups() []func() {
}

func (e *ConsoleService) PrepareConfig(cfg *config.Config) *handlers.TopazCfg {
directoryServiceURL := serviceAddress(fmt.Sprintf("https://%s", strings.Split(cfg.DirectoryResolver.Address, ":")[0]))

authorizerURL := ""
if serviceConfig, ok := cfg.APIConfig.Services[authorizerService]; ok {
authorizerURL = getGatewayAddress(serviceConfig)
}

readerURL := ""
if serviceConfig, ok := cfg.APIConfig.Services[readerService]; ok {
readerURL = getGatewayAddress(serviceConfig)
if cfg.DirectoryResolver.Address == serviceConfig.GRPC.ListenAddress {
directoryServiceURL = readerURL
}
}
writerURL := ""
if serviceConfig, ok := cfg.APIConfig.Services[writerService]; ok {
Expand Down Expand Up @@ -86,19 +92,12 @@ func (e *ConsoleService) PrepareConfig(cfg *config.Config) *handlers.TopazCfg {
}
}

directoryAPIKey := ""
if _, ok := cfg.APIConfig.Services[readerService]; ok {
for key := range cfg.Auth.APIKeys {
// we only need a key
directoryAPIKey = key
break
}
}
directoryAPIKey := cfg.DirectoryResolver.APIKey

return &handlers.TopazCfg{
AuthorizerServiceURL: authorizerURL,
AuthorizerAPIKey: authorizerAPIKey,
DirectoryServiceURL: readerURL,
DirectoryServiceURL: directoryServiceURL,
DirectoryAPIKey: directoryAPIKey,
DirectoryTenantID: cfg.DirectoryResolver.TenantID,
DirectoryReaderServiceURL: readerURL,
Expand Down
6 changes: 5 additions & 1 deletion pkg/app/topaz.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,11 @@ func (e *Topaz) GetDecisionLogger(cfg config.DecisionLogConfig) (decisionlog.Dec
func (e *Topaz) validateConfig() error {
if readerConfig, ok := e.Configuration.APIConfig.Services["reader"]; ok {
if readerConfig.GRPC.ListenAddress != e.Configuration.DirectoryResolver.Address {
return errors.New("remote directory resolver address is different from reader grpc address")
for _, serviceName := range e.Services["edge"].AvailableServices() {
delete(e.Configuration.APIConfig.Services, serviceName)
}
delete(e.Services, "edge")
e.Logger.Info().Msg("disabling local directory services")
}
}

Expand Down

0 comments on commit a02deb9

Please sign in to comment.