Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Siddheshk02 committed Nov 28, 2023
1 parent 4a3889e commit 4641e76
Show file tree
Hide file tree
Showing 8 changed files with 132 additions and 91 deletions.
1 change: 0 additions & 1 deletion cmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ var createCmd = &cobra.Command{
}
email := strings.Replace(userData.Email, "@", "-", -1)
Newemail := strings.Replace(email, ".", "-", -1)
fmt.Println(Newemail)

err = lib.Create(Newemail)
if err != nil {
Expand Down
19 changes: 10 additions & 9 deletions cmd/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (

"github.com/Siddheshk02/Securelee-cli/lib"
"github.com/mattn/go-colorable"
"github.com/pangeacyber/pangea-go/pangea-sdk/v2/service/authn"
"github.com/spf13/cobra"
"golang.org/x/term"
)
Expand Down Expand Up @@ -46,7 +45,7 @@ var loginCmd = &cobra.Command{
var choice int
var token string
var err error
var result *authn.ClientTokenCheckResult
var result lib.ResponseData
var ch, usertype string
fmt.Fprintf(out, "\n%s Select any one option: %s\n", yellow, reset)
fmt.Fprintf(out, "\n%s > 1. Login using Socials through Browser%s\n", yellow, reset)
Expand Down Expand Up @@ -96,10 +95,12 @@ var loginCmd = &cobra.Command{
return
}

token, usertype, err = lib.LoginWithEmail(email, string(password))
// token, usertype, err = lib.LoginWithEmail(email, string(password))

if token == "" && usertype == "" && err == nil {
fmt.Println("\033[31m", "\n > Failed to Login! Please try another login method. \033[0m")
os.Exit(0)

if token == "" && usertype == "" && err != nil {
log.Fatalf(err.Error())
} else if token == "" && usertype != "" && err == nil {
fmt.Println("\033[31m", "\n > ", usertype, "\033[0m")
fmt.Println("")
Expand All @@ -119,7 +120,7 @@ var loginCmd = &cobra.Command{
return
}

parsedTime, err := time.Parse(time.RFC3339, result.Expire)
parsedTime, err := time.Parse(time.RFC3339, result.Result.Expire)
if err != nil {
log.Fatal(err.Error())
}
Expand All @@ -132,9 +133,9 @@ var loginCmd = &cobra.Command{
Expiry time.Time `json:"expiry"`
}{
Token: token,
Email: result.Email,
Name: result.Profile["first_name"] + " " + result.Profile["last_name"],
User_ID: result.ID,
Email: result.Result.Email,
Name: result.Result.Profile.FirstName + " " + result.Result.Profile.LastName,
User_ID: result.Result.ID,
Expiry: parsedTime,
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Use: "Securelee-cli",
Version: "v1.1.6",
Version: "v1.1.7",
Short: "\nA CLI based Vault App for storing your Secret Messages or Keys Securely.",
Long: `A CLI based Vault App for storing your Secret Messages or Keys Securely.`,
// Uncomment the following line if your bare application
Expand All @@ -28,7 +28,7 @@ var rootCmd = &cobra.Command{

renderStr, _ := ascii.RenderOpts("Securelee.", options)
fmt.Print(renderStr)
fmt.Print(" > v1.1.6")
fmt.Print(" > v1.1.7")
},
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var versionCmd = &cobra.Command{
Short: "Version of the Securelee CLI.",
Long: `Version of the Securelee CLI.`,
Run: func(cmd *cobra.Command, args []string) {
color.Cyan("\n > Securelee - v1.1.6")
color.Cyan("\n > Securelee - v1.1.7")
fmt.Print("\n")
},
}
Expand Down
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@ go 1.20

require github.com/pangeacyber/pangea-go/pangea-sdk/v3 v3.0.0

require github.com/fatih/color v1.16.0
require github.com/fatih/color v1.16.0

require (
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-retryablehttp v0.7.2 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/joho/godotenv v1.5.1
github.com/mattn/go-colorable v0.1.13
github.com/mattn/go-colorable v0.1.13
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mbndr/figlet4go v0.0.0-20190224160619-d6cef5b186ea
github.com/pangeacyber/pangea-go/pangea-sdk v1.10.0
github.com/pangeacyber/pangea-go/pangea-sdk/v2 v2.3.0
github.com/rs/zerolog v1.29.1 // indirect
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWE
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mbndr/figlet4go v0.0.0-20190224160619-d6cef5b186ea h1:mQncVDBpKkAecPcH2IMGpKUQYhwowlafQbfkz2QFqkc=
github.com/mbndr/figlet4go v0.0.0-20190224160619-d6cef5b186ea/go.mod h1:QzTGLGoOqLHUBK8/EZ0v4Fa4CdyXmdyRwCHcl0YbeO4=
github.com/pangeacyber/pangea-go/pangea-sdk v1.10.0 h1:r7htbn5m56+4J8d5ZquCoBD6eRf80LmFQ4mEZfu3ttA=
github.com/pangeacyber/pangea-go/pangea-sdk v1.10.0/go.mod h1:TrRBjwbk83YhtHqCNsrMf//iz9yj/b3139mvts20qH0=
github.com/pangeacyber/pangea-go/pangea-sdk/v2 v2.3.0 h1:s72iLPWawcKFh8GO5eP1qev5Zp/VPGavYaqZ3CS3JWw=
github.com/pangeacyber/pangea-go/pangea-sdk/v2 v2.3.0/go.mod h1:VsuUoA8XBjZGMI8hu2UlWCBQau9enkisMdWr2AnxvqI=
github.com/pangeacyber/pangea-go/pangea-sdk/v3 v3.0.0 h1:24yIYHJ8iYUwt74+O9WRewwAgSYDQj2i6Ngkq81Q7jY=
Expand Down
44 changes: 22 additions & 22 deletions lib/init.go
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
package lib

import (
"log"
"os"

"github.com/joho/godotenv"
"github.com/pangeacyber/pangea-go/pangea-sdk/v2/pangea"
"github.com/pangeacyber/pangea-go/pangea-sdk/v2/service/authn"
"github.com/pangeacyber/pangea-go/pangea-sdk/v2/service/vault"
)

func Init() *authn.AuthN {
err := godotenv.Load(".env")
if err != nil {
log.Fatal("\033[31m", "Error loading .env file", "\033[0m")
}
// err := godotenv.Load(".env")
// if err != nil {
// log.Fatal("\033[31m", "Error loading .env file", "\033[0m")
// }
// Get token
token := os.Getenv("PANGEA_AUTHN_TOKEN")
if token == "" {
log.Fatal("\033[31m", "Unauthorized: No token present", "\033[0m")
}
// token := os.Getenv("PANGEA_AUTHN_TOKEN")
// if token == "" {
// log.Fatal("\033[31m", "Unauthorized: No token present", "\033[0m")
// }

token := "pts_xajlrac4we4mufoebqgejbrh2ieq72c4"
domain := "aws.us.pangea.cloud"
// Create config and client
client := authn.New(&pangea.Config{
Token: token,
Domain: os.Getenv("PANGEA_DOMAIN"),
Domain: domain,
})

return client
}

func InitVault() vault.Client {
err := godotenv.Load(".env")
if err != nil {
log.Fatal("\033[31m", "Error loading .env file", "\033[0m")
}
// err := godotenv.Load(".env")
// if err != nil {
// log.Fatal("\033[31m", "Error loading .env file", "\033[0m")
// }
// Get token
token := os.Getenv("PANGEA_VAULT_TOKEN")
if token == "" {
log.Fatal("\033[31m", "Unauthorized: No token present", "\033[0m")
}
// token := os.Getenv("PANGEA_VAULT_TOKEN")
// if token == "" {
// log.Fatal("\033[31m", "Unauthorized: No token present", "\033[0m")
// }
token := "pts_xajlrac4we4mufoebqgejbrh2ieq72c4"
domain := "aws.us.pangea.cloud"

// Create config and client
client := vault.New(&pangea.Config{
Token: token,
Domain: os.Getenv("PANGEA_DOMAIN"),
Domain: domain,
})

return client
Expand Down
Loading

0 comments on commit 4641e76

Please sign in to comment.