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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/rand"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
|
base58 "github.com/jbenet/go-base58"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"storj.io/storj/pkg/cfgstruct"
|
"storj.io/storj/pkg/cfgstruct"
|
||||||
@ -107,18 +109,39 @@ func cmdSetup(cmd *cobra.Command, args []string) (err error) {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
accessKey, err := generateAWSKey()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
secretKey, err := generateAWSKey()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
o := map[string]interface{}{
|
o := map[string]interface{}{
|
||||||
"cert-path": setupCfg.Identity.CertPath,
|
"cert-path": setupCfg.Identity.CertPath,
|
||||||
"key-path": setupCfg.Identity.KeyPath,
|
"key-path": setupCfg.Identity.KeyPath,
|
||||||
"api-key": setupCfg.APIKey,
|
"api-key": setupCfg.APIKey,
|
||||||
"pointer-db-addr": setupCfg.SatelliteAddr,
|
"pointer-db-addr": setupCfg.SatelliteAddr,
|
||||||
"overlay-addr": setupCfg.SatelliteAddr,
|
"overlay-addr": setupCfg.SatelliteAddr,
|
||||||
|
"access-key": accessKey,
|
||||||
|
"secret-key": secretKey,
|
||||||
}
|
}
|
||||||
|
|
||||||
return process.SaveConfig(runCmd.Flags(),
|
return process.SaveConfig(runCmd.Flags(),
|
||||||
filepath.Join(setupCfg.BasePath, "config.yaml"), o)
|
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() {
|
func main() {
|
||||||
runCmd.Flags().String("config",
|
runCmd.Flags().String("config",
|
||||||
filepath.Join(defaultConfDir, "config.yaml"), "path to configuration")
|
filepath.Join(defaultConfDir, "config.yaml"), "path to configuration")
|
||||||
|
Loading…
Reference in New Issue
Block a user