Create secret key (#309)

* initial aws creds for uplink

* uplink  random key works

* fixed pr per  suggestion
This commit is contained in:
nfarah86 2018-09-06 11:04:41 -07:00 committed by GitHub
parent 75110cf2da
commit 766a82c51f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 0 deletions

BIN
cmd/uplink/main Executable file

Binary file not shown.

View File

@ -4,10 +4,12 @@
package main
import (
"crypto/rand"
"fmt"
"os"
"path/filepath"
base58 "github.com/jbenet/go-base58"
"github.com/spf13/cobra"
"storj.io/storj/pkg/cfgstruct"
@ -107,18 +109,39 @@ func cmdSetup(cmd *cobra.Command, args []string) (err error) {
return err
}
accessKey, err := generateAWSKey()
if err != nil {
return err
}
secretKey, err := generateAWSKey()
if err != nil {
return err
}
o := map[string]interface{}{
"cert-path": setupCfg.Identity.CertPath,
"key-path": setupCfg.Identity.KeyPath,
"api-key": setupCfg.APIKey,
"pointer-db-addr": setupCfg.SatelliteAddr,
"overlay-addr": setupCfg.SatelliteAddr,
"access-key": accessKey,
"secret-key": secretKey,
}
return process.SaveConfig(runCmd.Flags(),
filepath.Join(setupCfg.BasePath, "config.yaml"), o)
}
func generateAWSKey() (key string, err error) {
var buf [20]byte
_, err = rand.Read(buf[:])
if err != nil {
return "", err
}
return base58.Encode(buf[:]), nil
}
func main() {
runCmd.Flags().String("config",
filepath.Join(defaultConfDir, "config.yaml"), "path to configuration")