Skip to content

Commit 8918b67

Browse files
committed
TUN-8871: Accept login flag to authenticate with Fedramp environment
## Summary Some description... Closes TUN-8871
1 parent 25c3f67 commit 8918b67

File tree

1 file changed

+42
-4
lines changed

1 file changed

+42
-4
lines changed

cmd/cloudflared/tunnel/login.go

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,32 @@ import (
1919
)
2020

2121
const (
22-
baseLoginURL = "https://dash.cloudflare.com/argotunnel"
23-
callbackStoreURL = "https://login.cloudflareaccess.org/"
22+
baseLoginURL = "https://dash.cloudflare.com/argotunnel"
23+
callbackURL = "https://login.cloudflareaccess.org/"
24+
// For now these are the same but will change in the future once we know which URLs to use (TUN-8872)
25+
fedBaseLoginURL = "https://dash.cloudflare.com/argotunnel"
26+
fedCallbackStoreURL = "https://login.cloudflareaccess.org/"
27+
fedRAMPParamName = "fedramp"
28+
loginURLParamName = "loginURL"
29+
callbackURLParamName = "callbackURL"
30+
)
31+
32+
var (
33+
loginURL = &cli.StringFlag{
34+
Name: loginURLParamName,
35+
Value: baseLoginURL,
36+
Usage: "The URL used to login (default is https://dash.cloudflare.com/argotunnel)",
37+
}
38+
callbackStore = &cli.StringFlag{
39+
Name: callbackURLParamName,
40+
Value: callbackURL,
41+
Usage: "The URL used for the callback (default is https://login.cloudflareaccess.org/)",
42+
}
43+
fedramp = &cli.BoolFlag{
44+
Name: fedRAMPParamName,
45+
Aliases: []string{"f"},
46+
Usage: "Login with FedRAMP High environment.",
47+
}
2448
)
2549

2650
func buildLoginSubcommand(hidden bool) *cli.Command {
@@ -30,6 +54,11 @@ func buildLoginSubcommand(hidden bool) *cli.Command {
3054
Usage: "Generate a configuration file with your login details",
3155
ArgsUsage: " ",
3256
Hidden: hidden,
57+
Flags: []cli.Flag{
58+
loginURL,
59+
callbackStore,
60+
fedramp,
61+
},
3362
}
3463
}
3564

@@ -44,9 +73,18 @@ func login(c *cli.Context) error {
4473
return err
4574
}
4675

47-
loginURL, err := url.Parse(baseLoginURL)
76+
var (
77+
baseloginURL = c.String(loginURLParamName)
78+
callbackStoreURL = c.String(callbackURLParamName)
79+
)
80+
81+
if c.Bool(fedRAMPParamName) {
82+
baseloginURL = fedBaseLoginURL
83+
callbackStoreURL = fedCallbackStoreURL
84+
}
85+
86+
loginURL, err := url.Parse(baseloginURL)
4887
if err != nil {
49-
// shouldn't happen, URL is hardcoded
5088
return err
5189
}
5290

0 commit comments

Comments
 (0)