Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
c2ba1e2
feat(core): Global RBAC Initial commit
RVANDO12 Sep 29, 2026
0ca53eb
feat(core): Global RBAC - itegrate actions and rules
RVANDO12 Sep 29, 2026
573abae
feat(core): Global RBAC - update doc
RVANDO12 Sep 29, 2026
8a614d8
feat(core): Global RBAC - prepare step following
RVANDO12 Sep 29, 2026
f11fa24
feat(core): Global RBAC - cleaning logic
RVANDO12 Oct 2, 2026
5d895a8
feat(core): Global RBAC - vale issue
RVANDO12 Oct 2, 2026
c71a220
feat(core): Global RBAC - fix copilot issue
RVANDO12 Oct 5, 2026
ec085d8
feat(core): Global RBAC - fix copilot issue
RVANDO12 Oct 5, 2026
c2186cb
feat(core): Global RBAC - fix copilot issue
RVANDO12 Oct 5, 2026
5a5d669
fix: CBC-999 - remove useless security
RVANDO12 Oct 5, 2026
ef89757
feat(core): Global RBAC - fix test fail
RVANDO12 Oct 5, 2026
381c0b4
Merge branch 'main' into feat/RABC/step_1_global
RVANDO12 Oct 7, 2026
41f120f
Merge branch 'main' into feat/RABC/step_1_global
brandPittCode Oct 13, 2026
05125b4
feat(core): Global RBAC
brandPittCode Oct 15, 2026
858bc7b
Merge branch 'main' into feat/RABC/step_1_global
brandPittCode Oct 15, 2026
565e44f
feat(core): GLOBAL RBAC - update right matrix - add provisioning flag
brandPittCode Oct 20, 2026
e4a4866
feat(core): GLOBAL RBAC - update right matrix and principal provisioning
brandPittCode Oct 21, 2026
539099d
GLOBAL RBAC - update right matrix and principal provisioning
brandPittCode Oct 21, 2026
3319e54
GLOBAL RBAC - update right matrix and principal provisioning
brandPittCode Oct 21, 2026
226798c
GLOBAL RBAC - update right matrix and principal provisioning
brandPittCode Oct 21, 2026
bea2935
GLOBAL RBAC - update right matrix and principal provisioning
brandPittCode Oct 21, 2026
7783c56
GLOBAL RBAC - update right matrix and principal provisioning
brandPittCode Oct 22, 2026
8fc656e
GLOBAL RBAC - update right matrix and principal provisioning
brandPittCode Oct 22, 2026
140f179
Merge branch 'main' into feat/RABC/step_1_global
brandPittCode Oct 22, 2026
99eb49c
GLOBAL RBAC - update right matrix and principal provisioning
brandPittCode Oct 22, 2026
ad6fa99
GLOBAL RBAC - update right matrix and principal provisioning
brandPittCode Oct 23, 2026
94fd77e
feat(core): GLOBAL RBAC - update right matrix and principal provisioning
brandPittCode Oct 23, 2026
c946bf8
feat(core): GLOBAL RBAC - update right matrix and principal provisioning
brandPittCode Oct 23, 2026
5efe8f2
feat(core): GLOBAL RBAC - update right matrix and principal provisioning
brandPittCode Oct 23, 2026
5a5fd2a
feat(core): GLOBAL RBAC - update right matrix and principal provisioning
brandPittCode Oct 23, 2026
6dc8369
feat(core): GLOBAL RBAC - update right matrix and principal provisioning
brandPittCode Oct 23, 2026
8251b57
feat(core): GLOBAL RBAC - update right matrix and principal provisioning
brandPittCode Oct 23, 2026
44800d3
feat(core): GLOBAL RBAC - update right matrix and principal provisioning
brandPittCode Oct 23, 2026
8b7b9bc
feat(core): GLOBAL RBAC - update right matrix and principal provisioning
brandPittCode Oct 23, 2026
7175de8
feat(core): GLOBAL RBAC - update right matrix and principal provisioning
brandPittCode Oct 23, 2026
018aef6
feat(core): GLOBAL RBAC - update right matrix and principal provisioning
brandPittCode Oct 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed .mvn/wrapper/maven-wrapper.jar
Binary file not shown.
1,022 changes: 261 additions & 761 deletions docs/src/concepts/authentication.md

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions docs/src/concepts/entity-templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ An Entity Template defines:
- **Properties** - Data fields with types and validation rules
- **Relations** - Connections to other entity templates

