Skip to main content

Implementing Authorization

How Authorization Works

When a component requests an operation, the SecurityManager.authorize method is invoked. It is passed the principal of the operation's requester and a ResourcePermission, which describes the operation requested.

The implementation of the SecurityManager.authorize method makes a decision as to whether the principal will be granted permission to carry out the operation. It returns a boolean in which a return value of true permits the operation, and a return value of false prevents the operation. The operation can also throw an AuthenticationExpiredException.

In case of an AuthenticationExpiredException the Geode client code will make one automatic attempt to re-connect to the member that sent the exception.

A well-designed authorize method will have or will have a way of obtaining a mapping of principals to the operations (in the form of resource permissions) that they are permitted to do.

Resource Permissions

All operations are described by an instance of the ResourcePermission class. A permission contains the Resource data member, which classifies whether the operation as working on

  • cache data; value is DATA
  • the cluster; value is CLUSTER

A permission also contains the Operation data member, which classifies whether the operation as

  • reading; value is READ
  • changing information; value is WRITE
  • making administrative changes; value is MANAGE

The operations are not hierarchical; MANAGE does not imply WRITE, and WRITE does not imply READ.

Some DATA operations further specify a region name in the permission. This permits restricting operations on that region to only those authorized principals. And within a region, some operations may specify a key. This permits restricting operations on that key within that region to only those authorized principals.

Some CLUSTER operations further specify a finer-grained target for the operation. Specify the target with a string value of:

  • DISK to target operations that write to a disk store
  • GATEWAY to target operations that manage gateway senders and receivers
  • QUERY to target operations that manage both indexes and continuous queries
  • DEPLOY to target operations that deploy code to servers
  • LUCENE to target Lucene index operations

This table classifies the permissions assigned for operations common to a Client-Server interaction.

Client OperationAssigned ResourcePermission
get function attributeCLUSTER:READ
create regionDATA:MANAGE
destroy regionDATA:MANAGE
Region.KeysetDATA:READ:RegionName
Region.queryDATA:READ:RegionName
Region.getAllDATA:READ:RegionName
Region.getAll with a list of keysDATA:READ:RegionName:Key
Region.getEntryDATA:READ:RegionName
Region.containsKeyOnServer(key)DATA:READ:RegionName:Key
Region.get(key)DATA:READ:RegionName:Key
Region.registerInterest(key)DATA:READ:RegionName:Key
Region.registerInterest(regex)DATA:READ:RegionName
Region.unregisterInterest(key)DATA:READ:RegionName:Key
Region.unregisterInterest(regex)DATA:READ:RegionName
execute functionDefaults to DATA:WRITE. Override Function.getRequiredPermissions to change the permission.
clear regionDATA:WRITE:RegionName
Region.putAllDATA:WRITE:RegionName
Region.clearDATA:WRITE:RegionName
Region.removeAllDATA:WRITE:RegionName
Region.destroy(key)DATA:WRITE:RegionName:Key
Region.invalidate(key)DATA:WRITE:RegionName:Key
Region.destroy(key)DATA:WRITE:RegionName:Key
Region.put(key)DATA:WRITE:RegionName:Key
Region.replaceDATA:WRITE:RegionName:Key
queryService.newCqDATA:READ:RegionName
CqQuery.stopCLUSTER:MANAGE:QUERY

This table classifies the permissions assigned for gfsh operations.

