PII - Field Level Security
For an example, see $GS_HOME/examples/helloworld-security.
What is Field Security?
Space
Where GigaSpaces data is stored. It is the logical cache that holds data objects in memory and might also hold them in layered in tiering. Data is hosted from multiple SoRs, consolidated as a unified data model. security has always been type level: a user either may or may not READ/WRITE a class. Field Security adds field-level control for properties that hold personal data (PII - Personally Identifiable Information), such as a social security number or a credit card number.
Each PII field can be granted separately per type and per user (role / service account):
| The user... | Result |
|---|---|
| has no read access to a PII field | SELECT * returns only the fields the user may read - the PII value is omitted (null in the Space API, the column is missing in JDBC |
| Selecting the PII field explicitly results in an access denied error | |
A query with a condition (WHERE, ORDER BY, GROUP BY, aggregation) on the PII field results in an access denied error |
|
| has no write access to a PII field | Writing an object with a non-null value in that field results in an access denied error |
| Writing / updating an object without that field is allowed; on update the existing PII value is preserved | |
change() on that field results in an access denied error |
|
| has read and write access | Everything works as usual |
Type-level privileges (READ, WRITE, ...) are still required in addition to the PII privileges. Types without PII fields and non-secured spaces are not affected.
Marking Fields as PII
POJO
Plain Old Java Object.
A regular Java object with no special restrictions other than those forced by the Java Language Specification and does not require any classpath. annotation - @SpacePii on the getter:
public class Customer {
private Integer id;
private String name;
private String ssn;
private String creditCard;
@SpaceId
public Integer getId() { return id; }
public String getName() { return name; }
@SpacePii // personal data
public String getSsn() { return ssn; }
@SpacePii // personal data
public String getCreditCard() { return creditCard; }
// setters ...
}
gs.xml:
<class name="com.acme.Customer">
<property name="ssn" pii="true"/>
<property name="creditCard" pii="true"/>
</class>
Space documents - SpaceTypeDescriptorBuilder:
SpaceTypeDescriptor customerType = new SpaceTypeDescriptorBuilder("Customer")
.idProperty("id")
.addFixedProperty("id", Integer.class)
.addFixedProperty("name", String.class)
.addFixedProperty("ssn", String.class)
.addFixedProperty("creditCard", String.class)
.piiProperties("ssn", "creditCard")
.create();
gigaSpace.getTypeManager().registerTypeDescriptor(customerType);
A subclass inherits the PII fields of its superclass.
Privileges
Two new space privileges:
| Privilege | Allows |
|---|---|
READ_PII
|
reading / querying PII fields |
WRITE_PII
|
writing / updating PII fields |
Each privilege can be restricted with a filter:
| Authority | Grants |
|---|---|
SpacePrivilege READ_PII
|
all PII fields of all types |
SpacePrivilege READ_PII FieldFilter com.acme.Customer#ssn
|
only ssn of com.acme.Customer |
SpacePrivilege READ_PII FieldFilter com.acme.Customer#*
|
all PII fields of com.acme.Customer |
SpacePrivilege READ_PII SpacenameFilter mySpace
|
all PII fields in space mySpace |
-
The type name in the
FieldFilteris the name the type is registered with (the fully qualified class name for POJOs, the type name for documents). -
FieldFiltercan be used only withREAD_PII/WRITE_PII. -
ROLE_ADMINin the distribution (config/security/security-openid.yaml,config/security/service-accounts.yaml) and therootuser have full PII privileges.
Defining Roles and Service Accounts
Security server REST API
REpresentational State Transfer. Application Programming Interface
An API, or application programming interface, is a set of rules that define how applications or devices can connect to and communicate with each other. A REST API is an API that conforms to the design principles of the REST, or representational state transfer architectural style. (OpenID mode - the auth server runs on port 9000). The following creates a role:
curl -u root:password -H "Content-Type: application/json" -X POST http://localhost:9000/v1/roles -d '{
"roleName": "ROLE_PII_PARTIAL",
"description": "read ssn only",
"default": false,
"policies": [
{"authority":"SpacePrivilege","privilege":"READ", "filter":null},
{"authority":"SpacePrivilege","privilege":"WRITE", "filter":null},
{"authority":"SpacePrivilege","privilege":"READ_PII",
"filter":{"type":"FieldFilter","parameter":"org.openspaces.example.helloworld.common.Customer#ssn"}}
]}'
The following creates a service account with that role and retrieves its secret:
UUID=$(curl -s -u root:password -H "Content-Type: application/json" -X POST \
http://localhost:9000/v1/service-account/config \
-d '{"serviceName":"pii-partial","rolesNames":["ROLE_PII_PARTIAL"],"tokenExpInMinutes":30}' | tr -d '"')
curl -s -u root:password http://localhost:9000/v1/service-account/config/$UUID # -> "clientSecret"
Configuration files - the same policies can be written as strings in config/security/security-openid.yaml:
roles:
ROLE_PII_PARTIAL:
SpacePrivilege READ
, SpacePrivilege WRITE
, SpacePrivilege READ_PII FieldFilter org.openspaces.example.helloworld.common.Customer#ssn
Connecting as a Service Account
Space API:
GigaSpace gigaSpace = new GigaSpaceConfigurer(
new SpaceProxyConfigurer("piiSpace")
.credentialsProvider(new ServiceCredentialsProvider("pii-partial", clientSecret)))
.gigaSpace();
Customer customer = gigaSpace.readById(Customer.class, 2);
// -> ssn is returned, creditCard is null (no READ_PII on creditCard)
gigaSpace.readMultiple(new SQLQuery<>(Customer.class, "ssn = ?", "ssn-2")); // OK
gigaSpace.readMultiple(new SQLQuery<>(Customer.class, "creditCard like '4111%'")); // AccessDeniedException
JDBC - the service account JWT
JSON Web Token is a compact URL-safe means of representing claims to be transferred between two parties. The claims in a JWT are encoded as a JSON. JWTs are credentials, which can grant access to resources. is used as the password:
TOKEN=$(curl -s "http://localhost:9000/v1/accessTokenWithSecret?id=pii-none&clientSecret=<secret>")
Properties props = new Properties();
props.setProperty("user", "pii-none");
props.setProperty("password", token);
Connection connection = DriverManager.getConnection("jdbc:gigaspaces:v3://localhost/piiSpace", props);
// SELECT * FROM "org.openspaces.example.helloworld.common.Customer" -> columns CITY, ID, NAME
// SELECT name, ssn FROM "...Customer" -> access denied (validation error)
// SELECT * FROM "...Customer" WHERE ssn = 'ssn-1' -> access denied (validation error)
Error messages look similar to the following:
User [service-account-pii-none] lacks [Write PII] privileges for field [ssn] of class [org.openspaces.example.helloworld.common.Customer]
Access denied - lacking [Read PII] privileges for field [creditCard] of table [org.openspaces.example.helloworld.common.Customer]
Limitations
-
Only fixed properties can be PII (not dynamic properties).
-
Local view, local cache and durable notifications of a type require
READ_PIIon all its PII fields. Regular notifications are delivered with the denied PII values omitted. -
Custom change operations on a PII type require
WRITE_PIIon all its PII fields. -
Custom query predicates (user code) cannot be inspected for PII references.
-
In the legacy JDBC driver,
SELECT *, ssnsilently omitsssninstead of failing.
In-Memory Data Grid - achieve unparalleled speed, persistence, and accuracy.