fix(security): use generic forbidden message to avoid leaking required role
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -35,7 +35,7 @@ public class HouseholdRoleInterceptor implements HandlerInterceptor {
|
|||||||
|
|
||||||
String actualRole = householdResolver.resolveRole(auth.getName());
|
String actualRole = householdResolver.resolveRole(auth.getName());
|
||||||
if (!annotation.value().equals(actualRole)) {
|
if (!annotation.value().equals(actualRole)) {
|
||||||
throw new ForbiddenException("Requires household role: " + annotation.value());
|
throw new ForbiddenException("Insufficient permissions");
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ class HouseholdRoleInterceptorTest {
|
|||||||
|
|
||||||
assertThatThrownBy(() -> interceptor.preHandle(request, response, handlerMethod))
|
assertThatThrownBy(() -> interceptor.preHandle(request, response, handlerMethod))
|
||||||
.isInstanceOf(ForbiddenException.class)
|
.isInstanceOf(ForbiddenException.class)
|
||||||
.hasMessageContaining("planner");
|
.hasMessage("Insufficient permissions");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user