Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

test(control-api): cover the bare-base half of the remote issuer check (F1-M1)

Diego Zacarias71b600bac2ca
diff --git a/control-api/package-lock.json b/control-api/package-lock.json
index 7b5b58711..f80598026 100644
--- a/control-api/package-lock.json
+++ b/control-api/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-api",
- "version": "0.1.790",
+ "version": "0.1.791",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-api",
- "version": "0.1.790",
+ "version": "0.1.791",
"dependencies": {
"@clerum/display-field": "file:../packages/display-field",
"@clerum/grok-provider-attempt-contract": "file:../packages/grok-provider-attempt-contract",
diff --git a/control-api/package.json b/control-api/package.json
index 1adfb726e..c42d871fd 100644
--- a/control-api/package.json
+++ b/control-api/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-api",
- "version": "0.1.790",
+ "version": "0.1.791",
"description": "Internal Clerum control plane REST API + UI for managing CRDs and secrets",
"main": "dist/main.js",
"engines": {
diff --git a/control-api/test/oauth.discovery.properties.test.ts b/control-api/test/oauth.discovery.properties.test.ts
index 1cd802c0b..22ac577f1 100644
--- a/control-api/test/oauth.discovery.properties.test.ts
+++ b/control-api/test/oauth.discovery.properties.test.ts
@@ -207,11 +207,11 @@ describe('issuer identity (RFC 8414 §3.3 / §2): no query, fragment or userinfo
// not interfere with the issuer comparison under test.
const base = 'https://as.example.com/p'
const [oauthUrl, oidcUrl] = asMetadataUrls(new URL(base))
- const prmJson = JSON.stringify({
- ...JSON.parse(PILOTS.sentry.prm.json),
- authorization_servers: [base],
- })
- const discoverWithIssuer = (issuer: string) => {
+ const discoverWithIssuer = (issuer: string, advertisedBase = base) => {
+ const prmJson = JSON.stringify({
+ ...JSON.parse(PILOTS.sentry.prm.json),
+ authorization_servers: [advertisedBase],
+ })
const asJson = JSON.stringify({ ...JSON.parse(PILOTS.sentry.as.json), issuer })
const pilot = {
...PILOTS.sentry,
@@ -242,6 +242,27 @@ describe('issuer identity (RFC 8414 §3.3 / §2): no query, fragment or userinfo
)
})
+ // The other half of the identity: a bare issuer against a decorated
+ // `authorization_servers[0]`. The well-known URLs derive from origin+path only, so
+ // the same metadata is served and only the base's own identifier shape can reject it.
+ it('a PRM authorization server decorated with a query or fragment, even an empty one, is issuer_mismatch', async () => {
+ await fc.assert(
+ fc.asyncProperty(fc.constantFrom('?', '#', '?q=1', '#f'), fc.string(), async (mark, tail) => {
+ const outcome = await discoverWithIssuer(base, `${base}${mark}${tail}`)
+ expect(outcome.ok).toBe(false)
+ if (!outcome.ok) expect(outcome.error.kind).toBe('issuer_mismatch')
+ })
+ )
+ })
+
+ it('a PRM authorization server with userinfo is issuer_mismatch', async () => {
+ for (const advertised of ['https://u:[email protected]/p', 'https://[email protected]/p']) {
+ const outcome = await discoverWithIssuer(base, advertised)
+ expect(outcome.ok).toBe(false)
+ if (!outcome.ok) expect(outcome.error.kind).toBe('issuer_mismatch')
+ }
+ })
+
it('an issuer with userinfo is issuer_mismatch', async () => {
for (const issuer of ['https://u:[email protected]/p', 'https://[email protected]/p']) {
const outcome = await discoverWithIssuer(issuer)