aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/swarm/access.go
diff options
context:
space:
mode:
authorElad <theman@elad.im>2018-09-07 15:56:05 +0800
committerBalint Gabor <balint.g@gmail.com>2018-09-07 15:56:05 +0800
commit70d31fb27842b047582a6557529b2234de1a4a8d (patch)
tree0fd8cefad55c82060373fba93aaae76986e1f0a9 /cmd/swarm/access.go
parent580145e96db848cb8e2f8bb8f0621bcacbc9521c (diff)
downloadgo-tangerine-70d31fb27842b047582a6557529b2234de1a4a8d.tar
go-tangerine-70d31fb27842b047582a6557529b2234de1a4a8d.tar.gz
go-tangerine-70d31fb27842b047582a6557529b2234de1a4a8d.tar.bz2
go-tangerine-70d31fb27842b047582a6557529b2234de1a4a8d.tar.lz
go-tangerine-70d31fb27842b047582a6557529b2234de1a4a8d.tar.xz
go-tangerine-70d31fb27842b047582a6557529b2234de1a4a8d.tar.zst
go-tangerine-70d31fb27842b047582a6557529b2234de1a4a8d.zip
cmd/swarm: added password to ACT (#17598)
Diffstat (limited to 'cmd/swarm/access.go')
-rw-r--r--cmd/swarm/access.go47
1 files changed, 31 insertions, 16 deletions
diff --git a/cmd/swarm/access.go b/cmd/swarm/access.go
index 12cfbfc1a..1e69526ec 100644
--- a/cmd/swarm/access.go
+++ b/cmd/swarm/access.go
@@ -51,7 +51,7 @@ func accessNewPass(ctx *cli.Context) {
password = getPassPhrase("", 0, makePasswordList(ctx))
dryRun = ctx.Bool(SwarmDryRunFlag.Name)
)
- accessKey, ae, err = api.DoPasswordNew(ctx, password, salt)
+ accessKey, ae, err = api.DoPassword(ctx, password, salt)
if err != nil {
utils.Fatalf("error getting session key: %v", err)
}
@@ -85,7 +85,7 @@ func accessNewPK(ctx *cli.Context) {
granteePublicKey = ctx.String(SwarmAccessGrantKeyFlag.Name)
dryRun = ctx.Bool(SwarmDryRunFlag.Name)
)
- sessionKey, ae, err = api.DoPKNew(ctx, privateKey, granteePublicKey, salt)
+ sessionKey, ae, err = api.DoPK(ctx, privateKey, granteePublicKey, salt)
if err != nil {
utils.Fatalf("error getting session key: %v", err)
}
@@ -110,23 +110,38 @@ func accessNewACT(ctx *cli.Context) {
}
var (
- ae *api.AccessEntry
- actManifest *api.Manifest
- accessKey []byte
- err error
- ref = args[0]
- grantees = []string{}
- actFilename = ctx.String(SwarmAccessGrantKeysFlag.Name)
- privateKey = getPrivKey(ctx)
- dryRun = ctx.Bool(SwarmDryRunFlag.Name)
+ ae *api.AccessEntry
+ actManifest *api.Manifest
+ accessKey []byte
+ err error
+ ref = args[0]
+ pkGrantees = []string{}
+ passGrantees = []string{}
+ pkGranteesFilename = ctx.String(SwarmAccessGrantKeysFlag.Name)
+ passGranteesFilename = ctx.String(utils.PasswordFileFlag.Name)
+ privateKey = getPrivKey(ctx)
+ dryRun = ctx.Bool(SwarmDryRunFlag.Name)
)
+ if pkGranteesFilename == "" && passGranteesFilename == "" {
+ utils.Fatalf("you have to provide either a grantee public-keys file or an encryption passwords file (or both)")
+ }
- bytes, err := ioutil.ReadFile(actFilename)
- if err != nil {
- utils.Fatalf("had an error reading the grantee public key list")
+ if pkGranteesFilename != "" {
+ bytes, err := ioutil.ReadFile(pkGranteesFilename)
+ if err != nil {
+ utils.Fatalf("had an error reading the grantee public key list")
+ }
+ pkGrantees = strings.Split(string(bytes), "\n")
+ }
+
+ if passGranteesFilename != "" {
+ bytes, err := ioutil.ReadFile(passGranteesFilename)
+ if err != nil {
+ utils.Fatalf("could not read password filename: %v", err)
+ }
+ passGrantees = strings.Split(string(bytes), "\n")
}
- grantees = strings.Split(string(bytes), "\n")
- accessKey, ae, actManifest, err = api.DoACTNew(ctx, privateKey, salt, grantees)
+ accessKey, ae, actManifest, err = api.DoACT(ctx, privateKey, salt, pkGrantees, passGrantees)
if err != nil {
utils.Fatalf("error generating ACT manifest: %v", err)
}