Skip to content

Commit

Permalink
Point OpenSearch Dashboards to to new back end APIs (opensearch-proje…
Browse files Browse the repository at this point in the history
  • Loading branch information
hsiang9431-amzn authored May 27, 2021
1 parent 9538f75 commit b366325
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 30 deletions.
84 changes: 69 additions & 15 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,75 @@ jobs:
name: Run integration tests
runs-on: ubuntu-latest
steps:
# build backend plugin
- name: Set up JDK 14
uses: actions/setup-java@v1
with:
java-version: 14.0.x

- name: Cache Maven packages
uses: actions/cache@v1
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: Checkout OpenSearch
uses: actions/checkout@v2
with:
repository: 'opensearch-project/OpenSearch'
path: OpenSearch
ref: '1.x'

- name: Build OpenSearch
working-directory: ./OpenSearch
run: ./gradlew publishToMavenLocal -Dbuild.version_qualifier=rc1 -Dbuild.snapshot=false

- name: Checkout security
uses: actions/checkout@v2
with:
repository: 'opensearch-project/security'
path: security
ref: 'main'

- name: Package
working-directory: ./security
run: mvn -B clean package -Padvanced -DskipTests

- name: Download OpenSearch Core
run: |
wget https://artifacts.opensearch.org/snapshots/core/opensearch/1.0.0-rc1/opensearch-1.0.0-rc1-SNAPSHOT-linux-x64-latest.tar.gz
tar -xzf opensearch-*.tar.gz
- name: Run OpenSearch with plugin
run: |
docker build -t opensearch-test:1.0.0-beta1 -<<EOF
FROM opensearchstaging/opensearch:1.0.0-beta1
RUN echo "opendistro_security.unsupported.restapi.allow_securityconfig_modification: true" >> config/opensearch.yml
RUN echo "discovery.type: single-node" >> config/opensearch.yml
ENTRYPOINT bin/opensearch
cat > os-ep.sh <<EOF
yes | opensearch-plugin install file:///docker-host/security-plugin.zip
chmod +x plugins/opensearch-security/tools/install_demo_configuration.sh
yes | plugins/opensearch-security/tools/install_demo_configuration.sh
echo "plugins.security.unsupported.restapi.allow_securityconfig_modification: true" >> /opensearch/config/opensearch.yml
chown 1001:1001 -R /opensearch
su -c "/opensearch/bin/opensearch" -s /bin/bash opensearch
EOF
docker build -t opensearch-test:latest -f- . <<EOF
FROM ubuntu:latest
COPY --chown=1001:1001 os-ep.sh /docker-host/
COPY --chown=1001:1001 security/target/releases/opensearch-security-1.0.0.0-beta1.zip /docker-host/security-plugin.zip
COPY --chown=1001:1001 opensearch* /opensearch/
RUN chmod +x /docker-host/os-ep.sh
RUN useradd -u 1001 -s /sbin/nologin opensearch
ENV PATH="/opensearch/bin:${PATH}"
WORKDIR /opensearch/
ENTRYPOINT /docker-host/os-ep.sh
EOF
docker run -d -p 9200:9200 -p 9600:9600 -i opensearch-test:1.0.0-beta1
docker run -d -p 9200:9200 -p 9600:9600 -i opensearch-test:latest
- name: Checkout OpenSearch Dashboard
uses: actions/checkout@v2
with:
path: OpenSearch-Dashboards
repository: opensearch-project/OpenSearch-Dashboards
ref: '1.0'
fetch-depth: 0

- name: Create plugins dir
Expand All @@ -45,15 +99,15 @@ jobs:
continue-on-error: true
run: curl -XGET https://localhost:9200 -u 'admin:admin' -k

- name: Get OpenSearch Dashboards version
id: osd_version
run: |
echo "::set-output name=osd_version::$(jq -r '.opensearchDashboards.version' ./OpenSearch-Dashboards/plugins/security-dashboards-plugin/package.json)"
# - name: Get OpenSearch Dashboards version
# id: osd_version
# run: |
# echo "::set-output name=osd_version::$(jq -r '.opensearchDashboards.version' ./OpenSearch-Dashboards/plugins/security-dashboards-plugin/package.json)"

- name: Check OpenSearch Dashboards release tag
run: |
cd ./OpenSearch-Dashboards
git checkout tags/${{ steps.osd_version.outputs.osd_version }} -b v${{ steps.osd_version.outputs.osd_version }}
# - name: Check OpenSearch Dashboards release tag
# run: |
# cd ./OpenSearch-Dashboards
# git checkout tags/${{ steps.osd_version.outputs.osd_version }} -b v${{ steps.osd_version.outputs.osd_version }}

- name: Get node and yarn versions
id: versions
Expand Down
18 changes: 9 additions & 9 deletions server/backend/opensearch_security_configuration_plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function (Client: any, config: any, components: any) {

Client.prototype.opensearch_security.prototype.restapiinfo = ca({
url: {
fmt: '/_opendistro/_security/api/permissionsinfo',
fmt: '/_plugins/_security/api/permissionsinfo',
},
});

Expand All @@ -49,7 +49,7 @@ export default function (Client: any, config: any, components: any) {
*/
Client.prototype.opensearch_security.prototype.listResource = ca({
url: {
fmt: '/_opendistro/_security/api/<%=resourceName%>',
fmt: '/_plugins/_security/api/<%=resourceName%>',
req: {
resourceName: {
type: 'string',
Expand All @@ -76,7 +76,7 @@ export default function (Client: any, config: any, components: any) {
method: 'PUT',
needBody: true,
url: {
fmt: '/_opendistro/_security/api/<%=resourceName%>/<%=id%>',
fmt: '/_plugins/_security/api/<%=resourceName%>/<%=id%>',
req: {
resourceName: {
type: 'string',
Expand Down Expand Up @@ -104,7 +104,7 @@ export default function (Client: any, config: any, components: any) {
method: 'PUT',
needBody: true,
url: {
fmt: '/_opendistro/_security/api/<%=resourceName%>',
fmt: '/_plugins/_security/api/<%=resourceName%>',
req: {
resourceName: {
type: 'string',
Expand All @@ -128,7 +128,7 @@ export default function (Client: any, config: any, components: any) {
Client.prototype.opensearch_security.prototype.getResource = ca({
method: 'GET',
url: {
fmt: '/_opendistro/_security/api/<%=resourceName%>/<%=id%>',
fmt: '/_plugins/_security/api/<%=resourceName%>/<%=id%>',
req: {
resourceName: {
type: 'string',
Expand All @@ -148,7 +148,7 @@ export default function (Client: any, config: any, components: any) {
Client.prototype.opensearch_security.prototype.deleteResource = ca({
method: 'DELETE',
url: {
fmt: '/_opendistro/_security/api/<%=resourceName%>/<%=id%>',
fmt: '/_plugins/_security/api/<%=resourceName%>/<%=id%>',
req: {
resourceName: {
type: 'string',
Expand All @@ -168,7 +168,7 @@ export default function (Client: any, config: any, components: any) {
Client.prototype.opensearch_security.prototype.clearCache = ca({
method: 'DELETE',
url: {
fmt: '/_opendistro/_security/api/cache',
fmt: '/_plugins/_security/api/cache',
},
});

Expand Down Expand Up @@ -206,7 +206,7 @@ export default function (Client: any, config: any, components: any) {
Client.prototype.opensearch_security.prototype.getAudit = ca({
method: 'GET',
url: {
fmt: '/_opendistro/_security/api/audit',
fmt: '/_plugins/_security/api/audit',
},
});

Expand All @@ -217,7 +217,7 @@ export default function (Client: any, config: any, components: any) {
method: 'PUT',
needBody: true,
url: {
fmt: '/_opendistro/_security/api/audit/config',
fmt: '/_plugins/_security/api/audit/config',
},
});
}
8 changes: 4 additions & 4 deletions server/backend/opensearch_security_plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default function (Client: any, config: any, components: any) {
*/
Client.prototype.opensearch_security.prototype.authinfo = ca({
url: {
fmt: '/_opendistro/_security/authinfo',
fmt: '/_plugins/_security/authinfo',
},
});

Expand All @@ -44,7 +44,7 @@ export default function (Client: any, config: any, components: any) {
*/
Client.prototype.opensearch_security.prototype.multitenancyinfo = ca({
url: {
fmt: '/_opendistro/_security/kibanainfo',
fmt: '/_plugins/_security/dashboardsinfo',
},
});

Expand All @@ -56,7 +56,7 @@ export default function (Client: any, config: any, components: any) {
*/
Client.prototype.opensearch_security.prototype.tenantinfo = ca({
url: {
fmt: '/_opendistro/_security/tenantinfo',
fmt: '/_plugins/_security/tenantinfo',
},
});

Expand All @@ -67,7 +67,7 @@ export default function (Client: any, config: any, components: any) {
method: 'POST',
needBody: true,
url: {
fmt: '/_opendistro/_security/api/authtoken',
fmt: '/_plugins/_security/api/authtoken',
},
});
}
4 changes: 2 additions & 2 deletions test/jest_integration/basic_auth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ describe('start OpenSearch Dashboards server', () => {

// update ES security config to enable anonymous auth
const getConfigResponse = await wreck.get(
'https://localhost:9200/_opendistro/_security/api/securityconfig',
'https://localhost:9200/_plugins/_security/api/securityconfig',
{
rejectUnauthorized: false,
headers: {
Expand All @@ -105,7 +105,7 @@ describe('start OpenSearch Dashboards server', () => {
try {
config.dynamic!.http!.anonymous_auth_enabled = true;
const updateConfigResponse = await wreck.put(
'https://localhost:9200/_opendistro/_security/api/securityconfig/config',
'https://localhost:9200/_plugins/_security/api/securityconfig/config',
{
payload: config,
rejectUnauthorized: false,
Expand Down

0 comments on commit b366325

Please sign in to comment.