Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions cmd/auth.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package cmd

import (
"fmt"

"github.com/pkg/browser"
"github.com/spf13/cobra"
)

var authUrl string

func init() {
RootCmd.AddCommand(authCmd)
authCmd.Flags().StringVarP(&authUrl, "url-override", "u", "", "Override the DCE login url")
}

var authCmd = &cobra.Command{
Use: "auth",
Short: "Login to dce",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("Opening web browser. Please login and copy/paste the provided credentials into this terminal.")

if authUrl == "" {
authUrl = *config.Auth.LoginUrl
}
browser.OpenURL(authUrl)
},
}
5 changes: 5 additions & 0 deletions configs/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ type admin struct {
MasterAccount *masterAccount
}

type auth struct {
LoginUrl *string
}

// Config contains config
type Config struct {
Admin *admin
Auth *auth
}
5 changes: 5 additions & 0 deletions example.dce.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Admin:
MasterAccount:
Profile: <insert .aws profile name>
Auth:
LoginUrl: https://<login-url>
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.13

require (
github.com/mitchellh/go-homedir v1.1.0
github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4
github.com/spf13/cobra v0.0.5
github.com/spf13/viper v1.4.0
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRW
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc=
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4 h1:49lOXmGaUpV9Fz3gd7TFZY106KVlPVa5jcYD1gaQf98=
github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4/go.mod h1:4OwLy04Bl9Ef3GJJCoec+30X3LQs/0/m4HFRt/2LUSA=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
Expand Down