aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdi <39572144+Adito5393@users.noreply.github.com>2023-03-06 11:20:07 +0100
committerGitHub <noreply@github.com>2023-03-06 18:20:07 +0800
commit805c5926ff3cbf325db0b7b9ed4e1b6179246ecf (patch)
tree2e245c65c83a78f6967f38efe441a25a80f5649c
parentb6eea680ce3516b8cc63a8c15356b9725f78e198 (diff)
downloadgitea-805c5926ff3cbf325db0b7b9ed4e1b6179246ecf.tar.gz
gitea-805c5926ff3cbf325db0b7b9ed4e1b6179246ecf.zip
Add CLI option tenant ID for oauth2 source (#22769) (#23263)
Backport #22769 Fixes #22713 Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
-rw-r--r--cmd/admin.go11
-rw-r--r--docs/content/doc/usage/command-line.en-us.md2
2 files changed, 13 insertions, 0 deletions
diff --git a/cmd/admin.go b/cmd/admin.go
index 3c09aa3175..59c100c644 100644
--- a/cmd/admin.go
+++ b/cmd/admin.go
@@ -162,6 +162,11 @@ var (
Usage: "Use custom URLs for GitLab/GitHub OAuth endpoints",
},
cli.StringFlag{
+ Name: "custom-tenant-id",
+ Value: "",
+ Usage: "Use custom Tenant ID for OAuth endpoints",
+ },
+ cli.StringFlag{
Name: "custom-auth-url",
Value: "",
Usage: "Use a custom Authorization URL (option for GitLab/GitHub)",
@@ -422,6 +427,7 @@ func parseOAuth2Config(c *cli.Context) *oauth2.Source {
AuthURL: c.String("custom-auth-url"),
ProfileURL: c.String("custom-profile-url"),
EmailURL: c.String("custom-email-url"),
+ Tenant: c.String("custom-tenant-id"),
}
} else {
customURLMapping = nil
@@ -531,6 +537,7 @@ func runUpdateOauth(c *cli.Context) error {
customURLMapping.AuthURL = oAuth2Config.CustomURLMapping.AuthURL
customURLMapping.ProfileURL = oAuth2Config.CustomURLMapping.ProfileURL
customURLMapping.EmailURL = oAuth2Config.CustomURLMapping.EmailURL
+ customURLMapping.Tenant = oAuth2Config.CustomURLMapping.Tenant
}
if c.IsSet("use-custom-urls") && c.IsSet("custom-token-url") {
customURLMapping.TokenURL = c.String("custom-token-url")
@@ -548,6 +555,10 @@ func runUpdateOauth(c *cli.Context) error {
customURLMapping.EmailURL = c.String("custom-email-url")
}
+ if c.IsSet("use-custom-urls") && c.IsSet("custom-tenant-id") {
+ customURLMapping.Tenant = c.String("custom-tenant-id")
+ }
+
oAuth2Config.CustomURLMapping = customURLMapping
source.Cfg = oAuth2Config
diff --git a/docs/content/doc/usage/command-line.en-us.md b/docs/content/doc/usage/command-line.en-us.md
index 9a7b2dd023..04604b0def 100644
--- a/docs/content/doc/usage/command-line.en-us.md
+++ b/docs/content/doc/usage/command-line.en-us.md
@@ -131,6 +131,7 @@ Admin operations:
- `--secret`: Client Secret.
- `--auto-discover-url`: OpenID Connect Auto Discovery URL (only required when using OpenID Connect as provider).
- `--use-custom-urls`: Use custom URLs for GitLab/GitHub OAuth endpoints.
+ - `--custom-tenant-id`: Use custom Tenant ID for OAuth endpoints.
- `--custom-auth-url`: Use a custom Authorization URL (option for GitLab/GitHub).
- `--custom-token-url`: Use a custom Token URL (option for GitLab/GitHub).
- `--custom-profile-url`: Use a custom Profile URL (option for GitLab/GitHub).
@@ -154,6 +155,7 @@ Admin operations:
- `--secret`: Client Secret.
- `--auto-discover-url`: OpenID Connect Auto Discovery URL (only required when using OpenID Connect as provider).
- `--use-custom-urls`: Use custom URLs for GitLab/GitHub OAuth endpoints.
+ - `--custom-tenant-id`: Use custom Tenant ID for OAuth endpoints.
- `--custom-auth-url`: Use a custom Authorization URL (option for GitLab/GitHub).
- `--custom-token-url`: Use a custom Token URL (option for GitLab/GitHub).
- `--custom-profile-url`: Use a custom Profile URL (option for GitLab/GitHub).