diff options
author | Denys Konovalov <privat@denyskon.de> | 2023-06-05 09:00:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-05 15:00:12 +0800 |
commit | ca35dec18b3d3d7dd5cde4c69a10ae830961faf7 (patch) | |
tree | e52b1b9c3032aadd8b5fae7dabec88b0de7ef4b4 /routers | |
parent | 7d192cb674bc475b123c84b205aca821247c5dd1 (diff) | |
download | gitea-ca35dec18b3d3d7dd5cde4c69a10ae830961faf7.tar.gz gitea-ca35dec18b3d3d7dd5cde4c69a10ae830961faf7.zip |
Add ability to set multiple redirect URIs in OAuth application UI (#25072)
OAuth applications can already have multiple redirect URIs if
created/edited over API.
This change allows for setting multiple redirect URIs through the UI as
a comma-separated list (e. g.
`https://example.org/redirect,https://redirect.example.org`)
<details>
<summary>Screenshots</summary>
![Bildschirmfoto vom 2023-06-04
17-14-40](https://github.com/go-gitea/gitea/assets/47871822/2206dc32-e7e4-4953-9ecb-e098890b3f54)
![Bildschirmfoto vom 2023-06-04
17-14-50](https://github.com/go-gitea/gitea/assets/47871822/cd97c73c-9310-44ee-a83a-b927a1ef94da)
</details>
Closes #25068
Diffstat (limited to 'routers')
-rw-r--r-- | routers/web/user/setting/oauth2_common.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/routers/web/user/setting/oauth2_common.go b/routers/web/user/setting/oauth2_common.go index 5489b60260..5de0f0e22f 100644 --- a/routers/web/user/setting/oauth2_common.go +++ b/routers/web/user/setting/oauth2_common.go @@ -10,6 +10,7 @@ import ( "code.gitea.io/gitea/models/auth" "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/context" + "code.gitea.io/gitea/modules/util" "code.gitea.io/gitea/modules/web" "code.gitea.io/gitea/services/forms" ) @@ -40,7 +41,7 @@ func (oa *OAuth2CommonHandlers) AddApp(ctx *context.Context) { // TODO validate redirect URI app, err := auth.CreateOAuth2Application(ctx, auth.CreateOAuth2ApplicationOptions{ Name: form.Name, - RedirectURIs: []string{form.RedirectURI}, + RedirectURIs: util.SplitTrimSpace(form.RedirectURIs, "\n"), UserID: oa.OwnerID, ConfidentialClient: form.ConfidentialClient, }) @@ -93,7 +94,7 @@ func (oa *OAuth2CommonHandlers) EditSave(ctx *context.Context) { if ctx.Data["App"], err = auth.UpdateOAuth2Application(auth.UpdateOAuth2ApplicationOptions{ ID: ctx.ParamsInt64("id"), Name: form.Name, - RedirectURIs: []string{form.RedirectURI}, + RedirectURIs: util.SplitTrimSpace(form.RedirectURIs, "\n"), UserID: oa.OwnerID, ConfidentialClient: form.ConfidentialClient, }); err != nil { |