Create secret key (#309)
* initial aws creds for uplink * uplink random key works * fixed pr per suggestion
This commit is contained in:
parent
75110cf2da
commit
766a82c51f
BIN
cmd/uplink/main
Executable file
BIN
cmd/uplink/main
Executable file
Binary file not shown.
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user