Class AdminSecurityServiceRemote
- All Implemented Interfaces:
AdminSecurityService,SecurityVerifier
- Converts the ServerSide AdminUser to a client level admin user with appropriate roles defined.
- Provides a method to check if the current logged in user matches the client side user and verifies whether that user has access to the entity operation they are trying to perform.
- Author:
- jfischer
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static enumHow a section crumb's entity relates to the next entity inwards. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringprotected final Map<String,Set<AdminSecurityServiceRemote.CrumbRelationship>> ResolvedAdminSecurityServiceRemote.CrumbRelationships keyed by "parentClass->childClass".protected org.broadleafcommerce.common.security.service.ExploitProtectionServiceprotected static final intDefensive ceiling oncrumbRelationshipCache.protected RowLevelSecurityServiceprotected AdminSecurityCheckExtensionManagerprotected AdminSecurityService -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidfindRelationships(jakarta.persistence.metamodel.Metamodel metamodel, jakarta.persistence.metamodel.ManagedType<?> type, Class<?> child, Set<AdminSecurityServiceRemote.CrumbRelationship> found, Set<Class<?>> visitedEmbeddables) protected Set<AdminSecurityServiceRemote.CrumbRelationship>getCrumbRelationships(String parent, String child) getRelatedSectionCrumbCeilings(PersistencePackage persistencePackage, EntityOperationType operationType) Returns the section crumb entities that may additionally authorize this request.protected booleanprotected booleanisCrumbHopAllowed(AdminSecurityServiceRemote.CrumbRelationship relationship, boolean readOnly, boolean finalHop, boolean adornedRequest) Whether one hop of the crumb chain may authorize the operation.protected booleanisReadOperation(EntityOperationType operationType) protected booleanprotected booleanisSameEntity(String parent, String child) protected Set<AdminSecurityServiceRemote.CrumbRelationship>resolveCrumbRelationships(String parent, String child) Determines from the JPA metamodel every kind of relationship any polymorphic implementation ofparenthas tochild(an entity can have several, e.g.protected voidsecurityCheck(String[] ceilingNames, EntityOperationType operationType) voidsecurityCheck(String ceilingEntityFullyQualifiedName, EntityOperationType operationType) voidsecurityCheck(PersistencePackage persistencePackage, EntityOperationType operationType)
-
Field Details
-
ANONYMOUS_USER_NAME
- See Also:
-
securityService
-
exploitProtectionService
protected org.broadleafcommerce.common.security.service.ExploitProtectionService exploitProtectionService -
rowLevelSecurityService
-
securityCheckExtensionManager
-
MAX_CRUMB_RELATIONSHIP_CACHE_SIZE
protected static final int MAX_CRUMB_RELATIONSHIP_CACHE_SIZEDefensive ceiling oncrumbRelationshipCache. Crumb identifiers are validated against the admin section / persistable-entity whitelist before they reach this service, so the key space is already bounded in practice; this cap guarantees the cache cannot grow without bound regardless of how it is populated.- See Also:
-
crumbRelationshipCache
protected final Map<String,Set<AdminSecurityServiceRemote.CrumbRelationship>> crumbRelationshipCacheResolvedAdminSecurityServiceRemote.CrumbRelationships keyed by "parentClass->childClass". Entity mappings don't change at runtime, so entries never need eviction for correctness;MAX_CRUMB_RELATIONSHIP_CACHE_SIZEonly bounds growth.
-
-
Constructor Details
-
AdminSecurityServiceRemote
public AdminSecurityServiceRemote()
-
-
Method Details
-
getAdminUser
- Specified by:
getAdminUserin interfaceAdminSecurityService- Throws:
org.broadleafcommerce.common.exception.ServiceException
-
getPersistentAdminUser
- Specified by:
getPersistentAdminUserin interfaceSecurityVerifier
-
securityCheck
public void securityCheck(PersistencePackage persistencePackage, EntityOperationType operationType) throws org.broadleafcommerce.common.exception.ServiceException - Specified by:
securityCheckin interfaceSecurityVerifier- Throws:
org.broadleafcommerce.common.exception.ServiceException
-
securityCheck
public void securityCheck(String ceilingEntityFullyQualifiedName, EntityOperationType operationType) throws org.broadleafcommerce.common.exception.ServiceException - Specified by:
securityCheckin interfaceSecurityVerifier- Throws:
org.broadleafcommerce.common.exception.ServiceException
-
securityCheck
protected void securityCheck(String[] ceilingNames, EntityOperationType operationType) throws org.broadleafcommerce.common.exception.ServiceException - Throws:
org.broadleafcommerce.common.exception.ServiceException
-
getRelatedSectionCrumbCeilings
protected List<String> getRelatedSectionCrumbCeilings(PersistencePackage persistencePackage, EntityOperationType operationType) Returns the section crumb entities that may additionally authorize this request.sectionCrumbscome straight from the client, so a crumb must never authorize a target it has nothing to do with (otherwise a permission on any one entity becomes a permission on every entity). A crumb only counts when the request target is genuinely reachable from it through mapped JPA relationships. Starting from the innermost crumb, each crumb must reach the next one inwards (and the innermost one the target) as allowed byisCrumbHopAllowed(org.broadleafcommerce.openadmin.server.security.remote.AdminSecurityServiceRemote.CrumbRelationship, boolean, boolean, boolean); the walk stops at the first crumb that doesn't, so neither an unrelated crumb nor anything in front of it is used.This keeps the legitimate uses of crumbs working: editing an entity's own collections (Product -> Skus), nested collection modals (Product -> Sku -> Sku media), adorned target collections (Product -> categories via CategoryProductXref) and read-only to-one lookups (Product.defaultCategory -> Category).
-
isCrumbHopAllowed
protected boolean isCrumbHopAllowed(AdminSecurityServiceRemote.CrumbRelationship relationship, boolean readOnly, boolean finalHop, boolean adornedRequest) Whether one hop of the crumb chain may authorize the operation.- Parameters:
finalHop- whether this hop reaches the request's own target (as opposed to a crumb nested inside it)adornedRequest- whether the server built this package for an adorned target collection
-
isReadOperation
-
isSameEntity
-
getCrumbRelationships
protected Set<AdminSecurityServiceRemote.CrumbRelationship> getCrumbRelationships(String parent, String child) -
resolveCrumbRelationships
protected Set<AdminSecurityServiceRemote.CrumbRelationship> resolveCrumbRelationships(String parent, String child) Determines from the JPA metamodel every kind of relationship any polymorphic implementation ofparenthas tochild(an entity can have several, e.g. Product has both the to-onedefaultCategoryand theallParentCategoryXrefsjoin collection to Category). Anything that can't be resolved (non-entity ceilings, unknown classes) yields an empty set, i.e. the crumb is not trusted. -
findRelationships
protected void findRelationships(jakarta.persistence.metamodel.Metamodel metamodel, jakarta.persistence.metamodel.ManagedType<?> type, Class<?> child, Set<AdminSecurityServiceRemote.CrumbRelationship> found, Set<Class<?>> visitedEmbeddables) -
hasToOne
-
isRelated
-