apply security audit
This commit is contained in:
@@ -23,7 +23,11 @@ function Login() {
|
||||
useEffect(() => {
|
||||
if (isAuthenticated) {
|
||||
setIsRedirecting(true);
|
||||
const from = (location.state as any)?.from || '/dashboard';
|
||||
const rawFrom = (location.state as any)?.from;
|
||||
const from =
|
||||
rawFrom && rawFrom.startsWith('/') && !rawFrom.startsWith('//')
|
||||
? rawFrom
|
||||
: '/dashboard';
|
||||
navigate(from, { replace: true });
|
||||
}
|
||||
}, [isAuthenticated, navigate, location.state]);
|
||||
@@ -31,10 +35,11 @@ function Login() {
|
||||
const handleLogin = () => {
|
||||
try {
|
||||
// Persist the intended destination so LoginCallback can restore it
|
||||
// after the full-page Authentik redirect round-trip
|
||||
const from = (location.state as any)?.from;
|
||||
if (from) {
|
||||
sessionStorage.setItem('auth_redirect_from', from);
|
||||
// after the full-page Authentik redirect round-trip.
|
||||
// Validate that from is a safe internal path before storing it.
|
||||
const rawFrom = (location.state as any)?.from;
|
||||
if (rawFrom && rawFrom.startsWith('/') && !rawFrom.startsWith('//')) {
|
||||
sessionStorage.setItem('auth_redirect_from', rawFrom);
|
||||
}
|
||||
const authUrl = authService.getAuthUrl();
|
||||
window.location.href = authUrl;
|
||||
|
||||
Reference in New Issue
Block a user