Class PutRoleMappingRequest
- All Implemented Interfaces:
JsonpSerializable
Role mappings define which roles are assigned to each user. Each mapping has rules that identify users and a list of roles that are granted to those users. The role mapping APIs are generally the preferred way to manage role mappings rather than using role mapping files. The create or update role mappings API cannot update role mappings that are defined in role mapping files.
NOTE: This API does not create roles. Rather, it maps users to existing roles. Roles can be created by using the create or update roles API or roles files.
Role templates
The most common use for role mappings is to create a mapping from a known
value on the user to a fixed role name. For example, all users in the
cn=admin,dc=example,dc=com
LDAP group should be given the
superuser role in Elasticsearch. The roles
field is used for
this purpose.
For more complex needs, it is possible to use Mustache templates to
dynamically determine the names of the roles that should be granted to the
user. The role_templates
field is used for this purpose.
NOTE: To use role templates successfully, the relevant scripting feature must be enabled. Otherwise, all attempts to create a role mapping with role templates fail.
All of the user fields that are available in the role mapping rules are also available in the role templates. Thus it is possible to assign a user to a role that reflects their username, their groups, or the name of the realm to which they authenticated.
By default a template is evaluated to produce a single string that is the name of the role which should be assigned to the user. If the format of the template is set to "json" then the template is expected to produce a JSON string or an array of JSON strings for the role names.
- See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class co.elastic.clients.elasticsearch._types.RequestBase
RequestBase.AbstractBuilder<BuilderT extends RequestBase.AbstractBuilder<BuilderT>>
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final JsonpDeserializer<PutRoleMappingRequest>
Json deserializer forPutRoleMappingRequest
static final Endpoint<PutRoleMappingRequest,
PutRoleMappingResponse, ErrorResponse> Endpoint "security.put_role_mapping
". -
Method Summary
Modifier and TypeMethodDescriptionfinal Boolean
enabled()
Mappings that haveenabled
set tofalse
are ignored when role mapping is performed.metadata()
Additional metadata that helps define which roles are assigned to each user.final String
name()
Required - The distinct name that identifies the role mapping.static PutRoleMappingRequest
final Refresh
refresh()
Iftrue
(the default) then refresh the affected shards to make this operation visible to search, ifwait_for
then wait for a refresh to make this operation visible to search, iffalse
then do nothing with refreshes.roles()
A list of role names that are granted to the users that match the role mapping rules.final List<RoleTemplate>
A list of Mustache templates that will be evaluated to determine the roles names that should granted to the users that match the role mapping rules.final RoleMappingRule
rules()
The rules that determine which users should be matched by the mapping.runAs()
API name:run_as
void
serialize
(jakarta.json.stream.JsonGenerator generator, JsonpMapper mapper) Serialize this object to JSON.protected void
serializeInternal
(jakarta.json.stream.JsonGenerator generator, JsonpMapper mapper) protected static void
Methods inherited from class co.elastic.clients.elasticsearch._types.RequestBase
toString
-
Field Details
-
_DESERIALIZER
Json deserializer forPutRoleMappingRequest
-
_ENDPOINT
Endpoint "security.put_role_mapping
".
-
-
Method Details
-
of
public static PutRoleMappingRequest of(Function<PutRoleMappingRequest.Builder, ObjectBuilder<PutRoleMappingRequest>> fn) -
enabled
Mappings that haveenabled
set tofalse
are ignored when role mapping is performed.API name:
enabled
-
metadata
Additional metadata that helps define which roles are assigned to each user. Within the metadata object, keys beginning with_
are reserved for system usage.API name:
metadata
-
name
Required - The distinct name that identifies the role mapping. The name is used solely as an identifier to facilitate interaction via the API; it does not affect the behavior of the mapping in any way.API name:
name
-
refresh
Iftrue
(the default) then refresh the affected shards to make this operation visible to search, ifwait_for
then wait for a refresh to make this operation visible to search, iffalse
then do nothing with refreshes.API name:
refresh
-
roleTemplates
A list of Mustache templates that will be evaluated to determine the roles names that should granted to the users that match the role mapping rules. Exactly one ofroles
orrole_templates
must be specified.API name:
role_templates
-
roles
A list of role names that are granted to the users that match the role mapping rules. Exactly one ofroles
orrole_templates
must be specified.API name:
roles
-
rules
The rules that determine which users should be matched by the mapping. A rule is a logical condition that is expressed by using a JSON DSL.API name:
rules
-
runAs
API name:run_as
-
serialize
Serialize this object to JSON.- Specified by:
serialize
in interfaceJsonpSerializable
-
serializeInternal
-
setupPutRoleMappingRequestDeserializer
protected static void setupPutRoleMappingRequestDeserializer(ObjectDeserializer<PutRoleMappingRequest.Builder> op)
-