Skip to content

Commit 84e65af

Browse files
GiteaBotearl-warrenGusted
authored
Use appSubUrl for OAuth2 callback URL tip (#28266) (#28275)
Backport #28266 by @earl-warren - When crafting the OAuth2 callbackURL take into account `appSubUrl`, which is quite safe given that its strictly formatted. - No integration testing as this is all done in Javascript. - Resolves https://codeberg.org/forgejo/forgejo/issues/1795 (cherry picked from commit 27cb6b7956136f87aa78067d9adb5a4c4ce28a24) Co-authored-by: Earl Warren <[email protected]> Co-authored-by: Gusted <[email protected]>
1 parent d2908b2 commit 84e65af

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

web_src/js/features/admin/common.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import $ from 'jquery';
22
import {checkAppUrl} from '../common-global.js';
33
import {hideElem, showElem, toggleElem} from '../../utils/dom.js';
44

5-
const {csrfToken} = window.config;
5+
const {csrfToken, appSubUrl} = window.config;
66

77
export function initAdminCommon() {
88
if ($('.page-content.admin').length === 0) {
@@ -172,7 +172,8 @@ export function initAdminCommon() {
172172

173173
if ($('.admin.authentication').length > 0) {
174174
$('#auth_name').on('input', function () {
175-
$('#oauth2-callback-url').text(`${window.location.origin}/user/oauth2/${encodeURIComponent($(this).val())}/callback`);
175+
// appSubUrl is either empty or is a path that starts with `/` and doesn't have a trailing slash.
176+
$('#oauth2-callback-url').text(`${window.location.origin}${appSubUrl}/user/oauth2/${encodeURIComponent($(this).val())}/callback`);
176177
}).trigger('input');
177178
}
178179

0 commit comments

Comments
 (0)