@fabrika/proxy-core 0.9.0-dev.20 → 0.9.0-dev.22
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/package.json +4 -4
- package/src/authorize.ts +22 -2
- package/src/iam.ts +2 -0
- package/types/src/authorize.d.ts +4 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fabrika/proxy-core",
|
|
3
|
-
"version": "0.9.0-dev.
|
|
3
|
+
"version": "0.9.0-dev.22",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -48,9 +48,9 @@
|
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"zod": "^3.25.76",
|
|
51
|
-
"@fabrika/auth-core": "0.9.0-dev.
|
|
52
|
-
"@fabrika/jwks": "0.9.0-dev.
|
|
51
|
+
"@fabrika/auth-core": "0.9.0-dev.22",
|
|
52
|
+
"@fabrika/jwks": "0.9.0-dev.22",
|
|
53
53
|
"jose": "^5.9.0",
|
|
54
|
-
"@fabrika/platform": "0.9.0-dev.
|
|
54
|
+
"@fabrika/platform": "0.9.0-dev.22"
|
|
55
55
|
}
|
|
56
56
|
}
|
package/src/authorize.ts
CHANGED
|
@@ -29,6 +29,10 @@ import {
|
|
|
29
29
|
FORM_MULTIPART_TYPE,
|
|
30
30
|
FORM_URLENCODED_TYPE,
|
|
31
31
|
formatEndpointHeader,
|
|
32
|
+
isLocale,
|
|
33
|
+
type Locale,
|
|
34
|
+
LOCALE_COOKIE,
|
|
35
|
+
LOCALE_PARAM,
|
|
32
36
|
planEndpoint,
|
|
33
37
|
sameOriginTarget,
|
|
34
38
|
satisfies,
|
|
@@ -650,7 +654,7 @@ export class Authorizer {
|
|
|
650
654
|
return {
|
|
651
655
|
outcome: 'login',
|
|
652
656
|
status: isDocumentNavigation(request.headers) ? 302 : 401,
|
|
653
|
-
location: this.loginUrl(app, request.url, handoff),
|
|
657
|
+
location: this.loginUrl(app, request.url, signInLocale(request.headers), handoff),
|
|
654
658
|
reason,
|
|
655
659
|
handoff,
|
|
656
660
|
}
|
|
@@ -662,8 +666,12 @@ export class Authorizer {
|
|
|
662
666
|
* The scheme comes from the MANIFEST, not from the forwarded request: behind a TLS-terminating
|
|
663
667
|
* balancer the proxy is reached over plain HTTP and `X-Forwarded-Proto` says so, which would send
|
|
664
668
|
* the browser back to an `http://` URL for an origin only served over `https://`.
|
|
669
|
+
*
|
|
670
|
+
* `locale` is the language the application left for this browser on its host (`signInLocale`), passed on as IAM's
|
|
671
|
+
* `?locale=` so the first sign-in page speaks it. It picks IAM's words only: the decision, the return URL and the
|
|
672
|
+
* handoff are the same without it.
|
|
665
673
|
*/
|
|
666
|
-
private loginUrl(app: ProxyApp, url: URL, handoff: HandoffAttempt): string {
|
|
674
|
+
private loginUrl(app: ProxyApp, url: URL, locale: Locale | null, handoff: HandoffAttempt): string {
|
|
667
675
|
const target = new URL(url)
|
|
668
676
|
target.protocol = `${app.scheme}:`
|
|
669
677
|
// `readProxyEnv` already reduces the issuer to an origin; this covers a composition root that
|
|
@@ -672,6 +680,9 @@ export class Authorizer {
|
|
|
672
680
|
const login = new URL('/auth/login', issuer)
|
|
673
681
|
login.searchParams.set('app', audienceOf(app))
|
|
674
682
|
login.searchParams.set(LOGIN_REDIRECT_PARAM, target.toString())
|
|
683
|
+
if (locale !== null) {
|
|
684
|
+
login.searchParams.set(LOCALE_PARAM, locale)
|
|
685
|
+
}
|
|
675
686
|
setHandoffParams(login, handoff)
|
|
676
687
|
return login.toString()
|
|
677
688
|
}
|
|
@@ -690,6 +701,15 @@ function admittedOrigin(app: ProxyApp, row: ManifestEndpointRow, origin: string)
|
|
|
690
701
|
return form === 'environment' && isApplicationEntry(app) && (app.crossOrigins ?? []).includes(origin) ? origin : null
|
|
691
702
|
}
|
|
692
703
|
|
|
704
|
+
/**
|
|
705
|
+
* The language an application left for this browser in `LOCALE_COOKIE` on its own host, or null for none or for a
|
|
706
|
+
* value IAM does not speak. A client can set it, which is why it only ever picks words on IAM's sign-in page.
|
|
707
|
+
*/
|
|
708
|
+
function signInLocale(headers: Headers): Locale | null {
|
|
709
|
+
const value = readCookie(headers.get('Cookie'), LOCALE_COOKIE)
|
|
710
|
+
return isLocale(value) ? value : null
|
|
711
|
+
}
|
|
712
|
+
|
|
693
713
|
/** Whether a redeemed code's return URL is on the host the callback arrived at, and that host is one of the entry's. */
|
|
694
714
|
function returnsToHost(app: ProxyApp, callback: URL, returnUrl: string): boolean {
|
|
695
715
|
const target = URL.canParse(returnUrl) ? new URL(returnUrl) : null
|
package/src/iam.ts
CHANGED
|
@@ -214,6 +214,8 @@ export class HttpIamGateway implements IamGateway, DelegationIssuer {
|
|
|
214
214
|
headers,
|
|
215
215
|
body,
|
|
216
216
|
signal: AbortSignal.timeout(this.timeoutMs),
|
|
217
|
+
// The proxy key and the credential in the body must never reach a redirect target; a 3xx is not ok below.
|
|
218
|
+
redirect: 'manual',
|
|
217
219
|
})
|
|
218
220
|
} catch {
|
|
219
221
|
// Deliberately swallow the cause: a fetch error stringifies the request URL and, on some
|
package/types/src/authorize.d.ts
CHANGED
|
@@ -248,6 +248,10 @@ export declare class Authorizer {
|
|
|
248
248
|
* The scheme comes from the MANIFEST, not from the forwarded request: behind a TLS-terminating
|
|
249
249
|
* balancer the proxy is reached over plain HTTP and `X-Forwarded-Proto` says so, which would send
|
|
250
250
|
* the browser back to an `http://` URL for an origin only served over `https://`.
|
|
251
|
+
*
|
|
252
|
+
* `locale` is the language the application left for this browser on its host (`signInLocale`), passed on as IAM's
|
|
253
|
+
* `?locale=` so the first sign-in page speaks it. It picks IAM's words only: the decision, the return URL and the
|
|
254
|
+
* handoff are the same without it.
|
|
251
255
|
*/
|
|
252
256
|
private loginUrl;
|
|
253
257
|
}
|