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

Fix setup detection for local users #3888

Merged
merged 2 commits into from
Sep 22, 2019
Merged
Changes from 1 commit
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
33 changes: 33 additions & 0 deletions src/jetstream/repository/interfaces/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,41 @@ type ConsoleConfig struct {
UseSSO bool `json:"use_sso" configName:"SSO_LOGIN"`
}

const defaultAdminScope = "stratos.admin"

// IsSetupComplete indicates if we have enough config
func (consoleConfig *ConsoleConfig) IsSetupComplete() bool {

// Local user - check setup complete
if AuthEndpointTypes[consoleConfig.AuthEndpointType] == Local {

// Need LocalUser and LocalUserPassword
if len(consoleConfig.LocalUser) == 0 || len(consoleConfig.LocalUserPassword) == 0 {
return false
}

// Also, we will make sure that admin scopes are set up for admin, if not specified
if len(consoleConfig.LocalUserScope) == 0 {
if len(consoleConfig.ConsoleAdminScope) == 0 {
// Neither set, so use default for both
consoleConfig.LocalUserScope = defaultAdminScope
consoleConfig.ConsoleAdminScope = defaultAdminScope
} else {
// admin scope set, so just use that
consoleConfig.LocalUserScope = consoleConfig.ConsoleAdminScope
}
} else {
if len(consoleConfig.ConsoleAdminScope) == 0 {
// Console admin scope not set, so use local user scope
consoleConfig.ConsoleAdminScope = consoleConfig.LocalUserScope
}
}

// Setup is complete if we have LocalUser and LocalUserPassword set
return true
}

// UAA - check setup complete for UAA
if consoleConfig.UAAEndpoint == nil {
return false
}
Expand Down