Skip to content

Commit 805c592

Browse files
Adito5393lunny
andauthored
Add CLI option tenant ID for oauth2 source (#22769) (#23263)
Backport #22769 Fixes #22713 Co-authored-by: Lunny Xiao <[email protected]>
1 parent b6eea68 commit 805c592

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

cmd/admin.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,11 @@ var (
161161
Value: "false",
162162
Usage: "Use custom URLs for GitLab/GitHub OAuth endpoints",
163163
},
164+
cli.StringFlag{
165+
Name: "custom-tenant-id",
166+
Value: "",
167+
Usage: "Use custom Tenant ID for OAuth endpoints",
168+
},
164169
cli.StringFlag{
165170
Name: "custom-auth-url",
166171
Value: "",
@@ -422,6 +427,7 @@ func parseOAuth2Config(c *cli.Context) *oauth2.Source {
422427
AuthURL: c.String("custom-auth-url"),
423428
ProfileURL: c.String("custom-profile-url"),
424429
EmailURL: c.String("custom-email-url"),
430+
Tenant: c.String("custom-tenant-id"),
425431
}
426432
} else {
427433
customURLMapping = nil
@@ -531,6 +537,7 @@ func runUpdateOauth(c *cli.Context) error {
531537
customURLMapping.AuthURL = oAuth2Config.CustomURLMapping.AuthURL
532538
customURLMapping.ProfileURL = oAuth2Config.CustomURLMapping.ProfileURL
533539
customURLMapping.EmailURL = oAuth2Config.CustomURLMapping.EmailURL
540+
customURLMapping.Tenant = oAuth2Config.CustomURLMapping.Tenant
534541
}
535542
if c.IsSet("use-custom-urls") && c.IsSet("custom-token-url") {
536543
customURLMapping.TokenURL = c.String("custom-token-url")
@@ -548,6 +555,10 @@ func runUpdateOauth(c *cli.Context) error {
548555
customURLMapping.EmailURL = c.String("custom-email-url")
549556
}
550557

558+
if c.IsSet("use-custom-urls") && c.IsSet("custom-tenant-id") {
559+
customURLMapping.Tenant = c.String("custom-tenant-id")
560+
}
561+
551562
oAuth2Config.CustomURLMapping = customURLMapping
552563
source.Cfg = oAuth2Config
553564

docs/content/doc/usage/command-line.en-us.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ Admin operations:
131131
- `--secret`: Client Secret.
132132
- `--auto-discover-url`: OpenID Connect Auto Discovery URL (only required when using OpenID Connect as provider).
133133
- `--use-custom-urls`: Use custom URLs for GitLab/GitHub OAuth endpoints.
134+
- `--custom-tenant-id`: Use custom Tenant ID for OAuth endpoints.
134135
- `--custom-auth-url`: Use a custom Authorization URL (option for GitLab/GitHub).
135136
- `--custom-token-url`: Use a custom Token URL (option for GitLab/GitHub).
136137
- `--custom-profile-url`: Use a custom Profile URL (option for GitLab/GitHub).
@@ -154,6 +155,7 @@ Admin operations:
154155
- `--secret`: Client Secret.
155156
- `--auto-discover-url`: OpenID Connect Auto Discovery URL (only required when using OpenID Connect as provider).
156157
- `--use-custom-urls`: Use custom URLs for GitLab/GitHub OAuth endpoints.
158+
- `--custom-tenant-id`: Use custom Tenant ID for OAuth endpoints.
157159
- `--custom-auth-url`: Use a custom Authorization URL (option for GitLab/GitHub).
158160
- `--custom-token-url`: Use a custom Token URL (option for GitLab/GitHub).
159161
- `--custom-profile-url`: Use a custom Profile URL (option for GitLab/GitHub).

0 commit comments

Comments
 (0)