mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
In order to redirect the user after authentication, Authelia uses rd query parameter provided by the proxy. However an attacker could use phishing to make the user be redirected to a bad domain. In order to avoid the user to be redirected to a bad location, Authelia now verifies the redirection URL is under the protected domain.
10 lines
323 B
TypeScript
10 lines
323 B
TypeScript
import { BelongToDomain } from "../../../shared/BelongToDomain";
|
|
|
|
export function SafeRedirect(url: string, cb: () => void): void {
|
|
const domain = window.location.hostname.split(".").slice(-2).join(".");
|
|
if (url.startsWith("/") || BelongToDomain(url, domain)) {
|
|
window.location.href = url;
|
|
return;
|
|
}
|
|
cb();
|
|
} |