Skip to content

Commit

Permalink
Additional logging in role loader and fixing of YAML
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-tavares committed Jul 25, 2023
1 parent ab29f37 commit e0d00ac
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 14 deletions.
@@ -1,4 +1,12 @@
# -----
# Source: https://github.com/elastic/project-controller/blob/main/internal/project/security/config/roles.yml
#
# Changes that needed to be done locally here:
#
# 1. indentation of 'privileges' for role endpoint_operations_manager was not correct
# 2. instances of 'application.spaces.privileges[0]' of '*' were changed to 'all'
#
# -----
t1_analyst:
cluster:
indices:
Expand Down Expand Up @@ -48,7 +56,7 @@ t1_analyst:
resources: "*"
- application: spaces
privileges:
- "*"
- all
resources: "*"

t2_analyst:
Expand Down Expand Up @@ -102,7 +110,7 @@ t2_analyst:
resources: "*"
- application: spaces
privileges:
- "*"
- all
resources: "*"

t3_analyst:
Expand Down Expand Up @@ -177,7 +185,7 @@ t3_analyst:
resources: "*"
- application: spaces
privileges:
- "*"
- all
resources: "*"

threat_intelligence_analyst:
Expand Down Expand Up @@ -234,7 +242,7 @@ threat_intelligence_analyst:
resources: "*"
- application: spaces
privileges:
- "*"
- all
resources: "*"

rule_author:
Expand Down Expand Up @@ -306,7 +314,7 @@ rule_author:
resources: "*"
- application: spaces
privileges:
- "*"
- all
resources: "*"

soc_manager:
Expand Down Expand Up @@ -381,7 +389,7 @@ soc_manager:
resources: "*"
- application: spaces
privileges:
- "*"
- all
resources: "*"

detections_admin:
Expand Down Expand Up @@ -441,7 +449,7 @@ detections_admin:
resources: "*"
- application: spaces
privileges:
- "*"
- all
resources: "*"

platform_engineer:
Expand Down Expand Up @@ -497,7 +505,7 @@ platform_engineer:
resources: "*"
- application: spaces
privileges:
- "*"
- all
resources: "*"

endpoint_operations_manager:
Expand Down
Expand Up @@ -17,7 +17,7 @@ import {
ServerlessSecurityRoles,
} from './kibana_roles';

const igonoreHttp409Error = (error: AxiosError) => {
const ignoreHttp409Error = (error: AxiosError) => {
if (error?.response?.status === 409) {
return;
}
Expand Down Expand Up @@ -67,11 +67,15 @@ export class RoleAndUserLoader<R extends Record<string, Role> = Record<string, R
await this.kbnClient
.request({
method: 'PUT',
path: `/api/security/role/${roleName}?createOnly=true`,
path: `/api/security/role/${roleName}`,
body: roleDefinition,
})
.catch(igonoreHttp409Error)
.catch(this.logPromiseError);
.catch(ignoreHttp409Error)
.catch(this.logPromiseError)
.then((response) => {
this.logger.info(`Role [${role}] created/updated`, response?.data);
return response;
});
}

private async createUser(
Expand All @@ -95,8 +99,12 @@ export class RoleAndUserLoader<R extends Record<string, Role> = Record<string, R
path: `/internal/security/users/${username}`,
body: user,
})
.catch(igonoreHttp409Error)
.catch(this.logPromiseError);
.catch(ignoreHttp409Error)
.catch(this.logPromiseError)
.then((response) => {
this.logger.info(`User [${username}] created/updated`, response?.data);
return response;
});
}
}

Expand Down

0 comments on commit e0d00ac

Please sign in to comment.