Este conteúdo não está disponível no idioma selecionado.
Chapter 5. Security realms
Security realms integrate Data Grid Server deployments with the network protocols and infrastructure in your environment that control access and verify user identities.
5.1. Creating security realms Copiar o linkLink copiado para a área de transferência!
Add security realms to Data Grid Server configuration to control access to deployments. You can add one or more security realm to your configuration.
When you add security realms to your configuration, Data Grid Server automatically enables the matching authentication mechanisms for the Hot Rod and REST endpoints.
Prerequisites
- Add socket bindings to your Data Grid Server configuration as required.
Create keystores, or have a PEM file, to configure the security realm with TLS/SSL encryption.
Data Grid Server can also generate keystores at startup.
-
Provision the resources or services that the security realm configuration relies on.
For example, if you add a token realm, you need to provision OAuth services.
This procedure demonstrates how to configure multiple property realms. Before you begin, you need to create properties files that add users and assign permissions with the Command Line Interface (CLI). Use the user create commands as follows:
Run user create --help for examples and more information.
Adding credentials to a properties realm with the CLI creates the user only on the server instance to which you are connected. You must manually synchronize credentials in a properties realm to each node in the cluster.
Procedure
- Open your Data Grid Server configuration for editing.
-
Use the
security-realmselement in thesecurityconfiguration to contain create multiple security realms. Add a security realm with the
security-realmelement and give it a unique name with thenameattribute.To follow the example, create one security realm named
application-realmand another namedmanagement-realm.-
Provide the TLS/SSL identify for Data Grid Server with the
server-identitieselement and configure a keystore as required. Specify the type of security realm by adding one the following elements or fields:
-
properties-realm -
ldap-realm -
token-realm -
truststore-realm
-
Specify properties for the type of security realm you are configuring as appropriate.
To follow the example, specify the
*.propertiesfiles you created with the CLI using thepathattribute on theuser-propertiesandgroup-propertieselements or fields.-
If you add multiple different types of security realm to your configuration, include the
distributed-realmelement or field so that Data Grid Server uses the realms in combination with each other. -
Configure Data Grid Server endpoints to use the security realm with the with the
security-realmattribute. - Save the changes to your configuration.
Multiple property realms
XML
JSON
YAML
5.2. Setting up Kerberos identities Copiar o linkLink copiado para a área de transferência!
Add Kerberos identities to a security realm in your Data Grid Server configuration to use keytab files that contain service principal names and encrypted keys, derived from Kerberos passwords.
Prerequisites
- Have Kerberos service account principals.
keytab files can contain both user and service account principals. However, Data Grid Server uses service account principals only which means it can provide identity to clients and allow clients to authenticate with Kerberos servers.
In most cases, you create unique principals for the Hot Rod and REST endpoints. For example, if you have a "datagrid" server in the "INFINISPAN.ORG" domain you should create the following service principals:
-
hotrod/datagrid@INFINISPAN.ORGidentifies the Hot Rod service. -
HTTP/datagrid@INFINISPAN.ORGidentifies the REST service.
Procedure
Create keytab files for the Hot Rod and REST services.
- Linux
ktutil ktutil: addent -password -p datagrid@INFINISPAN.ORG -k 1 -e aes256-cts Password for datagrid@INFINISPAN.ORG: [enter your password] ktutil: wkt http.keytab ktutil: quit
ktutil ktutil: addent -password -p datagrid@INFINISPAN.ORG -k 1 -e aes256-cts Password for datagrid@INFINISPAN.ORG: [enter your password] ktutil: wkt http.keytab ktutil: quitCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Microsoft Windows
ktpass -princ HTTP/datagrid@INFINISPAN.ORG -pass * -mapuser INFINISPAN\USER_NAME ktab -k http.keytab -a HTTP/datagrid@INFINISPAN.ORG
ktpass -princ HTTP/datagrid@INFINISPAN.ORG -pass * -mapuser INFINISPAN\USER_NAME ktab -k http.keytab -a HTTP/datagrid@INFINISPAN.ORGCopy to Clipboard Copied! Toggle word wrap Toggle overflow
-
Copy the keytab files to the
server/confdirectory of your Data Grid Server installation. - Open your Data Grid Server configuration for editing.
-
Add a
server-identitiesdefinition to the Data Grid server security realm. - Specify the location of keytab files that provide service principals to Hot Rod and REST connectors.
- Name the Kerberos service principals.
- Save the changes to your configuration.
Kerberos identity configuration
XML
JSON
YAML
5.3. Property realms Copiar o linkLink copiado para a área de transferência!
Property realms use property files to define users and groups.
-
users.propertiescontains Data Grid user credentials. Passwords can be pre-digested with theDIGEST-MD5andDIGESTauthentication mechanisms. -
groups.propertiesassociates users with roles and permissions.
You can avoid authentication issues that relate to a property file by using the Data Grid CLI to enter the correct security realm name to the file. You can find the correct security realm name of your Data Grid Server by opening the infinispan.xml file and navigating to the <security-realm name> property. When you copy a property file from one Data Grid Server to another, make sure that the security realm name appropriates to the correct authentication mechanism for the target endpoint.
users.properties
myuser=a_password user2=another_password
myuser=a_password
user2=another_password
groups.properties
myuser=supervisor,reader,writer user2=supervisor
myuser=supervisor,reader,writer
user2=supervisor
Property realm configuration
XML
JSON
YAML
5.4. LDAP realms Copiar o linkLink copiado para a área de transferência!
LDAP realms connect to LDAP servers, such as OpenLDAP, Red Hat Directory Server, Apache Directory Server, or Microsoft Active Directory, to authenticate users and obtain membership information.
LDAP servers can have different entry layouts, depending on the type of server and deployment. It is beyond the scope of this document to provide examples for all possible configurations.
5.4.1. LDAP connection properties Copiar o linkLink copiado para a área de transferência!
Specify the LDAP connection properties in the LDAP realm configuration.
The following properties are required:
| url |
Specifies the URL of the LDAP server. The URL should be in format |
| principal | Specifies a distinguished name (DN) of a valid user in the LDAp server. The DN uniquely identifies the user within the LDAP directory structure. |
| credential | Corresponds to the password associated with the principal mentioned above. |
The principal for LDAP connections must have necessary privileges to perform LDAP queries and access specific attributes.
Enabling connection-pooling significantly improves the performance of authentication to LDAP servers. The connection pooling mechanism is provided by the JDK. For more information see Connection Pooling Configuration and Java Tutorials: Pooling.
5.4.2. LDAP realm user authentication methods Copiar o linkLink copiado para a área de transferência!
Configure the user authentication method in the LDAP realm.
The LDAP realm can authenticate users in two ways:
| Hashed password comparison |
by comparing the hashed password stored in a user’s password attribute (usually |
| Direct verification | by authenticating against the LDAP server using the supplied credentials
Direct verification is the only approach that works with Active Directory, because access to the |
You cannot use endpoint authentication mechanisms that performs hashing with the direct-verification attribute, since this method requires having the password in clear text. As a result you must use the BASIC authentication mechanism with the REST endpoint and PLAIN with the Hot Rod endpoint to integrate with Active Directory Server. A more secure alternative is to use Kerberos, which allows the SPNEGO, GSSAPI, and GS2-KRB5 authentication mechanisms.
The LDAP realm searches the directory to find the entry which corresponds to the authenticated user. The rdn-identifier attribute specifies an LDAP attribute that finds the user entry based on a provided identifier, which is typically a username; for example, the uid or sAMAccountName attribute. Add search-recursive="true" to the configuration to search the directory recursively. By default, the search for the user entry uses the (rdn_identifier={0}) filter. You can specify a different filter using the filter-name attribute.
5.4.3. Mapping user entries to their associated groups Copiar o linkLink copiado para a área de transferência!
In the LDAP realm configuration, specify the attribute-mapping element to retrieve and associate all groups that a user is a member of.
The membership information is stored typically in two ways:
-
Under group entries that usually have class
groupOfNamesorgroupOfUniqueNamesin thememberattribute. This is the default behavior in most LDAP installations, except for Active Directory. In this case, you can use an attribute filter. This filter searches for entries that match the supplied filter, which locates groups with amemberattribute equal to the user’s DN. The filter then extracts the group entry’s CN as specified byfrom, and adds it to the user’sRoles. In the user entry in the
memberOfattribute. This is typically the case for Active Directory. In this case you should use an attribute reference such as the following:<attribute-reference reference="memberOf" from="cn" to="Roles" />This reference gets all
memberOfattributes from the user’s entry, extracts the CN as specified byfrom, and adds them to the user’s groups (Rolesis the internal name used to map the groups).
5.4.4. LDAP realm configuration reference Copiar o linkLink copiado para a área de transferência!
XML
JSON
YAML
5.4.4.1. LDAP realm principal rewriting Copiar o linkLink copiado para a área de transferência!
Principals obtained by SASL authentication mechanisms such as GSSAPI, GS2-KRB5 and Negotiate usually include the domain name, for example myuser@INFINISPAN.ORG. Before using these principals in LDAP queries, it is necessary to transform them to ensure their compatibility. This process is called rewriting.
Data Grid includes the following transformers:
| case-principal-transformer |
rewrites the principal to either all uppercase or all lowercase. For example |
| common-name-principal-transformer |
rewrites principals in the LDAP Distinguished Name format (as defined by RFC 4514). It extracts the first attribute of type |
| regex-principal-transformer | rewrites principals using a regular expression with capturing groups, allowing, for example, for extractions of any substring. |
5.4.4.2. LDAP principal rewriting configuration reference Copiar o linkLink copiado para a área de transferência!
Case principal transformer
XML
JSON
YAML
Common name principal transformer
XML
JSON
YAML
Regex principal transformer
XML
JSON
YAML
5.4.4.3. LDAP user and group mapping process with Data Grid Copiar o linkLink copiado para a área de transferência!
This example illustrates the process of loading and internally mapping LDAP users and groups to Data Grid subjects. The following is a LDIF (LDAP Data Interchange Format) file, which describes multiple LDAP entries:
LDIF
The root user is a member of the admin and monitor groups.
When a request to authenticate the user root with the password strongPassword is made on one of the endpoints, the following operations are performed:
- The username is optionally rewritten using the chosen principal transformer.
-
The realm searches within the
ou=People,dc=infinispan,dc=orgtree for an entry whoseuidattribute is equal torootand finds the entry with DNuid=root,ou=People,dc=infinispan,dc=org, which becomes the user principal. -
The realm searches within the
u=Roles,dc=infinispan,dc=orgtree for entries ofobjectClass=groupOfNamesthat includeuid=root,ou=People,dc=infinispan,dc=orgin thememberattribute. In this case it finds two entries:cn=admin,ou=Roles,dc=infinispan,dc=organdcn=monitor,ou=Roles,dc=infinispan,dc=org. From these entries, it extracts thecnattributes which become the group principals.
The resulting subject will therefore look like:
-
NamePrincipal:
uid=root,ou=People,dc=infinispan,dc=org -
RolePrincipal:
admin -
RolePrincipal:
monitor
At this point, the global authorization mappers are applied on the above subject to convert the principals into roles. The roles are then expanded into a set of permissions, which are validated against the requested cache and operation.
5.5. Token realms Copiar o linkLink copiado para a área de transferência!
Token realms use external services to validate tokens and require providers that are compatible with RFC-7662 (OAuth2 Token Introspection), such as Red Hat SSO.
Token realm configuration
XML
JSON
YAML
5.6. Trust store realms Copiar o linkLink copiado para a área de transferência!
Trust store realms use certificates, or certificates chains, that verify Data Grid Server and client identities when they negotiate connections.
- Keystores
- Contain server certificates that provide a Data Grid Server identity to clients. If you configure a keystore with server certificates, Data Grid Server encrypts traffic using industry standard SSL/TLS protocols.
- Trust stores
- Contain client certificates, or certificate chains, that clients present to Data Grid Server. Client trust stores are optional and allow Data Grid Server to perform client certificate authentication.
Client certificate authentication
You must add the require-ssl-client-auth="true" attribute to the endpoint configuration if you want Data Grid Server to validate or authenticate client certificates.
Trust store realm configuration
XML
JSON
YAML
5.7. Distributed security realms Copiar o linkLink copiado para a área de transferência!
Distributed realms combine multiple different types of security realms. When users attempt to access the Hot Rod or REST endpoints, Data Grid Server uses each security realm in turn until it finds one that can perform the authentication.
Distributed realm configuration
XML
JSON
YAML