JHipster generated RBAC least-privilege and credential expiration diagnosis
0 reputation · 27 Feb 2020, 01:03 UTC
0 reputation · 27 Feb 2020, 01:03 UTC
JHipster scaffolds Spring Security with authorities and roles derived from the generated user management domain, supporting role based access control for least privilege. Authentication type is selected at generation time, typically JWT stateless or OAuth2 OIDC session based, which determines token issuance and validation behavior in the generated backend.
The generated user entity and security configuration do not include password expiration, rotation enforcement or credential age checks by default. In JWT based setups the generated backend is stateless by default, so token revocation and immediate invalidation on credential change require design beyond the scaffold. JHipster generates URL security and method security annotations but does not prescribe a consistent enforcement scope.
Clarification is needed on default credential lifecycle handling and where least privilege enforcement is intended to be applied in a generated application.
Does the generated backend provide any default checks for expired credentials or password age, and where would such checks be added in the scaffold? For JWT versus OIDC generation, how does the scaffold handle token invalidation after a credential change? Is least privilege enforcement intended to be applied at the web layer, service layer, or both?
The JHipster generated backend does not provide default checks for expired credentials or password age. The scaffolded User entity lacks the necessary timestamp fields (such as passwordChangedDate) required to calculate credential age or enforce rotation policies.
The mechanism for handling credential changes depends entirely on the authentication type selected during generation:
To add credential age checks, you must manually extend the scaffold:
Instant passwordChangedAt field to the User entity.AuthenticationProvider or a OncePerRequestFilter to compare the current date against this timestamp.AccessDeniedException or a specific 401 error when the threshold is exceeded.In a default JHipster generation, least privilege enforcement is primarily applied at the web layer. This is achieved through SecurityConfiguration.java (URL-based security) and @PreAuthorize annotations on Controller methods.
While the scaffold supports method-level security, it does not automatically apply it to the service layer. For a true least-privilege architecture, you should manually move or duplicate @PreAuthorize annotations to the service layer to ensure that internal method calls—not just HTTP requests—are authorized.
To verify the current state of your scaffold, run these checks:
User.java for any fields tracking password age.@PreAuthorize is present in your Service classes; if only present in Resource classes, enforcement is web-layer only.Missing Diagnostic Detail: Are you using a custom JDL (JHipster Domain Language) to define granular authorities, or are you relying on the default ROLE_USER and ROLE_ADMIN roles?
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.