| 1 |
# Licensed to Elasticsearch B.V. under one or more contributor |
| 2 |
# license agreements. See the NOTICE file distributed with |
| 3 |
# this work for additional information regarding copyright |
| 4 |
# ownership. Elasticsearch B.V. licenses this file to you under |
| 5 |
# the Apache License, Version 2.0 (the "License"); you may |
| 6 |
# not use this file except in compliance with the License. |
| 7 |
# You may obtain a copy of the License at |
| 8 |
# |
| 9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 |
# |
| 11 |
# Unless required by applicable law or agreed to in writing, |
| 12 |
# software distributed under the License is distributed on an |
| 13 |
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 |
# KIND, either express or implied. See the License for the |
| 15 |
# specific language governing permissions and limitations |
| 16 |
# under the License. |
| 17 |
|
| 18 |
package Search::Elasticsearch::Client::8_0::Direct::Security; |
| 19 |
$Search::Elasticsearch::Client::8_0::Direct::Security::VERSION = '8.12'; |
| 20 |
use Moo; |
| 21 |
with 'Search::Elasticsearch::Client::8_0::Role::API'; |
| 22 |
with 'Search::Elasticsearch::Role::Client::Direct'; |
| 23 |
use namespace::clean; |
| 24 |
|
| 25 |
__PACKAGE__->_install_api('security'); |
| 26 |
|
| 27 |
1; |
| 28 |
|
| 29 |
=pod |
| 30 |
|
| 31 |
=encoding UTF-8 |
| 32 |
|
| 33 |
=head1 NAME |
| 34 |
|
| 35 |
Search::Elasticsearch::Client::8_0::Direct::Security - Plugin providing Security API for Search::Elasticsearch 8.x |
| 36 |
|
| 37 |
=head1 VERSION |
| 38 |
|
| 39 |
version 8.12 |
| 40 |
|
| 41 |
=head1 SYNOPSIS |
| 42 |
|
| 43 |
my $response = $es->security->authenticate(); |
| 44 |
|
| 45 |
=head2 DESCRIPTION |
| 46 |
|
| 47 |
This class extends the L<Search::Elasticsearch> client with a C<security> |
| 48 |
namespace, to support the |
| 49 |
L<Security APIs|https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api.html>. |
| 50 |
|
| 51 |
The full documentation for the Security feature is available here: |
| 52 |
L<https://www.elastic.co/guide/en/x-pack/current/xpack-security.html> |
| 53 |
|
| 54 |
=head1 GENERAL METHODS |
| 55 |
|
| 56 |
=head2 C<authenticate()> |
| 57 |
|
| 58 |
$response = $es->security->authenticate() |
| 59 |
|
| 60 |
The C<authenticate()> method checks that the C<userinfo> is correct and returns |
| 61 |
a list of which roles are assigned to the user. |
| 62 |
|
| 63 |
See the L<authenticate docs|https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-authenticate.html> |
| 64 |
for more information. |
| 65 |
|
| 66 |
Query string parameters: |
| 67 |
C<error_trace>, |
| 68 |
C<human> |
| 69 |
|
| 70 |
=head2 C<clear_cached_realms()> |
| 71 |
|
| 72 |
$response = $es->security->clear_cached_realms( |
| 73 |
realms => $realms # required (comma-separated string) |
| 74 |
); |
| 75 |
|
| 76 |
The C<clear_cached_realms()> method clears the caches for the specified realms |
| 77 |
|
| 78 |
Query string parameters: |
| 79 |
C<error_trace>, |
| 80 |
C<human>, |
| 81 |
C<usernames> |
| 82 |
|
| 83 |
See the L<clear_cached_realms docs|https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-clear-cache.html> |
| 84 |
for more information. |
| 85 |
|
| 86 |
=head1 USER METHODS |
| 87 |
|
| 88 |
=head2 C<put_user()> |
| 89 |
|
| 90 |
$response = $es->security->put_user( |
| 91 |
username => $username, # required |
| 92 |
body => {...} # required |
| 93 |
); |
| 94 |
|
| 95 |
The C<put_user()> method creates a new user or updates an existing user. |
| 96 |
|
| 97 |
See the L<User Management docs|https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-users.html> |
| 98 |
for more information. |
| 99 |
|
| 100 |
Query string parameters: |
| 101 |
C<error_trace>, |
| 102 |
C<human> |
| 103 |
|
| 104 |
=head2 C<get_user()> |
| 105 |
|
| 106 |
$response = $es->security->get_user( |
| 107 |
username => $username | \@usernames # optional |
| 108 |
); |
| 109 |
|
| 110 |
The C<get_user()> method retrieves info for the specified users (or all users). |
| 111 |
|
| 112 |
See the L<User Management docs|https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-users.html> |
| 113 |
for more information. |
| 114 |
|
| 115 |
Query string parameters: |
| 116 |
C<error_trace>, |
| 117 |
C<human> |
| 118 |
|
| 119 |
=head2 C<delete_user()> |
| 120 |
|
| 121 |
$response = $es->security->delete_user( |
| 122 |
username => $username # required |
| 123 |
); |
| 124 |
|
| 125 |
The C<delete_user()> method deletes the specified user. |
| 126 |
|
| 127 |
See the L<User Management docs|https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-users.html> |
| 128 |
for more information. |
| 129 |
|
| 130 |
Query string parameters: |
| 131 |
C<error_trace>, |
| 132 |
C<human> |
| 133 |
|
| 134 |
=head2 C<change_password()> |
| 135 |
|
| 136 |
$response = $es->security->change_password( |
| 137 |
username => $username # optional |
| 138 |
body => { |
| 139 |
password => $password # required |
| 140 |
} |
| 141 |
) |
| 142 |
|
| 143 |
The C<change_password()> method changes the password for the specified user. |
| 144 |
|
| 145 |
See the L<User Management docs|https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-users.html> |
| 146 |
for more information. |
| 147 |
|
| 148 |
=head2 C<disable_user()> |
| 149 |
|
| 150 |
$response = $es->security->disable_user( |
| 151 |
username => $username # required |
| 152 |
); |
| 153 |
|
| 154 |
The C<disable_user()> method disables the specified user. |
| 155 |
|
| 156 |
See the L<User Management docs|https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-users.html> |
| 157 |
for more information. |
| 158 |
|
| 159 |
Query string parameters: |
| 160 |
C<error_trace>, |
| 161 |
C<human> |
| 162 |
|
| 163 |
=head2 C<enable_user()> |
| 164 |
|
| 165 |
$response = $es->security->enable_user( |
| 166 |
username => $username # required |
| 167 |
); |
| 168 |
|
| 169 |
The C<enable_user()> method enables the specified user. |
| 170 |
|
| 171 |
See the L<User Management docs|https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-users.html> |
| 172 |
for more information. |
| 173 |
|
| 174 |
Query string parameters: |
| 175 |
C<error_trace>, |
| 176 |
C<human> |
| 177 |
|
| 178 |
=head1 ROLE METHODS |
| 179 |
|
| 180 |
=head2 C<put_role()> |
| 181 |
|
| 182 |
$response = $es->security->put_role( |
| 183 |
name => $name, # required |
| 184 |
body => {...} # required |
| 185 |
); |
| 186 |
|
| 187 |
The C<put_role()> method creates a new role or updates an existing role. |
| 188 |
|
| 189 |
See the L<Role Management docs|https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-roles.html> |
| 190 |
for more information. |
| 191 |
|
| 192 |
Query string parameters: |
| 193 |
C<error_trace>, |
| 194 |
C<human> |
| 195 |
|
| 196 |
=head2 C<get_role()> |
| 197 |
|
| 198 |
$response = $es->security->get_role( |
| 199 |
name => $name | \@names # optional |
| 200 |
); |
| 201 |
|
| 202 |
The C<get_role()> method retrieves info for the specified roles (or all roles). |
| 203 |
|
| 204 |
See the L<Role Management docs|https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-roles.html> |
| 205 |
for more information. |
| 206 |
|
| 207 |
Query string parameters: |
| 208 |
C<error_trace>, |
| 209 |
C<human> |
| 210 |
|
| 211 |
=head2 C<delete_role()> |
| 212 |
|
| 213 |
$response = $es->security->delete_role( |
| 214 |
name => $name # required |
| 215 |
); |
| 216 |
|
| 217 |
The C<delete_role()> method deletes the specified role. |
| 218 |
|
| 219 |
See the L<Role Management docs|https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-roles.html> |
| 220 |
for more information. |
| 221 |
|
| 222 |
Query string parameters: |
| 223 |
C<error_trace>, |
| 224 |
C<human> |
| 225 |
|
| 226 |
=head2 C<clear_cached_roles()> |
| 227 |
|
| 228 |
$response = $es->security->clear_cached_roles( |
| 229 |
names => $names # required (comma-separated string) |
| 230 |
); |
| 231 |
|
| 232 |
The C<clear_cached_roles()> method clears the caches for the specified roles. |
| 233 |
|
| 234 |
See the L<Role Management docs|https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-roles.html> |
| 235 |
for more information. |
| 236 |
|
| 237 |
Query string parameters: |
| 238 |
C<error_trace>, |
| 239 |
C<human> |
| 240 |
|
| 241 |
=head1 ROLE MAPPING METHODS |
| 242 |
|
| 243 |
=head2 C<put_role_mapping()> |
| 244 |
|
| 245 |
$response = $es->security->put_role_mapping( |
| 246 |
name => $name, # required |
| 247 |
body => {...} # required |
| 248 |
); |
| 249 |
|
| 250 |
The C<put_role_mapping()> method creates a new role mapping or updates an existing role mapping. |
| 251 |
|
| 252 |
See the L<Role Mapping docs|https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-role-mapping.html> |
| 253 |
for more information. |
| 254 |
|
| 255 |
Query string parameters: |
| 256 |
C<error_trace>, |
| 257 |
C<human> |
| 258 |
|
| 259 |
=head2 C<get_role_mapping()> |
| 260 |
|
| 261 |
$response = $es->security->get_role_mapping( |
| 262 |
name => $name, # optional |
| 263 |
); |
| 264 |
|
| 265 |
The C<get_role_mapping()> method retrieves one or more role mappings. |
| 266 |
|
| 267 |
See the L<Role Mapping docs|https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-role-mapping.html> |
| 268 |
for more information. |
| 269 |
|
| 270 |
Query string parameters: |
| 271 |
C<error_trace>, |
| 272 |
C<human> |
| 273 |
|
| 274 |
=head2 C<delete_role_mapping()> |
| 275 |
|
| 276 |
$response = $es->security->delete_role_mapping( |
| 277 |
name => $name, # required |
| 278 |
); |
| 279 |
|
| 280 |
The C<delete_role_mapping()> method deletes a role mapping. |
| 281 |
|
| 282 |
See the L<Role Mapping docs|https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-role-mapping.html> |
| 283 |
for more information. |
| 284 |
|
| 285 |
Query string parameters: |
| 286 |
C<error_trace>, |
| 287 |
C<human> |
| 288 |
|
| 289 |
=head1 TOKEN METHODS |
| 290 |
|
| 291 |
=head2 C<get_token()> |
| 292 |
|
| 293 |
$response = $es->security->get_token( |
| 294 |
body => {...} # required |
| 295 |
); |
| 296 |
|
| 297 |
The C<get_token()> method enables you to create bearer tokens for access without |
| 298 |
requiring basic authentication. |
| 299 |
|
| 300 |
See the L<Token Management docs|https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-tokens.html> |
| 301 |
for more information. |
| 302 |
|
| 303 |
Query string parameters: |
| 304 |
C<error_trace>, |
| 305 |
C<human> |
| 306 |
|
| 307 |
=head2 C<invalidate_token()> |
| 308 |
|
| 309 |
$response = $es->security->invalidate_token( |
| 310 |
body => {...} # required |
| 311 |
); |
| 312 |
|
| 313 |
The C<invalidate_token()> method enables you to invalidate bearer tokens for access without |
| 314 |
requiring basic authentication. |
| 315 |
|
| 316 |
See the L<Token Management docs|https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-tokens.html> |
| 317 |
for more information. |
| 318 |
|
| 319 |
Query string parameters: |
| 320 |
C<error_trace>, |
| 321 |
C<human> |
| 322 |
|
| 323 |
=head1 API KEY METHODS |
| 324 |
|
| 325 |
=head2 C<create_api_key()> |
| 326 |
|
| 327 |
$response = $es->security->create_api_key( |
| 328 |
body => {...} # required |
| 329 |
) |
| 330 |
|
| 331 |
The C<create_api_key()> API is used to create API keys which can be used for access instead |
| 332 |
of basic authentication. |
| 333 |
|
| 334 |
Query string parameters: |
| 335 |
C<error_trace>, |
| 336 |
C<filter_path>, |
| 337 |
C<human>, |
| 338 |
C<refresh> |
| 339 |
|
| 340 |
See the L<Create API Key docs|https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-api-key.html> for more. |
| 341 |
|
| 342 |
=head2 C<get_api_key()> |
| 343 |
|
| 344 |
$response = $es->security->get_api_key( |
| 345 |
id => $id, # optional |
| 346 |
name => $name, # optional |
| 347 |
realm_name => $realm, # optional |
| 348 |
username => $username # optional |
| 349 |
) |
| 350 |
|
| 351 |
The C<get_api_key()> API is used to get information about an API key. |
| 352 |
|
| 353 |
Query string parameters: |
| 354 |
C<error_trace>, |
| 355 |
C<filter_path>, |
| 356 |
C<human>, |
| 357 |
C<id>, |
| 358 |
C<name>, |
| 359 |
C<realm_name>, |
| 360 |
C<username> |
| 361 |
|
| 362 |
See the L<Get API Key docs|https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-api-key.html> for more. |
| 363 |
|
| 364 |
=head2 C<invalidate_api_key()> |
| 365 |
|
| 366 |
$response = $es->security->invalidate_api_key( |
| 367 |
id => $id, # optional |
| 368 |
name => $name, # optional |
| 369 |
realm_name => $realm, # optional |
| 370 |
username => $username # optional |
| 371 |
) |
| 372 |
|
| 373 |
The C<invalidate_api_key()> API is used to invalidate an API key. |
| 374 |
|
| 375 |
Query string parameters: |
| 376 |
C<error_trace>, |
| 377 |
C<filter_path>, |
| 378 |
C<human>, |
| 379 |
C<id>, |
| 380 |
C<name>, |
| 381 |
C<realm_name>, |
| 382 |
C<username> |
| 383 |
|
| 384 |
See the L<Invalidate API Key docs|https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-invalidate-api-key.html> for more. |
| 385 |
|
| 386 |
=head1 USER PRIVILEGE METHODS |
| 387 |
|
| 388 |
=head2 C<get_user_privileges()> |
| 389 |
|
| 390 |
$response = $es->get_user_privileges(); |
| 391 |
|
| 392 |
The C<get_user_privileges()> method retrieves the privileges granted to the current user. |
| 393 |
|
| 394 |
Query string parameters: |
| 395 |
C<error_trace>, |
| 396 |
C<filter_path>, |
| 397 |
C<human> |
| 398 |
|
| 399 |
=head2 C<has_privileges()> |
| 400 |
$response = $es->has_privileges( |
| 401 |
user => $user, # optional |
| 402 |
body => {...} # required |
| 403 |
); |
| 404 |
|
| 405 |
The C<has_privileges()> method checks whether the current or specified user has the listed privileges. |
| 406 |
|
| 407 |
Query string parameters: |
| 408 |
C<error_trace>, |
| 409 |
C<filter_path>, |
| 410 |
C<human> |
| 411 |
|
| 412 |
See the L<Has Privileges docs|https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-has-privileges.html> for more. |
| 413 |
|
| 414 |
=head1 APPLICATION PRIVILEGE METHODS |
| 415 |
|
| 416 |
=head2 C<put_privileges()> |
| 417 |
|
| 418 |
$response = $es->put_privileges( |
| 419 |
application => $application, # required |
| 420 |
name => $name, # required |
| 421 |
body => {...} # required |
| 422 |
); |
| 423 |
|
| 424 |
The C<put_privileges()> method creates or updates the named privilege for a particular application. |
| 425 |
|
| 426 |
Query string parameters: |
| 427 |
C<error_trace>, |
| 428 |
C<filter_path>, |
| 429 |
C<human>, |
| 430 |
C<refresh> |
| 431 |
|
| 432 |
See the L<Create or Update Application Privileges docs|https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-privileges.html> for more. |
| 433 |
|
| 434 |
=head2 C<get_privileges()> |
| 435 |
|
| 436 |
$response = $es->get_privileges( |
| 437 |
application => $application, # required |
| 438 |
name => $name, # required |
| 439 |
); |
| 440 |
|
| 441 |
The C<get_privileges()> method retrieves the named privilege for a particular application. |
| 442 |
|
| 443 |
Query string parameters: |
| 444 |
C<error_trace>, |
| 445 |
C<filter_path>, |
| 446 |
C<human> |
| 447 |
|
| 448 |
See the L<Get Application Privileges docs|https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-privileges.html> for more. |
| 449 |
|
| 450 |
=head2 C<delete_privileges()> |
| 451 |
|
| 452 |
$response = $es->delete_privileges( |
| 453 |
application => $application, # required |
| 454 |
name => $name, # required |
| 455 |
); |
| 456 |
|
| 457 |
The C<delete_privileges()> method deletes the named privilege for a particular application. |
| 458 |
|
| 459 |
Query string parameters: |
| 460 |
C<error_trace>, |
| 461 |
C<filter_path>, |
| 462 |
C<human>, |
| 463 |
C<refresh> |
| 464 |
|
| 465 |
See the L<Delete Application Privileges docs|https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-privilege.html> for more. |
| 466 |
|
| 467 |
=head1 AUTHOR |
| 468 |
|
| 469 |
Enrico Zimuel <[email protected]> |
| 470 |
|
| 471 |
=head1 COPYRIGHT AND LICENSE |
| 472 |
|
| 473 |
This software is Copyright (c) 2024 by Elasticsearch BV. |
| 474 |
|
| 475 |
This is free software, licensed under: |
| 476 |
|
| 477 |
The Apache License, Version 2.0, January 2004 |
| 478 |
|
| 479 |
=cut |
| 480 |
|
| 481 |
__END__ |
| 482 |
|
| 483 |
# ABSTRACT: Plugin providing Security API for Search::Elasticsearch 8.x |
| 484 |
|