Skip to content

Commit 01c8183

Browse files
authored
Add some comments for the case RS authentication fails when JWT introspection responses are requested. (#78)
1 parent ddecff7 commit 01c8183

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

src/main/java/com/authlete/jaxrs/server/api/IntrospectionEndpoint.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,20 @@ public Response post(
8282
// If failed to authenticate the resource server.
8383
if (authenticateResourceServer(rsEntity, credentials) == false)
8484
{
85+
// RFC 9701 mandates a "400 Bad Request" for unauthenticated introspection
86+
// requests as follows:
87+
//
88+
// Note: An AS compliant with this specification MUST refuse to serve
89+
// introspection requests that don't authenticate the caller and return
90+
// an HTTP status code 400. This is done to ensure token data is released
91+
// to legitimate recipients only and prevent downgrading to [RFC7662]
92+
// behavior (see Section 8.2).
93+
//
94+
// However, we return "401 Unauthorized" instead here.
95+
// While RFC 7662 leaves authentication details out of scope, we consider
96+
// 401 the semantically correct HTTP status for API caller authentication
97+
// failures and the standard behavior for protected endpoints.
98+
8599
// Return "401 Unauthorized".
86100
return Response.status(Status.UNAUTHORIZED).build();
87101
}

0 commit comments

Comments
 (0)