initial commit

This commit is contained in:
0xdcarns
2022-09-13 15:25:56 -04:00
parent 0da5c388b6
commit 88cd0a6497
79 changed files with 4146 additions and 160 deletions

View File

@@ -3,6 +3,7 @@ package command
import (
"crypto/ed25519"
"crypto/rand"
"errors"
"fmt"
"strings"
@@ -18,6 +19,25 @@ import (
func Join(cfg *config.ClientConfig, privateKey string) error {
var err error
//join network
if cfg.SsoServer != "" {
// User wants to get access key from the OIDC server
// Do that before the Joining Network flow by performing the end point auth flow
// if performed successfully an access key is obtained from the server and then we
// proceed with the usual flow 'pretending' that user is feeded us with an access token
logger.Log(1, "Logging into %s via:", cfg.Network, cfg.SsoServer)
err = functions.JoinViaSSo(cfg, privateKey)
if err != nil {
logger.Log(0, "Join via OIDC failed: ", err.Error())
return err
}
if cfg.AccessKey == "" {
return errors.New("failed to get access key")
}
logger.Log(1, "Got an access key to ", cfg.Network, " via:", cfg.SsoServer)
}
logger.Log(1, "Joining network: ", cfg.Network)
err = functions.JoinNetwork(cfg, privateKey)
if err != nil {
if !strings.Contains(err.Error(), "ALREADY_INSTALLED") {