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

Enable/disable API keys UI given API keys config setting #4559

Merged
merged 12 commits into from
Sep 7, 2020
Prev Previous commit
Next Next commit
Fix failing test
  • Loading branch information
ikapelyukhin committed Aug 28, 2020
commit 9b6ecfc3c31abe7b6033ea0864ff35ac8b5b8588
4 changes: 2 additions & 2 deletions src/jetstream/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -784,9 +784,9 @@ func TestVerifySession(t *testing.T) {
So(contentType, ShouldEqual, "application/json; charset=UTF-8")
})

var expectedScopes = "\"scopes\":[\"openid\",\"scim.read\",\"cloud_controller.admin\",\"uaa.user\",\"cloud_controller.read\",\"password.write\",\"routing.router_groups.read\",\"cloud_controller.write\",\"doppler.firehose\",\"scim.write\"]"
var expectedScopes = `"scopes":["openid","scim.read","cloud_controller.admin","uaa.user","cloud_controller.read","password.write","routing.router_groups.read","cloud_controller.write","doppler.firehose","scim.write"]`

var expectedBody = "{\"version\":{\"proxy_version\":\"dev\",\"database_version\":20161117141922},\"user\":{\"guid\":\"asd-gjfg-bob\",\"name\":\"admin\",\"admin\":false," + expectedScopes + "},\"endpoints\":{\"cf\":{}},\"plugins\":null,\"config\":{\"enableTechPreview\":false}}"
var expectedBody = `{"version":{"proxy_version":"dev","database_version":20161117141922},"user":{"guid":"asd-gjfg-bob","name":"admin","admin":false,` + expectedScopes + `},"endpoints":{"cf":{}},"plugins":null,"config":{"enableTechPreview":false,"APIKeysEnabled":"admin_only"}}`

Convey("Should contain expected body", func() {
So(res, ShouldNotBeNil)
Expand Down
12 changes: 6 additions & 6 deletions src/jetstream/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,6 @@ func main() {
}()
log.Info("Session data store initialized.")

// Setting default value for APIKeysEnabled
if portalConfig.APIKeysEnabled == "" {
log.Debug(`APIKeysEnabled not set, setting to "admin_only"`)
portalConfig.APIKeysEnabled = config.APIKeysConfigEnum.AdminOnly
}

// Setup the global interface for the proxy
portalProxy := newPortalProxy(portalConfig, databaseConnectionPool, sessionStore, sessionStoreOptions, envLookup)
portalProxy.SessionDataStore = sessionDataStore
Expand Down Expand Up @@ -665,6 +659,12 @@ func newPortalProxy(pc interfaces.PortalConfig, dcp *sql.DB, ss HttpSessionStore

log.Infof("Session Cookie name: %s", cookieName)

// Setting default value for APIKeysEnabled
if pc.APIKeysEnabled == "" {
log.Debug(`APIKeysEnabled not set, setting to "admin_only"`)
pc.APIKeysEnabled = config.APIKeysConfigEnum.AdminOnly
}

pp := &portalProxy{
Config: pc,
DatabaseConnectionPool: dcp,
Expand Down