Skip to content

Commit

Permalink
Merge pull request buildbot#7824 from tdesveaux/issue/7814
Browse files Browse the repository at this point in the history
www: Fix auth when Buildbot is not hosted at the URL's root
  • Loading branch information
p12tic authored Jul 17, 2024
2 parents b67a1f1 + dceac6e commit e2296b1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions newsfragments/fix-www-auth-reverseproxy-subpath.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix ReactUI authentication when Buildbot is hosted behind a reverse proxy not at url's root. (:issue:`7814`)
5 changes: 3 additions & 2 deletions www/base/src/components/Loginbar/Loginbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
import {useLocation} from "react-router-dom";
import {Nav, NavDropdown} from "react-bootstrap";
import {ConfigContext} from "buildbot-ui";
import { getBaseUrl } from 'buildbot-data-js';

function getAuthIcon(faIcon: string) {
switch (faIcon) {
Expand Down Expand Up @@ -56,7 +57,7 @@ export const Loginbar = () => {
return (
<Nav className="bb-loginbar-dropdown-nav">
<NavDropdown title="Anonymous" id="bb-loginbar-dropdown">
<NavDropdown.Item href={"/auth/login?redirect=" + encodeURI(redirect)}>
<NavDropdown.Item href={getBaseUrl(window.location, "auth/login?redirect=" + encodeURI(redirect))}>
{
config.auth.oauth2
? <span>
Expand Down Expand Up @@ -90,7 +91,7 @@ export const Loginbar = () => {
<Nav className="bb-loginbar-dropdown-nav">
<NavDropdown title={dropdownToggle} id="bb-loginbar-dropdown">
{userDropdownHeader}
<NavDropdown.Item href={"auth/logout?redirect=" + encodeURI(redirect)}>
<NavDropdown.Item href={getBaseUrl(window.location, "auth/logout?redirect=" + encodeURI(redirect))}>
<FaSignOutAlt/>
Logout
</NavDropdown.Item>
Expand Down

0 comments on commit e2296b1

Please sign in to comment.