The `principal` template is protected because its entities determine access to IDP-Core. Only catalog administrators can
create it.

```mermaid
classDiagram
class EntityTemplate {
Expand Down
5 changes: 2 additions & 3 deletions docs/src/contributing/code/exception-handling.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@ description: Global exception handling strategy and error response formats for I

## Error Response Format

At API level, always follow the same error response structure:
At API level, always follow the same error response structure, including errors written directly by security filters:

```json
{
"error": "NOT_FOUND",
"error_description": "Template with ID 'invalid-id' not found",
"timestamp": "2025-11-28T10:30:00Z"
"error_description": "Template with ID 'invalid-id' not found"
}
```
4 changes: 4 additions & 0 deletions docs/src/features/entity-dynamic-mapping.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ description: Understand Dynamic mappings and JSLT expressions.

A mapping targets one Entity Template and describes how to derive entity fields from the incoming JSON payload with a JSLT filter and entity projections. It is linked to a data integration configuration (Webhook, Kafka, etc) as it describes how to transform incoming payloads.

Only catalog administrators can create or update mappings that target the protected `principal` template. This
restriction prevents an ingestion mapping from changing principal privileges. Webhook deliveries that use an already
authorized mapping continue to run through the configured connector security strategy.

## Entity Dynamic Mapping Fields

| Field | Required | Description |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ public class ValidationMessages {
// Principal provisioning validation messages
public static final String PRINCIPAL_CREATION_FAILED = "Failed to create principal with identifier '%s'. The principal provider is currently unavailable. The system will automatically retry provisioning on the next request.";

// Authorization validation messages
public static final String AUTHORIZATION_VALUE_MUST_NOT_BE_NULL = "%s must not be null";

// Helper method to construct rules incompatibility message
public static String rulesAreIncompatible(String rule1, String rule2) {
return PROPERTY_RULES_MUTUALLY_EXCLUSIVE.replace("{rule1}", rule1).replace("{rule2}", rule2);
Expand All @@ -100,6 +103,9 @@ public static String minMaxConstraintViolated(String constraint) {
return PROPERTY_RULES_MIN_MAX_CONSTRAINT_VIOLATED.replace("{constraint}", constraint);
}

public static String authorizationValueMustNotBeNull(String fieldName) {
return AUTHORIZATION_VALUE_MUST_NOT_BE_NULL.formatted(fieldName);
}
// Pagination validation messages
public static final String PAGE_SIZE_TOO_LARGE = "Page size must not exceed %d";
public static final String PAGE_SIZE_NOT_INTEGER = "Page size must be an integer";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.decathlon.idp_core.domain.exception.authorization;

/// Indicates that a principal is not permitted to perform the requested operation.
public class PrincipalNotAuthorizedException extends RuntimeException {

private final String identifier;

/// Creates an authorization failure for the specified principal.
///
/// @param identifier the identifier of the principal denied access
public PrincipalNotAuthorizedException(String identifier) {
super("Principal '" + identifier + "' is not authorized to perform this operation");
this.identifier = identifier;
}

/// Returns the identifier of the principal denied access.
///
/// @return the principal identifier
public String getIdentifier() {
return identifier;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.decathlon.idp_core.domain.model.authorization;

/// CRUD operation requested against a platform resource.
public enum AuthorizationAction {
CREATE, READ, UPDATE, DELETE, UNSUPPORTED
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.decathlon.idp_core.domain.model.authorization;

/// Authorization strategies supported by the platform.
public enum AuthorizationMode {
GLOBAL, RBAC, ABAC
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.decathlon.idp_core.domain.model.authorization;

import java.util.Objects;
import java.util.Optional;
import java.util.Set;

import com.decathlon.idp_core.domain.constant.ValidationMessages;

/// Immutable authorization configuration used by domain authorization services.
public record AuthorizationPolicy(AuthorizationMode mode, Set<String> globalPrincipalIdentifiers,
Optional<String> requiredPrincipalProperty) {

public AuthorizationPolicy {
Objects.requireNonNull(mode, ValidationMessages.authorizationValueMustNotBeNull("mode"));
globalPrincipalIdentifiers = globalPrincipalIdentifiers != null
? Set.copyOf(globalPrincipalIdentifiers)
: Set.of();
Objects.requireNonNull(requiredPrincipalProperty,
ValidationMessages.authorizationValueMustNotBeNull("requiredPrincipalProperty"));
requiredPrincipalProperty = requiredPrincipalProperty.map(String::trim)
.filter(propertyName -> !propertyName.isBlank());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.decathlon.idp_core.domain.model.authorization;

import java.util.Objects;
import java.util.Optional;

import jakarta.validation.constraints.NotNull;

import com.decathlon.idp_core.domain.constant.ValidationMessages;
import com.decathlon.idp_core.domain.model.entity.Entity;
import com.decathlon.idp_core.domain.model.principal.PrincipalInfo;

/// Domain input describing a principal's request without infrastructure types.
public record AuthorizationRequest(@NotNull PrincipalInfo principal,
@NotNull Optional<Entity> principalEntity, @NotNull AuthorizationAction action,
@NotNull AuthorizationResource resource) {

public AuthorizationRequest {
Objects.requireNonNull(principal,
ValidationMessages.authorizationValueMustNotBeNull("principal"));
Objects.requireNonNull(principalEntity,
ValidationMessages.authorizationValueMustNotBeNull("principalEntity"));
Objects.requireNonNull(action, ValidationMessages.authorizationValueMustNotBeNull("action"));
Objects.requireNonNull(resource,
ValidationMessages.authorizationValueMustNotBeNull("resource"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.decathlon.idp_core.domain.model.authorization;

import java.util.Objects;
import java.util.Optional;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;

import com.decathlon.idp_core.domain.constant.ValidationMessages;

/// Identifies the resource and optional parent context for an authorization request.
public record AuthorizationResource(@NotBlank String type, @NotNull Optional<String> identifier,
@NotNull Optional<String> parentIdentifier) {

public static final String INBOUND_WEBHOOK_CONFIGURATION = "inbound_webhook_configuration";
public static final String ENTITY_DYNAMIC_MAPPING = "entity_dynamic_mapping";
public static final String ENTITY_TEMPLATE = "entity_template";
public static final String PRINCIPAL_TEMPLATE_IDENTIFIER = "principal";
public static final String PRINCIPAL_SELF = "principal_self";

public AuthorizationResource {
Objects.requireNonNull(type, ValidationMessages.authorizationValueMustNotBeNull("type"));
Objects.requireNonNull(identifier,
ValidationMessages.authorizationValueMustNotBeNull("identifier"));
Objects.requireNonNull(parentIdentifier,
ValidationMessages.authorizationValueMustNotBeNull("parentIdentifier"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.decathlon.idp_core.domain.port.audit;

/// Provides the authenticated identity associated with an audit revision.
public interface AuditIdentityProviderPort {

/// Returns the identifier recorded for the authenticated user.
///
/// @return authenticated user identifier
String getAuthId();

/// Returns the name associated with the authenticated user.
///
/// @return authenticated user name
String getName();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package com.decathlon.idp_core.domain.service.authorization;

import org.springframework.stereotype.Service;

import com.decathlon.idp_core.domain.exception.authorization.PrincipalNotAuthorizedException;
import com.decathlon.idp_core.domain.model.authorization.AuthorizationAction;
import com.decathlon.idp_core.domain.model.authorization.AuthorizationMode;
import com.decathlon.idp_core.domain.model.authorization.AuthorizationPolicy;
import com.decathlon.idp_core.domain.model.authorization.AuthorizationRequest;
import com.decathlon.idp_core.domain.model.authorization.AuthorizationResource;
import com.decathlon.idp_core.domain.model.entity.Entity;
import com.decathlon.idp_core.domain.model.principal.PrincipalKind;

/// Applies the global authorization policy to a principal request.
@Service
public class GlobalAuthorizationService {

private static final String IS_ADMIN_PROPERTY = "is_admin";
private static final String PRINCIPAL_TEMPLATE_IDENTIFIER = AuthorizationResource.PRINCIPAL_TEMPLATE_IDENTIFIER;
private static final String ENTITY_RESOURCE = "entity";
private static final String ENTITY_SEARCH_RESOURCE = "entity_search";
private static final String ENTITY_TEMPLATE_RESOURCE = AuthorizationResource.ENTITY_TEMPLATE;
private static final String PRINCIPAL_SELF_RESOURCE = AuthorizationResource.PRINCIPAL_SELF;

/// Applies the global authorization matrix, including the break-glass bypass.
///
/// @param request the principal and operation being authorized
/// @param policy the configured global authorization policy
/// @throws PrincipalNotAuthorizedException when the request is not permitted
public void authorize(AuthorizationRequest request, AuthorizationPolicy policy) {
String identifier = request.principal().identifier();
if (policy.mode() != AuthorizationMode.GLOBAL
|| request.action() == AuthorizationAction.UNSUPPORTED) {
throw new PrincipalNotAuthorizedException(identifier);
}

if (policy.globalPrincipalIdentifiers().contains(identifier)) {
return;
}

boolean catalogAdministrator = request.principalEntity().filter(this::isCatalogAdministrator)
.isPresent();
if (catalogAdministrator) {
return;
}

boolean missingConfiguredAccessProperty = request.principal().kind() == PrincipalKind.HUMAN
&& policy.requiredPrincipalProperty()
.map(propertyName -> request.principalEntity()
.filter(entity -> hasRequiredPrincipalProperty(entity, propertyName)).isEmpty())
.orElse(false);
if (missingConfiguredAccessProperty) {
throw new PrincipalNotAuthorizedException(identifier);
}

if (PRINCIPAL_SELF_RESOURCE.equals(request.resource().type())
&& request.action() == AuthorizationAction.READ) {
return;
}

boolean readOnlyResource = ENTITY_RESOURCE.equals(request.resource().type())
|| ENTITY_SEARCH_RESOURCE.equals(request.resource().type())
|| ENTITY_TEMPLATE_RESOURCE.equals(request.resource().type());
if (readOnlyResource && request.action() == AuthorizationAction.READ) {
return;
}

throw new PrincipalNotAuthorizedException(identifier);
}

private boolean isCatalogAdministrator(Entity principalEntity) {
return PRINCIPAL_TEMPLATE_IDENTIFIER.equals(principalEntity.templateIdentifier())
&& principalEntity.properties().stream()
.anyMatch(property -> IS_ADMIN_PROPERTY.equals(property.name())
&& Boolean.parseBoolean(property.value()));
}

private boolean hasRequiredPrincipalProperty(Entity principalEntity, String propertyName) {
return PRINCIPAL_TEMPLATE_IDENTIFIER.equals(principalEntity.templateIdentifier())
&& principalEntity.properties().stream()
.anyMatch(property -> propertyName.equals(property.name())
&& Boolean.parseBoolean(property.value()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.decathlon.idp_core.domain.model.entity.Property;
import com.decathlon.idp_core.domain.model.entity.Relation;
import com.decathlon.idp_core.domain.model.principal.PrincipalInfo;
import com.decathlon.idp_core.domain.model.principal.PrincipalKind;
import com.decathlon.idp_core.domain.port.EntityRepositoryPort;

import lombok.RequiredArgsConstructor;
Expand All @@ -36,6 +37,8 @@
public class PrincipalProvisioningService {

private static final String PRINCIPAL_TEMPLATE_IDENTIFIER = "principal";
private static final String KIND_PROPERTY = "kind";
private static final String IS_ADMIN_PROPERTY = "is_admin";

private final EntityRepositoryPort entityRepository;

Expand All @@ -57,14 +60,28 @@ public class PrincipalProvisioningService {
/// @return the provisioned Principal entity
@Transactional
public Entity provisionPrincipal(PrincipalInfo principalInfo) {
return provisionPrincipal(principalInfo, false);
}

/// Provisions a globally configured administrator principal.
///
/// @param principalInfo extracted authentication information for an
/// allow-listed principal
/// @return the provisioned Principal entity
@Transactional
public Entity provisionGlobalAdministrator(PrincipalInfo principalInfo) {
return provisionPrincipal(principalInfo, true);
}

private Entity provisionPrincipal(PrincipalInfo principalInfo, boolean isAdmin) {
Optional<Entity> existingPrincipal = entityRepository.findByTemplateIdentifierAndIdentifier(
PRINCIPAL_TEMPLATE_IDENTIFIER, principalInfo.identifier());

if (existingPrincipal.isPresent()) {
return existingPrincipal.get();
}

return createNewPrincipal(principalInfo);
return createNewPrincipal(principalInfo, isAdmin);
}

/// Retrieves a Principal entity by its identifier.
Expand All @@ -74,11 +91,30 @@ public Entity provisionPrincipal(PrincipalInfo principalInfo) {
/// @param identifier unique principal identifier
/// @return optional containing the principal entity
@Transactional(readOnly = true)
public Optional<Entity> getPrincipal(String identifier) {
public Optional<Entity> findPrincipal(String identifier) {
return entityRepository.findByTemplateIdentifierAndIdentifier(PRINCIPAL_TEMPLATE_IDENTIFIER,
identifier);
}

/// Retrieves a principal only when its stored kind matches the authenticated
/// actor.
///
/// @param principalInfo authenticated principal identity
/// @return matching principal entity, or empty when missing or of a different
/// kind
@Transactional(readOnly = true)
public Optional<Entity> findPrincipalWithSameKind(PrincipalInfo principalInfo) {
return entityRepository
.findByTemplateIdentifierAndIdentifier(PRINCIPAL_TEMPLATE_IDENTIFIER,
principalInfo.identifier())
.filter(entity -> hasMatchingKind(entity, principalInfo.kind()));
}

private boolean hasMatchingKind(Entity entity, PrincipalKind kind) {
return entity.properties().stream().anyMatch(
property -> KIND_PROPERTY.equals(property.name()) && kind.name().equals(property.value()));
}

/// Creates a new Principal entity in the catalog.
///
/// **Business logic:** Maps PrincipalInfo to entity properties and relations.
Expand All @@ -87,9 +123,10 @@ public Optional<Entity> getPrincipal(String identifier) {
///
/// @param principalInfo extracted authentication information
/// @return the newly created or existing Principal entity
private Entity createNewPrincipal(PrincipalInfo principalInfo) {
private Entity createNewPrincipal(PrincipalInfo principalInfo, boolean isAdmin) {
Entity newPrincipal = new Entity(null, PRINCIPAL_TEMPLATE_IDENTIFIER, principalInfo.name(),
principalInfo.identifier(), buildProperties(principalInfo), buildRelations(principalInfo));
principalInfo.identifier(), buildProperties(principalInfo, isAdmin),
buildRelations(principalInfo));
try {
return entityRepository.save(newPrincipal);
} catch (EntityAlreadyExistsException _) {
Expand All @@ -110,12 +147,14 @@ private Entity createNewPrincipal(PrincipalInfo principalInfo) {
///
/// @param principalInfo the principal information containing attributes
/// @return list of properties for the principal entity
private List<Property> buildProperties(PrincipalInfo principalInfo) {
private List<Property> buildProperties(PrincipalInfo principalInfo, boolean isAdmin) {
List<Property> properties = new ArrayList<>();
properties.add(new Property(null, "kind", principalInfo.kind().name()));
properties.add(new Property(null, KIND_PROPERTY, principalInfo.kind().name()));
properties.add(new Property(null, IS_ADMIN_PROPERTY, Boolean.toString(isAdmin)));

principalInfo.attributes().forEach((key, value) -> {
if (value != null && !value.isBlank()) {
if (!KIND_PROPERTY.equalsIgnoreCase(key) && !IS_ADMIN_PROPERTY.equalsIgnoreCase(key)
&& value != null && !value.isBlank()) {
properties.add(new Property(null, key, value));
}
});
Expand Down
Loading
Loading