Skip to content

Commit

Permalink
Use appSubUrl for OAuth2 callback URL tip (#28266)
Browse files Browse the repository at this point in the history
- 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: Gusted <postmaster@gusted.xyz>
  • Loading branch information
2 people authored and GiteaBot committed Nov 29, 2023
1 parent 5001f63 commit 547fbd5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions web_src/js/features/admin/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import $ from 'jquery';
import {checkAppUrl} from '../common-global.js';
import {hideElem, showElem, toggleElem} from '../../utils/dom.js';

const {csrfToken} = window.config;
const {csrfToken, appSubUrl} = window.config;

export function initAdminCommon() {
if ($('.page-content.admin').length === 0) {
Expand Down Expand Up @@ -172,7 +172,8 @@ export function initAdminCommon() {

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

Expand Down

0 comments on commit 547fbd5

Please sign in to comment.