CLI support for OAuth sources custom icons (#14166)

Co-authored-by: Daniil Pankratov <daniil.pankratov@t-systems.com>
This commit is contained in:
Daniil Pankratov 2020-12-28 11:39:12 +03:00 committed by GitHub
parent d75f011345
commit 3175d08626
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View file

@ -282,6 +282,11 @@ var (
Value: "", Value: "",
Usage: "Use a custom Email URL (option for GitHub)", Usage: "Use a custom Email URL (option for GitHub)",
}, },
cli.StringFlag{
Name: "icon-url",
Value: "",
Usage: "Custom icon URL for OAuth2 login source",
},
} }
microcmdAuthUpdateOauth = cli.Command{ microcmdAuthUpdateOauth = cli.Command{
@ -606,6 +611,7 @@ func parseOAuth2Config(c *cli.Context) *models.OAuth2Config {
ClientSecret: c.String("secret"), ClientSecret: c.String("secret"),
OpenIDConnectAutoDiscoveryURL: c.String("auto-discover-url"), OpenIDConnectAutoDiscoveryURL: c.String("auto-discover-url"),
CustomURLMapping: customURLMapping, CustomURLMapping: customURLMapping,
IconURL: c.String("icon-url"),
} }
} }
@ -658,6 +664,10 @@ func runUpdateOauth(c *cli.Context) error {
oAuth2Config.OpenIDConnectAutoDiscoveryURL = c.String("auto-discover-url") oAuth2Config.OpenIDConnectAutoDiscoveryURL = c.String("auto-discover-url")
} }
if c.IsSet("icon-url") {
oAuth2Config.IconURL = c.String("icon-url")
}
// update custom URL mapping // update custom URL mapping
var customURLMapping = &oauth2.CustomURLMapping{} var customURLMapping = &oauth2.CustomURLMapping{}

View file

@ -114,6 +114,7 @@ Admin operations:
- `--custom-token-url`: Use a custom Token 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). - `--custom-profile-url`: Use a custom Profile URL (option for GitLab/GitHub).
- `--custom-email-url`: Use a custom Email URL (option for GitHub). - `--custom-email-url`: Use a custom Email URL (option for GitHub).
- `--icon-url`: Custom icon URL for OAuth2 login source.
- Examples: - Examples:
- `gitea admin auth add-oauth --name external-github --provider github --key OBTAIN_FROM_SOURCE --secret OBTAIN_FROM_SOURCE` - `gitea admin auth add-oauth --name external-github --provider github --key OBTAIN_FROM_SOURCE --secret OBTAIN_FROM_SOURCE`
- `update-oauth`: - `update-oauth`:
@ -129,6 +130,7 @@ Admin operations:
- `--custom-token-url`: Use a custom Token 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). - `--custom-profile-url`: Use a custom Profile URL (option for GitLab/GitHub).
- `--custom-email-url`: Use a custom Email URL (option for GitHub). - `--custom-email-url`: Use a custom Email URL (option for GitHub).
- `--icon-url`: Custom icon URL for OAuth2 login source.
- Examples: - Examples:
- `gitea admin auth update-oauth --id 1 --name external-github-updated` - `gitea admin auth update-oauth --id 1 --name external-github-updated`
- `add-ldap`: Add new LDAP (via Bind DN) authentication source - `add-ldap`: Add new LDAP (via Bind DN) authentication source