Token Substitution
Enabling the defence
import { defineConfig } from "vite";
import { oidcSpa } from "oidc-spa/vite-plugin";
export default defineConfig({
plugins: [
// ...
oidcSpa({
// ...
browserRuntimeFreeze: { enabled: true, /*exclude: [...]*/ }, //Recommended
tokenSubstitution: {
enabled: true,
// Optional, see below
trustedExternalResourceServers: [
"*.{{location.hostname}}",
"s3.amazonaws.com"
]
}
})
]
});import { oidcEarlyInit } from "oidc-spa/entrypoint";
import { browserRuntimeFreeze } from 'oidc-spa/browser-runtime-freeze';
import { tokenSubstitution } from 'oidc-spa/token-substitution';
const { shouldLoadApp } = oidcEarlyInit({
BASE_URL: "/",
securityDefenses: {
...browserRuntimeFreeze(/*{ exclude: [...] }*/), // Recommended
...tokenSubstitution({
// Optional, see below
trustedExternalResourceServers: [
`*.${location.hostname}`,
"s3.amazonaws.com"
]
})
}
});
if (shouldLoadApp) {
import("./main.lazy");
}Understanding the defence
What this blocks
How requests still work
Compared to DPoP
Requirements (can I enable it?)
trustedExternalResourceServers
What to put in the list
Example
Last updated
Was this helpful?