Indicate backend encrypted only if encryption is requested (#8508)

This commit is contained in:
Harshavardhana 2019-11-11 18:42:10 -08:00 committed by GitHub
parent aa04f97f95
commit 1027afa853
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 14 deletions

View File

@ -183,8 +183,10 @@ func (a adminAPIHandlers) SetConfigKVHandler(w http.ResponseWriter, r *http.Requ
} }
// Make sure to write backend is encrypted // Make sure to write backend is encrypted
if globalConfigEncrypted {
saveConfig(context.Background(), objectAPI, backendEncryptedFile, backendEncryptedMigrationComplete) saveConfig(context.Background(), objectAPI, backendEncryptedFile, backendEncryptedMigrationComplete)
} }
}
// GetConfigKVHandler - GET /minio/admin/v2/get-config-kv?key={key} // GetConfigKVHandler - GET /minio/admin/v2/get-config-kv?key={key}
func (a adminAPIHandlers) GetConfigKVHandler(w http.ResponseWriter, r *http.Request) { func (a adminAPIHandlers) GetConfigKVHandler(w http.ResponseWriter, r *http.Request) {
@ -447,7 +449,9 @@ func (a adminAPIHandlers) SetConfigHandler(w http.ResponseWriter, r *http.Reques
} }
// Make sure to write backend is encrypted // Make sure to write backend is encrypted
if globalConfigEncrypted {
saveConfig(context.Background(), objectAPI, backendEncryptedFile, backendEncryptedMigrationComplete) saveConfig(context.Background(), objectAPI, backendEncryptedFile, backendEncryptedMigrationComplete)
}
// Reply to the client before restarting minio server. // Reply to the client before restarting minio server.
writeSuccessResponseHeadersOnly(w) writeSuccessResponseHeadersOnly(w)

View File

@ -19,11 +19,12 @@ package cmd
import ( import (
"bytes" "bytes"
"context" "context"
"errors"
"os" "os"
"strings" "strings"
"unicode/utf8"
etcd "github.com/coreos/etcd/clientv3" etcd "github.com/coreos/etcd/clientv3"
jsoniter "github.com/json-iterator/go"
"github.com/minio/minio/cmd/config" "github.com/minio/minio/cmd/config"
"github.com/minio/minio/cmd/logger" "github.com/minio/minio/cmd/logger"
"github.com/minio/minio/pkg/auth" "github.com/minio/minio/pkg/auth"
@ -260,11 +261,8 @@ func migrateIAMConfigsEtcdToEncrypted(client *etcd.Client) error {
data = cdata data = cdata
} }
// Attempt to unmarshal JSON content if !utf8.Valid(data) {
var dummy map[string]interface{} return errors.New("config data not in plain-text form")
var json = jsoniter.ConfigCompatibleWithStandardLibrary
if err = json.Unmarshal(data, &dummy); err != nil {
return err
} }
cencdata, err = madmin.EncryptData(globalActiveCred.String(), data) cencdata, err = madmin.EncryptData(globalActiveCred.String(), data)
@ -335,11 +333,8 @@ func migrateConfigPrefixToEncrypted(objAPI ObjectLayer, activeCredOld auth.Crede
data = cdata data = cdata
} }
// Attempt to unmarshal JSON content if !utf8.Valid(data) {
var dummy map[string]interface{} return errors.New("config data not in plain-text form")
var json = jsoniter.ConfigCompatibleWithStandardLibrary
if err = json.Unmarshal(data, &dummy); err != nil {
return err
} }
cencdata, err = madmin.EncryptData(globalActiveCred.String(), data) cencdata, err = madmin.EncryptData(globalActiveCred.String(), data)

View File

@ -193,7 +193,7 @@ func LookupConfig(scfg config.Config) (Config, error) {
if starget != config.Default { if starget != config.Default {
authTokenEnv = EnvLoggerHTTPAuditAuthToken + config.Default + starget authTokenEnv = EnvLoggerHTTPAuditAuthToken + config.Default + starget
} }
cfg.HTTP[starget] = HTTP{ cfg.Audit[starget] = HTTP{
Enabled: true, Enabled: true,
Endpoint: endpoint, Endpoint: endpoint,
AuthToken: env.Get(authTokenEnv, kv.Get(AuthToken)), AuthToken: env.Get(authTokenEnv, kv.Get(AuthToken)),