gfsh CommandAssigned ResourcePermission
alter async-event-queueCLUSTER:MANAGE:DEPLOY
alter disk-storeCLUSTER:MANAGE:DISK
alter query-serviceCLUSTER:MANAGE
alter regionDATA:MANAGE:RegionName
alter runtimeCLUSTER:MANAGE
backup disk-storeDATA:READ and CLUSTER:WRITE:DISK
change loglevelCLUSTER:WRITE
clear defined indexesCLUSTER:MANAGE:QUERY
close durable-clientCLUSTER:MANAGE:QUERY
close durable-cqCLUSTER:MANAGE:QUERY
compact disk-storeCLUSTER:MANAGE:DISK
configure pdxCLUSTER:MANAGE
create async-event-queueCLUSTER:MANAGE:DEPLOY, plus CLUSTER:WRITE:DISK if the associated region is persistent
create defined indexesCLUSTER:MANAGE:QUERY
create disk-storeCLUSTER:MANAGE:DISK
create gateway-receiverCLUSTER:MANAGE:GATEWAY
create gateway-senderCLUSTER:MANAGE:GATEWAY
create indexCLUSTER:MANAGE:QUERY
create jndi-bindingCLUSTER:MANAGE
create lucene indexCLUSTER:MANAGE:LUCENE
create regionDATA:MANAGE, plus CLUSTER:WRITE:DISK if the associated region is persistent
define indexCLUSTER:MANAGE:QUERY
deployCLUSTER:MANAGE:DEPLOY
describe clientCLUSTER:READ
describe configCLUSTER:READ
describe disk-storeCLUSTER:READ
describe jndi-bindingCLUSTER:READ
describe lucene indexCLUSTER:READ:LUCENE
describe memberCLUSTER:READ
describe offline-disk-storeCLUSTER:READ
describe query-serviceCLUSTER:READ
describe regionCLUSTER:READ
destroy async-event-queueCLUSTER:MANAGE
destroy disk-storeCLUSTER:MANAGE:DISK
destroy functionCLUSTER:MANAGE:DEPLOY
destroy indexCLUSTER:MANAGE:QUERY
destroy jndi-bindingCLUSTER:MANAGE
destroy lucene indexCLUSTER:MANAGE:LUCENE
destroy regionDATA:MANAGE
execute functionDefaults to DATA:WRITE. Override Function.getRequiredPermissions to change the permission.
export cluster-configurationCLUSTER:READ
export configCLUSTER:READ
export dataCLUSTER:READ
export logsCLUSTER:READ
export offline-disk-storeCLUSTER:READ
export stack-tracesCLUSTER:READ
gcCLUSTER:MANAGE
get ‑key=key1 ‑region=region1DATA:READ:RegionName:Key
import dataDATA:WRITE:RegionName
import cluster-configurationCLUSTER:MANAGE
list async-event-queuesCLUSTER:READ
list clientsCLUSTER:READ
list deployedCLUSTER:READ
list disk-storesCLUSTER:READ
list durable-cqsCLUSTER:READ
list functionsCLUSTER:READ
list gatewaysCLUSTER:READ
list indexesCLUSTER:READ:QUERY
list jndi-bindingCLUSTER:READ
list lucene indexesCLUSTER:READ:LUCENE
list membersCLUSTER:READ
list regionsCLUSTER:READ
load-balance gateway-senderCLUSTER:MANAGE:GATEWAY
locate entryDATA:READ:RegionName:Key
netstatCLUSTER:READ
pause gateway-senderCLUSTER:MANAGE:GATEWAY
put ‑‑key=key1 ‑‑region=region1DATA:WRITE:RegionName:Key
queryDATA:READ:RegionName
rebalanceDATA:MANAGE
removeDATA:WRITE:RegionName or DATA:WRITE:RegionName:Key
resume async-event-queue-dispatcherCLUSTER:MANAGE
resume gateway-senderCLUSTER:MANAGE:GATEWAY
revoke mising-disk-storeCLUSTER:MANAGE:DISK
search luceneDATA:READ:RegionName
show dead-locksCLUSTER:READ
show logCLUSTER:READ
show metricsCLUSTER:READ
show missing-disk-storesCLUSTER:READ
show subscription-queue-sizeCLUSTER:READ
shutdownCLUSTER:MANAGE
start gateway-receiverCLUSTER:MANAGE:GATEWAY
start gateway-senderCLUSTER:MANAGE:GATEWAY
start serverCLUSTER:MANAGE
status cluster-config-serviceCLUSTER:READ
status gateway-receiverCLUSTER:READ
status gateway-senderCLUSTER:READ
status locatorCLUSTER:READ
status serverCLUSTER:READ
stop gateway-receiverCLUSTER:MANAGE:GATEWAY
stop gateway-receiverCLUSTER:MANAGE:GATEWAY
stop locatorCLUSTER:MANAGE
stop serverCLUSTER:MANAGE
undeployCLUSTER:MANAGE:DEPLOY

The gfsh connect does not have a permission, as it is the operation that invokes authentication. These gfsh commands do not have permission defined, as they do not interact with the cluster:

  • gfsh describe connection, which describes the gfsh end of the connection
  • gfsh debug, which toggles the mode within gfsh
  • gfsh exit
  • gfsh help
  • gfsh hint
  • gfsh history
  • gfsh run, although individual commands within the script will go through authorization
  • gfsh set variable
  • gfsh sh
  • gfsh sleep
  • validate offline-disk-store
  • gfsh version

