Hello,
I am developing public-facing features such as user sign-up and password reset functionalities. To achieve this, I need to allow anonymous users to interact with the backend to create or modify data. I have identified several possible approaches for data access, and I would like to seek clarity on which method is considered the most secure and appropriate according to Jmix best practices.
-
SystemAuthenticator+DataManager+SpecificPolicy
My understanding is that this is a layered approach. First, aSpecificPolicy(e.g.,resources = "public.sign-up") is assigned to theAnonymousRoleto grant entry-point access to the specific REST controller method. Second, within the controller method, the entire business logic (involvingDataManagercalls) is wrapped in asystemAuthenticator.runWithSystem(...)block to execute it with system-level privileges. - Using
DataManager.unconstrained()
This approach involves injecting the standardDataManagerand then calling the.unconstrained()method to bypass security constraints for a specific operation. However, it seems this still requires an authenticated user context to begin with, which is absent in a public API call. - Using the
UnconstrainedDataManagerbean
This involves directly injecting theUnconstrainedDataManager. I understand this is a legacy approach and is generally discouraged, but I would like to confirm its security implications compared to the other methods.
My Questions Is:
- Security Comparison: Which of these approaches provides the highest level of security for public APIs? What are the specific risks associated with each method?
-
Role of
SpecificPolicy: When usingSystemAuthenticator, is the primary role ofSpecificPolicysimply to allow the HTTP request to reach the controller method, while the actual data operations are secured by the system-level execution context? - Recommended Practice: For features like user sign-up and password reset, what is the officially recommended Jmix pattern?
Thank you in advance for your guidance.