Skip to content

fix/improve-rest-apis#67

Merged
marioserrano09 merged 3 commits into
mainfrom
fix/improve-rest-apis
May 25, 2026
Merged

fix/improve-rest-apis#67
marioserrano09 merged 3 commits into
mainfrom
fix/improve-rest-apis

Conversation

@marioserrano09
Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings May 25, 2026 15:19
@marioserrano09 marioserrano09 merged commit ae1e0d8 into main May 25, 2026
1 check passed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR tightens REST-side class resolution to an allowlist and improves SaaS account API responses/auth checks, while extending SimpleCache with map-like operations.

Changes:

  • Add put / putIfAbsent convenience methods to SimpleCache.
  • Restrict AbstractCrudServiceRestController entity class loading to classes discovered from CRUD view descriptors (allowlist).
  • Update SaaS AccountApiController endpoints to return ResponseEntity and enforce authorization/same-account checks.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

File Description
platform/core/commons/src/main/java/tools/dynamia/commons/SimpleCache.java Adds map-style write APIs (put, putIfAbsent) to the cache.
platform/app/src/main/java/tools/dynamia/app/controllers/AbstractCrudServiceRestController.java Introduces an allowlist cache for entity classes based on CRUD descriptors and blocks non-allowed classes.
extensions/saas/sources/core/src/main/java/tools/dynamia/modules/saas/controllers/AccountApiController.java Adds authorization checks and switches responses to typed ResponseEntity payloads.

* @param value
*/
public void put(K key, V value) {
data.put(key, value);
*/
private final JsonMapper mapper = StringPojoParser.createJsonMapper();

private SimpleCache<String, Class> allowedClasses = new SimpleCache<>();
Comment on lines +174 to 183
private void initAllowedClasses() {
if (allowedClasses == null || allowedClasses.isEmpty()) {
ViewDescriptorFactory viewDescriptorFactory = Containers.get().findObject(ViewDescriptorFactory.class);
if (viewDescriptorFactory != null) {
viewDescriptorFactory.findDescriptorsByType("crud").forEach(d -> {
var entityClass = d.getKey();
allowedClasses.add(entityClass.getName(), entityClass);
});
}
}
initAllowedClasses();
Class entityClass = allowedClasses.get(className);
if (entityClass == null) {
throw new ValidationError("Class not allowed: " + className);
Comment on lines +175 to +177
public boolean isSameAccount(String uuid, HttpServletRequest request) {
var subdomain = HttpUtils.getSubdomain(request);
var currentAccount = service.getAccount(subdomain);
Comment on lines +167 to +173
public boolean isAuthorized(HttpServletRequest request) {
if (serviceAPI.getSystemAccountId().equals(serviceAPI.getCurrentAccountId())) {
return true;
}

return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants