This repository was archived by the owner on Mar 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cortex: create superadmin and thehive users
Signed-off-by: Jakub Sokołowski <[email protected]>
- Loading branch information
Showing
7 changed files
with
121 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
--- | ||
- name: Wait for API port to become available | ||
wait_for: | ||
port: '{{ cortex_port }}' | ||
delay: 10 | ||
timeout: 20 | ||
|
||
# This is necessary because this software for no reason whatsoever | ||
# does not run its migrations at startup if ES index doesn't exist. | ||
# There is no harm in calling this route multiple times. | ||
# For more details you can read this issue: | ||
# https://github.com/TheHive-Project/Cortex/issues/305 | ||
- name: Trigger ES index migrations | ||
uri: | ||
url: 'http://localhost:{{ cortex_port }}/api/maintenance/migrate' | ||
method: POST | ||
status_code: 204 | ||
|
||
- name: CHeck if Super Admin exists | ||
uri: | ||
url: 'http://localhost:{{ cortex_port }}/api/user/{{ cortex_admin_user }}' | ||
status_code: [200, 404] | ||
force_basic_auth: yes | ||
user: '{{ cortex_admin_user }}' | ||
password: '{{ cortex_admin_pass }}' | ||
register: check_admin_user | ||
|
||
- name: Create Super Admin user | ||
uri: | ||
url: 'http://localhost:{{ cortex_port }}/api/user' | ||
method: 'POST' | ||
status_code: 201 | ||
force_basic_auth: yes | ||
user: '{{ cortex_admin_user }}' | ||
password: '{{ cortex_admin_pass }}' | ||
body_format: 'json' | ||
body: | ||
name: '{{ cortex_admin_user | mandatory }}' | ||
login: '{{ cortex_admin_user | mandatory }}' | ||
password: '{{ cortex_admin_pass | mandatory }}' | ||
organization: 'cortex' | ||
roles: ['superadmin'] | ||
when: check_admin_user.status == 404 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
--- | ||
- name: Check if organization exists | ||
uri: | ||
url: 'http://localhost:{{ cortex_port }}/api/organization/{{ cortex_org_name }}' | ||
status_code: [200, 404] | ||
force_basic_auth: yes | ||
user: '{{ cortex_admin_user }}' | ||
password: '{{ cortex_admin_pass }}' | ||
register: check_org_exists | ||
|
||
- name: Create organization for TheHive | ||
uri: | ||
url: 'http://localhost:{{ cortex_port }}/api/organization' | ||
method: 'POST' | ||
status_code: 201 | ||
force_basic_auth: yes | ||
user: '{{ cortex_admin_user }}' | ||
password: '{{ cortex_admin_pass }}' | ||
body_format: 'json' | ||
body: | ||
name: '{{ cortex_org_name }}' | ||
description: 'Status Security Incident Response' | ||
status: 'Active' | ||
when: check_org_exists.status == 404 | ||
|
||
- name: Check if The Hive user exists | ||
uri: | ||
url: 'http://localhost:{{ cortex_port }}/api/user/{{ cortex_the_hive_user }}' | ||
status_code: [200, 404] | ||
force_basic_auth: yes | ||
user: '{{ cortex_admin_user }}' | ||
password: '{{ cortex_admin_pass }}' | ||
register: check_thehive_user | ||
|
||
- name: Create API user for TheHive | ||
uri: | ||
url: 'http://localhost:{{ cortex_port }}/api/user' | ||
method: 'POST' | ||
status_code: 201 | ||
force_basic_auth: yes | ||
user: '{{ cortex_admin_user }}' | ||
password: '{{ cortex_admin_pass }}' | ||
body_format: 'json' | ||
body: | ||
name: 'The Hive API User' | ||
login: '{{ cortex_the_hive_user | mandatory }}' | ||
password: '{{ cortex_the_hive_pass | mandatory }}' | ||
organization: '{{ cortex_org_name }}' | ||
roles: ['read', 'analyze', 'orgadmin'] | ||
when: check_thehive_user.status == 404 | ||
register: cortex_the_hive_user_creation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters