@robosystems/core 0.11.3 → 0.11.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/auth-core/sso.js +7 -18
- package/package.json +1 -1
package/auth-core/sso.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
2
|
import { RoboSystemsAuthClient } from './client';
|
|
3
3
|
import { APP_CONFIGS } from './config';
|
|
4
|
+
import { isSafeRelativePath } from './login-home';
|
|
4
5
|
// Configuration constants
|
|
5
6
|
const NAVIGATION_DELAY_MS = 100; // 100ms delay for navigation
|
|
6
7
|
// Debug logging helper
|
|
@@ -12,25 +13,13 @@ const debugLog = (message, error) => {
|
|
|
12
13
|
/**
|
|
13
14
|
* Reduce a `returnUrl` to a same-origin path, or reject it.
|
|
14
15
|
*
|
|
15
|
-
* The value reaches us from a query parameter
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* app, which resolves it against its own origin — so a bare absolute path is
|
|
21
|
-
* the only shape we ever legitimately produce.
|
|
16
|
+
* The value reaches us from a query parameter, so it is attacker-controlled
|
|
17
|
+
* on any crafted link. Cross-app returns don't need anything but a bare
|
|
18
|
+
* absolute path — `getSSORedirectUrl` hands the path to the *target* app,
|
|
19
|
+
* which resolves it against its own origin. The check is the package's one
|
|
20
|
+
* validator, `isSafeRelativePath` (shared with the login home).
|
|
22
21
|
*/
|
|
23
|
-
const sanitizeReturnUrl = (returnUrl) =>
|
|
24
|
-
if (!returnUrl)
|
|
25
|
-
return null;
|
|
26
|
-
// `//host` and `/\host` are both protocol-relative once a browser
|
|
27
|
-
// normalises them, so a leading slash alone isn't enough.
|
|
28
|
-
if (!returnUrl.startsWith('/'))
|
|
29
|
-
return null;
|
|
30
|
-
if (returnUrl.startsWith('//') || returnUrl.startsWith('/\\'))
|
|
31
|
-
return null;
|
|
32
|
-
return returnUrl;
|
|
33
|
-
};
|
|
22
|
+
const sanitizeReturnUrl = (returnUrl) => returnUrl && isSafeRelativePath(returnUrl) ? returnUrl : null;
|
|
34
23
|
/** Keys an older version wrote; cleared on every handoff completion. */
|
|
35
24
|
const LEGACY_SSO_HINT_KEYS = ['sso_target_app', 'sso_return_url'];
|
|
36
25
|
const clearLegacySsoHints = () => {
|
package/package.json
CHANGED