Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable local directory services when using a remote directory #375

Merged
merged 1 commit into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -306,7 +306,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
Loading