feat: allow M2M password resets when OIDC is enabled
The password reset endpoint was fully blocked under OIDC mode. Now M2M callers (identified by oidc: principal prefix) can reset local user passwords, enabling the SaaS platform to manage the server's built-in admin credentials. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -207,9 +207,14 @@ public class UserAdminController {
|
|||||||
@PathVariable String userId,
|
@PathVariable String userId,
|
||||||
@Valid @RequestBody SetPasswordRequest request,
|
@Valid @RequestBody SetPasswordRequest request,
|
||||||
HttpServletRequest httpRequest) {
|
HttpServletRequest httpRequest) {
|
||||||
|
// Block local UI users from resetting passwords when OIDC is enabled,
|
||||||
|
// but allow M2M callers (SaaS platform) identified by "oidc:" principal prefix
|
||||||
if (oidcEnabled) {
|
if (oidcEnabled) {
|
||||||
|
String caller = httpRequest.getUserPrincipal() != null ? httpRequest.getUserPrincipal().getName() : "";
|
||||||
|
if (!caller.startsWith("oidc:")) {
|
||||||
return ResponseEntity.badRequest().build();
|
return ResponseEntity.badRequest().build();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Extract bare username from "user:username" format for policy check
|
// Extract bare username from "user:username" format for policy check
|
||||||
String username = userId.startsWith("user:") ? userId.substring(5) : userId;
|
String username = userId.startsWith("user:") ? userId.substring(5) : userId;
|
||||||
List<String> violations = PasswordPolicyValidator.validate(request.password(), username);
|
List<String> violations = PasswordPolicyValidator.validate(request.password(), username);
|
||||||
|
|||||||
Reference in New Issue
Block a user