[ISSUE-67869881] update retrieve key request
diff --git a/common/cipher.go b/common/cipher.go index 5562c02..7dd2014 100644 --- a/common/cipher.go +++ b/common/cipher.go
@@ -26,10 +26,12 @@ ) const RegEncrypted = `^\{[0-9A-Za-z]+/[0-9A-Za-z]+/[0-9A-Za-z]+\}.` -const retrieveEncryptKeyPath = "/encryption/key" +const retrieveEncryptKeyPath = "/encryptionkey" const EncryptAes = "AES" const retrieveKeyRetryInterval = time.Duration(5 * time.Second) const retrieveKeyTimeout = time.Duration(5 * time.Minute) +const parameterOrganization = "organization" +const configBearerToken = "apigeesync_bearer_token" var RegexpEncrypted = regexp.MustCompile(RegEncrypted) @@ -88,8 +90,12 @@ func (c *KmsCipherManager) retrieveKey(org string) error { var key []byte - log.Debugf("Retrieving key from: %s", c.serverUrlBase+retrieveEncryptKeyPath) req, err := http.NewRequest(http.MethodGet, c.serverUrlBase+retrieveEncryptKeyPath, nil) + pars := req.URL.Query() + pars[parameterOrganization] = []string{org} + req.URL.RawQuery = pars.Encode() + req.Header.Set("Authorization", "Bearer "+services.Config().GetString(configBearerToken)) + log.Debugf("Retrieving key: %s", req.URL.String()) if err != nil { return fmt.Errorf("failed to create retrieving key request for org=%s : %v", org, err) }
diff --git a/common/data.go b/common/data.go index ef8434f..f7c9ba6 100644 --- a/common/data.go +++ b/common/data.go
@@ -99,7 +99,7 @@ func (dbc *DbManager) GetOrgs() (orgs []string, err error) { db := dbc.GetDb() - rows, err := db.Query(`SELECT name FROM kms_organization`) + rows, err := db.Query(`SELECT DISTINCT org FROM edgex_data_scope`) if err != nil { return nil, err }