Skip to content

Commit c3e9dac

Browse files
committed
Fix issue with abac
1 parent cb5591d commit c3e9dac

File tree

7 files changed

+33
-559
lines changed

7 files changed

+33
-559
lines changed

.azure.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
SENTRIUS_VERSION=1.1.109
1+
SENTRIUS_VERSION=1.1.113
22
SENTRIUS_SSH_VERSION=1.1.12
33
SENTRIUS_KEYCLOAK_VERSION=1.1.15
44
SENTRIUS_AGENT_VERSION=1.1.24

api/src/main/java/io/sentrius/sso/controllers/api/documents/DocumentController.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,12 +377,20 @@ public ResponseEntity<DocumentDTO> retrieveFromExternal(
377377
String documentType = (String) retrievalRequest.get("documentType");
378378
String classification = (String) retrievalRequest.get("classification");
379379
String markings = (String) retrievalRequest.get("markings");
380+
381+
if (null == classification || classification.trim().isEmpty() || "UNCLASSIFIED".equalsIgnoreCase(classification)) {
382+
if (null == markings || markings.trim().isEmpty()) {
383+
classification = "PUBLIC";
384+
} else {
385+
classification = "PRIVATE";
386+
}
387+
}
380388

381389
@SuppressWarnings("unchecked")
382390
Map<String, String> options = (Map<String, String>) retrievalRequest.get("options");
383391

384-
log.info("Retrieving document from external source via integration-proxy: {}, store={}, user={}",
385-
sourceUrl, storeDocument, userId);
392+
log.info("Retrieving document from external source via integration-proxy: {}, store={}, user={}, classification={}, markings={}",
393+
sourceUrl, storeDocument, userId, classification, markings);
386394

387395
Document document = documentService.retrieveFromExternalSource(
388396
sourceUrl, options, storeDocument, documentName,

api/src/main/java/io/sentrius/sso/controllers/view/UserController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ public String listUsers(Model model) {
177177
@GetMapping("/edit")
178178
public String editUser(Model model, HttpServletRequest request, HttpServletResponse response,
179179
@RequestParam("userId") String userId) throws GeneralSecurityException {
180-
model.addAttribute("globalAccessSet", UserType.createSuperUser().getAccessSet());
180+
model.addAttribute("globalAccessSet", UserType.createSuperUser().getAccessSet().stream().filter(x -> !x.startsWith("CANNOT")).collect(Collectors.toSet()));
181181
var decryptedUserId = cryptoService.decrypt(userId);
182182
Long id = Long.parseLong(decryptedUserId);
183183
User user = userService.getUserById(id);

api/src/main/resources/templates/sso/data/sources.html

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ <h5 class="modal-title" id="retrieveExternalModalLabel">Retrieve External Data S
349349
<span class="tag-badge">${source.documentType}</span>
350350
${source.markings ? `<span class="marking-badge"><i class="fas fa-shield-alt"></i> ${escapeHtml(source.markings)}</span>` : ''}
351351
</div>
352-
${source.summary ? `<div class="source-summary">${escapeHtml(source.summary)}</div>` : ''}
352+
${source.summary ? `<div class="source-summary">${escapeHtmlLimitLength(source.summary, 50)}</div>` : ''}
353353
<div class="source-tags">
354354
${(source.tags || []).map(tag => `<span class="tag-badge"><i class="fas fa-tag"></i> ${escapeHtml(tag)}</span>`).join('')}
355355
</div>
@@ -483,6 +483,20 @@ <h5 class="modal-title" id="retrieveExternalModalLabel">Retrieve External Data S
483483
return div.innerHTML;
484484
}
485485

486+
function escapeHtmlLimitLength(text, maxLength = 50) {
487+
if (text == null) return "";
488+
489+
// Convert to string and trim to length
490+
const truncated =
491+
String(text).length > maxLength
492+
? String(text).slice(0, maxLength) + "…"
493+
: String(text);
494+
495+
const div = document.createElement("div");
496+
div.textContent = truncated; // safely escapes HTML
497+
return div.innerHTML;
498+
}
499+
486500
function formatDate(dateString) {
487501
if (!dateString) return '';
488502
const date = new Date(dateString);

dataplane/src/main/java/io/sentrius/sso/core/model/documents/Document.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,10 @@ public class Document {
5050
@Column(name = "tags")
5151
private String tags; // Comma-separated tags for categorization
5252

53+
// previously classified as UNCLASSIFIED, which are documents we assume are public or markings
54+
// that are nothing more than tags. If not PUBLIC, then we must enforce markings-based access control.
5355
@Column(name = "classification")
54-
private String classification = "UNCLASSIFIED";
56+
private String classification = "PUBLIC";
5557

5658
@Column(name = "markings")
5759
private String markings;

dataplane/src/main/java/io/sentrius/sso/core/services/documents/DocumentService.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public Document storeDocument(String documentName, String documentType, String c
8989
.content(content)
9090
.contentType(contentType != null ? contentType : "text/plain")
9191
.summary(summary)
92-
.classification(classification != null ? classification : "UNCLASSIFIED")
92+
.classification(classification != null ? classification : markings != null ? "PRIVATE" : "PUBLIC")
9393
.markings(markings)
9494
.createdBy(createdBy)
9595
.checksum(checksum)
@@ -671,12 +671,7 @@ public Document retrieveFromExternalSource(String sourceUrl, Map<String, String>
671671
log.info("Calling integration-proxy at: {}", url);
672672

673673
ResponseEntity<Map> response = (ResponseEntity<Map>) forwardRequest(url,HttpMethod.POST, request,
674-
Map.class); /*restTemplate.exchange(
675-
url,
676-
HttpMethod.POST,
677-
entity,
678-
Map.class
679-
);*/
674+
Map.class);
680675

681676
if (!response.getStatusCode().is2xxSuccessful() || response.getBody() == null) {
682677
throw new RuntimeException("Failed to retrieve document from integration-proxy");
@@ -709,7 +704,7 @@ public Document retrieveFromExternalSource(String sourceUrl, Map<String, String>
709704
finalContentType,
710705
"Retrieved from " + sourceUrl,
711706
null, // tags can be added later
712-
classification != null ? classification : "UNCLASSIFIED",
707+
classification != null ? classification : markings != null ? "PRIVATE" : "PUBLIC",
713708
markings,
714709
createdBy
715710
);

0 commit comments

Comments
 (0)