mirror of
https://github.com/minio/minio.git
synced 2025-03-31 17:53:43 -04:00
control cmds: Extract access and secret keys from URL if specified (#3109)
This commit is contained in:
parent
e9c45102b0
commit
f7c20b97a1
@ -191,9 +191,19 @@ func healControl(ctx *cli.Context) {
|
|||||||
parsedURL, err := url.Parse(ctx.Args().Get(0))
|
parsedURL, err := url.Parse(ctx.Args().Get(0))
|
||||||
fatalIf(err, "Unable to parse URL %s", ctx.Args().Get(0))
|
fatalIf(err, "Unable to parse URL %s", ctx.Args().Get(0))
|
||||||
|
|
||||||
|
accessKey := serverConfig.GetCredential().AccessKeyID
|
||||||
|
secretKey := serverConfig.GetCredential().SecretAccessKey
|
||||||
|
// Username and password specified in URL will override prior configuration
|
||||||
|
if parsedURL.User != nil {
|
||||||
|
accessKey = parsedURL.User.Username()
|
||||||
|
if key, set := parsedURL.User.Password(); set {
|
||||||
|
secretKey = key
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
authCfg := &authConfig{
|
authCfg := &authConfig{
|
||||||
accessKey: serverConfig.GetCredential().AccessKeyID,
|
accessKey: accessKey,
|
||||||
secretKey: serverConfig.GetCredential().SecretAccessKey,
|
secretKey: secretKey,
|
||||||
secureConn: parsedURL.Scheme == "https",
|
secureConn: parsedURL.Scheme == "https",
|
||||||
address: parsedURL.Host,
|
address: parsedURL.Host,
|
||||||
path: path.Join(reservedBucket, controlPath),
|
path: path.Join(reservedBucket, controlPath),
|
||||||
|
@ -150,6 +150,16 @@ func lockControl(c *cli.Context) {
|
|||||||
parsedURL, err := url.Parse(c.Args().Get(1))
|
parsedURL, err := url.Parse(c.Args().Get(1))
|
||||||
fatalIf(err, "Unable to parse URL.")
|
fatalIf(err, "Unable to parse URL.")
|
||||||
|
|
||||||
|
accessKey := serverConfig.GetCredential().AccessKeyID
|
||||||
|
secretKey := serverConfig.GetCredential().SecretAccessKey
|
||||||
|
// Username and password specified in URL will override prior configuration
|
||||||
|
if parsedURL.User != nil {
|
||||||
|
accessKey = parsedURL.User.Username()
|
||||||
|
if key, set := parsedURL.User.Password(); set {
|
||||||
|
secretKey = key
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Parse older than string.
|
// Parse older than string.
|
||||||
olderThanStr := c.String("older-than")
|
olderThanStr := c.String("older-than")
|
||||||
olderThan, err := time.ParseDuration(olderThanStr)
|
olderThan, err := time.ParseDuration(olderThanStr)
|
||||||
@ -162,8 +172,8 @@ func lockControl(c *cli.Context) {
|
|||||||
recursive := c.Bool("recursive")
|
recursive := c.Bool("recursive")
|
||||||
|
|
||||||
authCfg := &authConfig{
|
authCfg := &authConfig{
|
||||||
accessKey: serverConfig.GetCredential().AccessKeyID,
|
accessKey: accessKey,
|
||||||
secretKey: serverConfig.GetCredential().SecretAccessKey,
|
secretKey: secretKey,
|
||||||
secureConn: parsedURL.Scheme == "https",
|
secureConn: parsedURL.Scheme == "https",
|
||||||
address: parsedURL.Host,
|
address: parsedURL.Host,
|
||||||
path: path.Join(reservedBucket, controlPath),
|
path: path.Join(reservedBucket, controlPath),
|
||||||
|
@ -71,9 +71,19 @@ func serviceControl(c *cli.Context) {
|
|||||||
parsedURL, err := url.Parse(c.Args().Get(1))
|
parsedURL, err := url.Parse(c.Args().Get(1))
|
||||||
fatalIf(err, "Unable to parse URL %s", c.Args().Get(1))
|
fatalIf(err, "Unable to parse URL %s", c.Args().Get(1))
|
||||||
|
|
||||||
|
accessKey := serverConfig.GetCredential().AccessKeyID
|
||||||
|
secretKey := serverConfig.GetCredential().SecretAccessKey
|
||||||
|
// Username and password specified in URL will override prior configuration
|
||||||
|
if parsedURL.User != nil {
|
||||||
|
accessKey = parsedURL.User.Username()
|
||||||
|
if key, set := parsedURL.User.Password(); set {
|
||||||
|
secretKey = key
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
authCfg := &authConfig{
|
authCfg := &authConfig{
|
||||||
accessKey: serverConfig.GetCredential().AccessKeyID,
|
accessKey: accessKey,
|
||||||
secretKey: serverConfig.GetCredential().SecretAccessKey,
|
secretKey: secretKey,
|
||||||
secureConn: parsedURL.Scheme == "https",
|
secureConn: parsedURL.Scheme == "https",
|
||||||
address: parsedURL.Host,
|
address: parsedURL.Host,
|
||||||
path: path.Join(reservedBucket, controlPath),
|
path: path.Join(reservedBucket, controlPath),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user