Skip to content

Commit 9a7d784

Browse files
thehandsomezebraStephanie Frantz
andauthored
Feature/add okta (#230)
* added support for Okta; changes are in conjunction with vaultkv * Update main.go * updated to use new vaultkv 0.5.0 tag @thomasmitchell added tag 0.5.0 for `vaultkv` -- safe is now ready. Co-authored-by: Stephanie Frantz <[email protected]>
1 parent 5bb4e2d commit 9a7d784

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,12 @@ To authenticate:
7070
safe auth [token]
7171
safe auth ldap
7272
safe auth github
73+
safe auth okta
7374
```
7475

7576
(Other authentication backends are not yet supported)
7677

77-
For each type (token, ldap or github), you will be prompted for
78+
For each type (token, ldap, okta or github), you will be prompted for
7879
the necessary credentials to authenticated against the Vault.
7980

8081
Usage

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.14
44

55
require (
66
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5
7-
github.com/cloudfoundry-community/vaultkv v0.4.0
7+
github.com/cloudfoundry-community/vaultkv v0.5.0
88
github.com/jhunt/go-ansi v0.0.0-20180630013815-403d5f0d9ccb
99
github.com/jhunt/go-cli v0.0.0-20170503201019-f04a1744b5e3
1010
github.com/jhunt/go-envirotron v0.0.0-20171017043611-8bdb90f72b39

main.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ func connect(auth bool) *vault.Vault {
7474
fmt.Fprintf(os.Stderr, "@R{You are not authenticated to a Vault.}\n")
7575
fmt.Fprintf(os.Stderr, "Try @C{safe auth ldap}\n")
7676
fmt.Fprintf(os.Stderr, " or @C{safe auth github}\n")
77+
fmt.Fprintf(os.Stderr, " or @C{safe auth okta}\n")
7778
fmt.Fprintf(os.Stderr, " or @C{safe auth token}\n")
7879
fmt.Fprintf(os.Stderr, " or @C{safe auth userpass}\n")
7980
fmt.Fprintf(os.Stderr, " or @C{safe auth approle}\n")
@@ -546,7 +547,7 @@ provided multiple times to provide multiple CA certificates.
546547
fmt.Fprintf(os.Stderr, "You will need to target a Vault manually first.\n\n")
547548
fmt.Fprintf(os.Stderr, "Try something like this:\n")
548549
fmt.Fprintf(os.Stderr, " @C{safe target ops https://address.of.your.vault}\n")
549-
fmt.Fprintf(os.Stderr, " @C{safe auth (github|token|ldap|userpass)}\n")
550+
fmt.Fprintf(os.Stderr, " @C{safe auth (github|token|ldap|okta|userpass)}\n")
550551
fmt.Fprintf(os.Stderr, "\n")
551552
os.Exit(1)
552553
}
@@ -1427,7 +1428,7 @@ written to STDOUT instead of STDERR to make it easier to consume.
14271428

14281429
r.Dispatch("auth", &Help{
14291430
Summary: "Authenticate to the current target",
1430-
Usage: "safe auth [--path <value>] (token|github|ldap|userpass|approle)",
1431+
Usage: "safe auth [--path <value>] (token|github|ldap|okta|userpass|approle)",
14311432
Description: `
14321433
Set the authentication token sent when talking to the Vault.
14331434
@@ -1436,6 +1437,7 @@ Supported auth backends are:
14361437
token Set the Vault authentication token directly.
14371438
github Provide a Github personal access (oauth) token.
14381439
ldap Provide LDAP user credentials.
1440+
okta Provide Okta user credentials.
14391441
userpass Provide a username and password registered with the UserPass backend.
14401442
approle Provide a client ID and client secret registered with the AppRole backend.
14411443
status Get information about current authentication status
@@ -1490,6 +1492,16 @@ Flags:
14901492
}
14911493
token = result.ClientToken
14921494

1495+
case "okta":
1496+
username := prompt.Normal("Okta username: ")
1497+
password := prompt.Secure("Password: ")
1498+
1499+
result, err := v.Client().Client.AuthOktaMount(authMount, username, password)
1500+
if err != nil {
1501+
return err
1502+
}
1503+
token = result.ClientToken
1504+
14931505
case "github":
14941506
accessToken := prompt.Secure("Github Personal Access Token: ")
14951507

0 commit comments

Comments
 (0)