Do not save credentials in config.json (#16275)

This commit is contained in:
Anis Elleuch
2022-12-19 21:27:06 +01:00
committed by GitHub
parent b4f71362e9
commit e57e946206
7 changed files with 8 additions and 92 deletions
-19
View File
@@ -96,7 +96,6 @@ const (
// Top level config constants.
const (
CredentialsSubSys = madmin.CredentialsSubSys
PolicyOPASubSys = madmin.PolicyOPASubSys
PolicyPluginSubSys = madmin.PolicyPluginSubSys
IdentityOpenIDSubSys = madmin.IdentityOpenIDSubSys
@@ -178,7 +177,6 @@ var SubSystemsDynamic = set.CreateStringSet(
// SubSystemsSingleTargets - subsystems which only support single target.
var SubSystemsSingleTargets = set.CreateStringSet(
CredentialsSubSys,
SiteSubSys,
RegionSubSys,
EtcdSubSys,
@@ -463,9 +461,6 @@ func (c Config) RedactSensitiveInfo() Config {
}
}
// Remove the server credentials altogether
nc.DelKVS(CredentialsSubSys)
return nc
}
@@ -501,20 +496,6 @@ var (
}
)
// LookupCreds - lookup credentials from config.
func LookupCreds(kv KVS) (auth.Credentials, error) {
if err := CheckValidKeys(CredentialsSubSys, kv, DefaultCredentialKVS); err != nil {
return auth.Credentials{}, err
}
accessKey := kv.Get(AccessKey)
secretKey := kv.Get(SecretKey)
if accessKey == "" || secretKey == "" {
accessKey = auth.DefaultAccessKey
secretKey = auth.DefaultSecretKey
}
return auth.CreateCredentials(accessKey, secretKey)
}
// Site - holds site info - name and region.
type Site struct {
Name string
-23
View File
@@ -17,31 +17,8 @@
package config
import "github.com/minio/minio/internal/auth"
// One time migration code section
// SetCredentials - One time migration code needed, for migrating from older config to new for server credentials.
func SetCredentials(c Config, cred auth.Credentials) {
creds, err := auth.CreateCredentials(cred.AccessKey, cred.SecretKey)
if err != nil {
return
}
if !creds.IsValid() {
return
}
c[CredentialsSubSys][Default] = KVS{
KV{
Key: AccessKey,
Value: cred.AccessKey,
},
KV{
Key: SecretKey,
Value: cred.SecretKey,
},
}
}
// SetRegion - One time migration code needed, for migrating from older config to new for server Region.
func SetRegion(c Config, name string) {
if name == "" {