Skip to content

Latest commit

 

History

History
59 lines (44 loc) · 1.23 KB

security.md

File metadata and controls

59 lines (44 loc) · 1.23 KB

Security Plugin

The Security Plugin API lets you programmatically create and manage users, roles, role mappings, action groups, and tenants.

Create a Role

role_name = "test-role"

role_content = {
  "cluster_permissions": ["cluster_monitor"],
  "index_permissions": [
      {
          "index_patterns": ["index", "test-*"],
          "allowed_actions": [
              "data_access",
              "indices_monitor",
          ],
      }
  ],
}

response = client.security.create_role(role_name, body=role_content)
print(response)

Get a Role

role_name = "test-role"

response = client.security.get_role(role_name)
print(response)

Create a User

user_name = "test-user"
user_content = {"password": "test_password", "opendistro_security_roles": []}

response = client.security.create_user(user_name, body=user_content)
print(response)

Get a User

user_name = "test-user"

response = client.security.get_user(user_name)
print(response)