Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify opensearch users with customized passwords #141

Merged
merged 3 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions nightly-playground/lib/nightly-playground-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,17 @@ export class NightlyPlaygroundStack {
if (dashboardsUrl === 'undefined') {
throw new Error('dashboardsUrl parameter cannot be empty! Please provide the OpenSearch-Dashboards distribution URL');
}
const dashboardPassword = scope.node.tryGetContext('dashboardPassword');
Copy link

@rishabh6788 rishabh6788 Feb 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IS this user different from admin user or is this for kibanaserver user?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is password for kibanaserver user. I kept the username same. Just customized the password.

if (dashboardPassword === 'undefined') {
throw new Error('dashboardPassword parameter cannot be empty! Please provide the OpenSearch-Dashboards customized password for kibanauser');
}

const additionalOsdConfigString = `{"opensearch_security.auth.anonymous_auth_enabled": "true", "opensearch.password": "${dashboardPassword}"}`;

const securtityConfig = '{ "resources/security-config/config.yml" : "opensearch/config/opensearch-security/config.yml", '
+ '"resources/security-config/roles_mapping.yml" : "opensearch/config/opensearch-security/roles_mapping.yml", '
+ '"resources/security-config/roles.yml" : "opensearch/config/opensearch-security/roles.yml"}';
+ '"resources/security-config/roles.yml" : "opensearch/config/opensearch-security/roles.yml", '
+ '"resources/security-config/internal_users.yml": "opensearch/config/opensearch-security/internal_users.yml"}';

// @ts-ignore
const networkStack = new NetworkStack(scope, `networkStack-${id}`, {
Expand All @@ -54,7 +61,7 @@ export class NightlyPlaygroundStack {
singleNodeCluster: false,
dashboardsUrl,
customConfigFiles: securtityConfig,
additionalOsdConfig: '{"opensearch_security.auth.anonymous_auth_enabled": "true"}',
additionalOsdConfig: additionalOsdConfigString,
});
this.stacks.push(infraStack);

Expand Down
14 changes: 7 additions & 7 deletions nightly-playground/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion nightly-playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"typescript": "~3.9.7"
},
"dependencies": {
"@opensearch-project/opensearch-cluster-cdk": "1.0.1",
"@opensearch-project/opensearch-cluster-cdk": "1.1.0",
"@types/babel__traverse": "^7.18.2",
"@typescript-eslint/eslint-plugin": "^4.31.1",
"@typescript-eslint/parser": "^4.31.1",
Expand Down
40 changes: 40 additions & 0 deletions nightly-playground/resources/security-config/internal_users.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
# This is the internal user database
# The hash value is a bcrypt hash and can be generated with plugin/tools/hash.sh

_meta:
type: 'internalusers'
config_version: 2

# Define your internal users here

admin:
hash: '\$2y\$12\$fkypbXL0jRI5T25GNBJB3uhPnixWJVPGhFGIQoIaoWuUAQzzOfe3G'
reserved: true
backend_roles:
- "admin"
description: "Admin user with customized password"

kibanaserver:
hash: '\$2y\$12\$t17cD/p.ZlsR2jOav7fYfuzk0sWrq1GXZihq3eWsbqXheSJk8Nr2O'
reserved: true
description: "OpenSearch Dashboards user with customized password"

kibanaro:
hash: '\$2a\$12\$JJSXNfTowz7Uu5ttXfeYpeYE0arACvcwlPBStB1F.MI7f0U9Z4DGC'
reserved: false
backend_roles:
- "kibanauser"
- "readall"
attributes:
attribute1: "value1"
attribute2: "value2"
attribute3: "value3"
description: "Demo read-only user for OpenSearch dashboards"

readall:
hash: '\$2a\$12\$ae4ycwzwvLtZxwZ82RmiEunBbIPiAmGZduBAjKN0TXdwQFtCwARz2'
reserved: false
backend_roles:
- "readall"
description: "Demo readall user"
10 changes: 0 additions & 10 deletions nightly-playground/resources/security-config/roles_mapping.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ own_index:
- "*"
description: "Allow full access to an index named like the username"

logstash:
reserved: false
backend_roles:
- "logstash"

kibana_user:
reserved: false
backend_roles:
Expand All @@ -40,11 +35,6 @@ readall:
backend_roles:
- "readall"

manage_snapshots:
reserved: false
backend_roles:
- "snapshotrestore"

kibana_server:
reserved: true
users:
Expand Down
Loading
Loading