Skip to content

Commit 5b63dd6

Browse files
committed
client: require that the resource returned by PRM matches the server resource
1 parent 617facc commit 5b63dd6

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/client/auth.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ export async function auth(
110110
if (resourceMetadata.authorization_servers && resourceMetadata.authorization_servers.length > 0) {
111111
authorizationServerUrl = resourceMetadata.authorization_servers[0];
112112
}
113+
if (!resourceMetadata.resource || resourceMetadata.resource !== resource.href) {
114+
throw new Error(`Resource returned by RFC9728 PRM (${resourceMetadata.resource}) doesn't match the expected resource ${resource.href}`);
115+
}
113116
} catch (error) {
114117
console.warn("Could not load OAuth Protected Resource metadata, falling back to /.well-known/oauth-authorization-server", error)
115118
}

0 commit comments

Comments
 (0)