-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add feature to support customized config files to the cluster (#82)
Signed-off-by: Sayali Gaikawad <[email protected]>
- Loading branch information
Showing
6 changed files
with
119 additions
and
10 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 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,23 @@ | ||
--- | ||
_meta: | ||
type: "allowlist" | ||
config_version: 2 | ||
|
||
# Description: | ||
# enabled - feature flag. | ||
# if enabled is false, all endpoints are accessible. | ||
# if enabled is true, all users except the SuperAdmin can only submit the allowed requests to the specified endpoints. | ||
# SuperAdmin can access all APIs. | ||
# SuperAdmin is defined by the SuperAdmin certificate, which is configured with the opensearch.yml setting plugins.security.authcz.admin_dn: | ||
# Refer to the example setting in opensearch.yml to learn more about configuring SuperAdmin. | ||
# | ||
# requests - map of allow listed endpoints and HTTP requests | ||
|
||
#this name must be config | ||
config: | ||
enabled: true | ||
requests: | ||
/_cluster/settings: | ||
- GET | ||
/_cat/nodes: | ||
- GET |
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,27 @@ | ||
--- | ||
complex-role: | ||
reserved: false | ||
hidden: false | ||
cluster_permissions: | ||
- "read" | ||
- "cluster:monitor/nodes/stats" | ||
- "cluster:monitor/task/get" | ||
index_permissions: | ||
- index_patterns: | ||
- "opensearch_dashboards_sample_data_*" | ||
dls: "{\"match\": {\"FlightDelay\": true}}" | ||
fls: | ||
- "~FlightNum" | ||
masked_fields: | ||
- "Carrier" | ||
allowed_actions: | ||
- "read" | ||
tenant_permissions: | ||
- tenant_patterns: | ||
- "analyst_*" | ||
allowed_actions: | ||
- "kibana_all_write" | ||
static: false | ||
_meta: | ||
type: "roles" | ||
config_version: 2 |
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 |
---|---|---|
|
@@ -24,6 +24,8 @@ test('Test Resources with security disabled multi-node default instance types', | |
restrictServerAccessTo: 'all', | ||
additionalConfig: '{ "name": "John Doe", "age": 30, "email": "[email protected]" }', | ||
additionalOsdConfig: '{ "something.enabled": "true", "something_else.enabled": "false" }', | ||
// eslint-disable-next-line max-len | ||
customConfigFiles: '{"test/data/config.yml": "opensearch/config/opensearch-security/config.yml", "test/data/roles.yml": "opensearch/config/opensearch-security/roles.yml"}', | ||
}, | ||
}); | ||
|
||
|
@@ -489,3 +491,36 @@ test('Test multi-node cluster with custom IAM Role', () => { | |
Roles: ['customRoleName'], | ||
}); | ||
}); | ||
|
||
test('Throw error on incorrect JSON', () => { | ||
const app = new App({ | ||
context: { | ||
securityDisabled: true, | ||
minDistribution: false, | ||
distributionUrl: 'www.example.com', | ||
cpuArch: 'x64', | ||
singleNodeCluster: false, | ||
dashboardsUrl: 'www.example.com', | ||
distVersion: '1.0.0', | ||
serverAccessType: 'ipv4', | ||
restrictServerAccessTo: 'all', | ||
additionalConfig: '{ "name": "John Doe", "age": 30, "email": "[email protected]" }', | ||
additionalOsdConfig: '{ "something.enabled": "true", "something_else.enabled": "false" }', | ||
// eslint-disable-next-line max-len | ||
customConfigFiles: '{"test/data/config.yml": opensearch/config/opensearch-security/config.yml"}', | ||
}, | ||
}); | ||
// WHEN | ||
try { | ||
const testStack = new OsClusterEntrypoint(app, { | ||
env: { account: 'test-account', region: 'us-east-1' }, | ||
}); | ||
|
||
// eslint-disable-next-line no-undef | ||
fail('Expected an error to be thrown'); | ||
} catch (error) { | ||
expect(error).toBeInstanceOf(Error); | ||
// eslint-disable-next-line max-len | ||
expect(error.message).toEqual('Encountered following error while parsing customConfigFiles json parameter: SyntaxError: Unexpected token o in JSON at position 25'); | ||
} | ||
}); |