This table classifies the permissions assigned for JMX operations.

JMX OperationAssigned ResourcePermission
DistributedSystemMXBean.shutdownAllMembersCLUSTER:MANAGE
ManagerMXBean.startCLUSTER:MANAGE
ManagerMXBean.stopCLUSTER:MANAGE
ManagerMXBean.createManagerCLUSTER:MANAGE
ManagerMXBean.shutDownMemberCLUSTER:MANAGE
Mbeans get attributesCLUSTER:READ
MemberMXBean.showLogCLUSTER:READ
DistributedSystemMXBean.changerAlertLevelCLUSTER:WRITE
ManagerMXBean.setPulseURLCLUSTER:WRITE
ManagerMXBean.setStatusMessageCLUSTER:WRITE
CacheServerMXBean.closeAllContinuousQueryCLUSTER:MANAGE:QUERY
CacheServerMXBean.closeContinuousQueryCLUSTER:MANAGE:QUERY
CacheServerMXBean.executeContinuousQueryDATA:READ
CqQuery.executeDATA:READ:RegionName and CLUSTER:MANAGE:QUERY
CqQuery.executeWithInitialResultsDATA:READ:RegionName and CLUSTER:MANAGE:QUERY
DiskStoreMXBean.flushCLUSTER:MANAGE:DISK
DiskStoreMXBean.forceCompactionCLUSTER:MANAGE:DISK
DiskStoreMXBean.forceRollCLUSTER:MANAGE:DISK
DiskStoreMXBean.setDiskUsageCriticalPercentageCLUSTER:MANAGE:DISK
DiskStoreMXBean.setDiskUsageWarningPercentageCLUSTER:MANAGE:DISK
DistributedSystemMXBean.revokeMissingDiskStoresCLUSTER:MANAGE:DISK
DistributedSystemMXBean.setQueryCollectionsDepthCLUSTER:MANAGE:QUERY
DistributedSystemMXBean.setQueryResultSetLimitCLUSTER:MANAGE:QUERY
DistributedSystemMXBean.backupAllMembersDATA:READ and CLUSTER:WRITE:DISK
DistributedSystemMXBean.queryDataDATA:READ
DistributedSystemMXBean.queryDataForCompressedResultDATA:READ
GatewayReceiverMXBean.pauseCLUSTER:MANAGE:GATEWAY
GatewayReceiverMXBean.rebalanceCLUSTER:MANAGE:GATEWAY
GatewayReceiverMXBean.resumeCLUSTER:MANAGE:GATEWAY
GatewayReceiverMXBean.startCLUSTER:MANAGE:GATEWAY
GatewayReceiverMXBean.stopCLUSTER:MANAGE:GATEWAY
GatewaySenderMXBean.pauseCLUSTER:MANAGE:GATEWAY
GatewaySenderMXBean.rebalanceCLUSTER:MANAGE:GATEWAY
GatewaySenderMXBean.resumeCLUSTER:MANAGE:GATEWAY
GatewaySenderMXBean.startCLUSTER:MANAGE:GATEWAY
GatewaySenderMXBean.stopCLUSTER:MANAGE:GATEWAY
LockServiceMXBean.becomeLockGrantorCLUSTER:MANAGE
MemberMXBean.compactAllDiskStoresCLUSTER:MANAGE:DISK

Implement Authorization

Complete these items to implement authorization.

  • Decide upon an authorization algorithm. The Authorization Example stores a mapping of which principals (users) are permitted to do which operations. The algorithm bases its decision on a look up of the permissions granted to the principal attempting the operation.
  • Define the security-manager property. See Enable Security with Property Definitions for details about this property.
  • Implement the authorize method of the SecurityManager interface.
  • Define any extra resources that the implemented authorization algorithm needs in order to make a decision.

Authorization of Function Execution

By default, a function executed on servers requires that the entity invoking the function have DATA:WRITE permission on the region(s) involved. Since the default permission may not be appropriate for all functions, the permissions required may be altered.

To implement a different set of permissions, override the Function.getRequiredPermissions() method in the function's class. The method should return a Collection of the permissions required of the entity that invokes an execution of the function.

Authorization of Methods Invoked from Queries

Enabling the SecurityManager affects queries by restricting the methods that a running query may invoke. See Method Invocations and Method Invocation Authorizers for details.