-
Task
-
Resolution: Done
-
Major
-
None
-
None
-
None
-
2020 Week 34-36 (from Aug 17)
Currently REST endpoints generate a protected policies() method which always resolves to the same body:
protected Policy[] policies(String user, List<String> groups) { if (user == null) { return new Policy[0]; } org.kie.kogito.auth.IdentityProvider identity = null; if (user != null) { identity = new org.kie.kogito.services.identity.StaticIdentityProvider(user, groups); } return new Policy[] { SecurityPolicy.of(identity) }; }
There are also isolated usages of the sole lines:
org.kie.kogito.auth.IdentityProvider identity = null; if (user != null) { identity = new org.kie.kogito.services.identity.StaticIdentityProvider(user, groups); }
Move this code to one or more utility classes that we invoke statically in the generated code.
Alternatively, if we want to retain "customizability", we can scaffold a separate class with the method
and invoke the method of that class. In this case, the class may be also @Singleton and @Inject'ed
e.g.:
@Singleton class MyProcessPolicies implements ProcessPolicies { public IdentityProvider identityProvider(String user, List<String> groups) { org.kie.kogito.auth.IdentityProvider identity = null; if (user != null) { identity = new org.kie.kogito.services.identity.StaticIdentityProvider(user, groups); } } public Policy[] of(String user, List<String> groups) { if (user == null) { return new Policy[0]; } org.kie.kogito.auth.IdentityProvider identity = identityProvider(user, groups); return new Policy[] { SecurityPolicy.of(identity) }; } } // usage: @Inject ProcessPolicies policies; org.kie.kogito.auth.IdentityProvider identity = policies.of(user, groups);
We should be able to generate this only once, and globally for all processes.
see also https://gist.github.com/evacchi/d0ee8b08d6fe97c909568a1ae24f4fd4 for a more comprehensive example
- is incorporated by
-
KOGITO-2455 Rework Kogito code generation for scaffolding (processes)
- Resolved
- is related to
-
KOGITO-2756 Processes: Hide implementation details of workItem handling
- Closed