From 2174b5c220e995efa732482c60946219f7c1438e Mon Sep 17 00:00:00 2001 From: Colin Stubbs <3059577+colin-stubbs@users.noreply.github.com> Date: Mon, 9 May 2022 18:35:42 +1000 Subject: [PATCH 1/4] Fix for issue #3295 Render of auth.oauth2.scopes fails for custom httpjson input, this will fix the issue --- packages/httpjson/data_stream/generic/manifest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/httpjson/data_stream/generic/manifest.yml b/packages/httpjson/data_stream/generic/manifest.yml index 290f4eb94ef..c4a6699d38b 100644 --- a/packages/httpjson/data_stream/generic/manifest.yml +++ b/packages/httpjson/data_stream/generic/manifest.yml @@ -246,7 +246,7 @@ streams: multi: false required: false - name: oauth_scopes - type: yaml + type: text title: Oauth2 Scopes description: A list of scopes that will be requested during the oauth2 flow. It is optional for all providers. show_user: false From 7b61c169da4d2f62ecb54a057fa6d2c3d5cb87a8 Mon Sep 17 00:00:00 2001 From: Colin Stubbs <3059577+colin-stubbs@users.noreply.github.com> Date: Mon, 9 May 2022 18:48:42 +1000 Subject: [PATCH 2/4] Update changelog related to #3295 --- packages/httpjson/changelog.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/httpjson/changelog.yml b/packages/httpjson/changelog.yml index c4c7463e9c1..0f31eaa45d6 100644 --- a/packages/httpjson/changelog.yml +++ b/packages/httpjson/changelog.yml @@ -1,3 +1,8 @@ +- version: "1.2.2" + changes: + - description: Fixes rendering issue for custom oauth2 scopes + type: bugfix + link: https://github.com/elastic/integrations/pull/3295 - version: "1.2.1" changes: - description: Adds missing `delegated_account` option for Google Oauth2 From 3105bd502829f4a24bbcd759e2652f19de9706b9 Mon Sep 17 00:00:00 2001 From: Colin Stubbs <3059577+colin-stubbs@users.noreply.github.com> Date: Mon, 9 May 2022 20:24:49 +1000 Subject: [PATCH 3/4] Add oauth_scopes test variable --- .../data_stream/generic/_dev/test/system/test-oauth-config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/httpjson/data_stream/generic/_dev/test/system/test-oauth-config.yml b/packages/httpjson/data_stream/generic/_dev/test/system/test-oauth-config.yml index 86d1ac30a7d..815a677dc77 100644 --- a/packages/httpjson/data_stream/generic/_dev/test/system/test-oauth-config.yml +++ b/packages/httpjson/data_stream/generic/_dev/test/system/test-oauth-config.yml @@ -5,5 +5,6 @@ data_stream: data_stream.dataset: httpjson.generic oauth_id: test oauth_secret: test + oauth_scopes: ["http://{{Hostname}}:{{Port}}/.default"] oauth_token_url: http://{{Hostname}}:{{Port}}/testoauth/token request_url: http://{{Hostname}}:{{Port}}/testoauth/api From cc65a63227bb2b97580fa72b770a2f2368bdc2e3 Mon Sep 17 00:00:00 2001 From: Dan Kortschak Date: Tue, 10 May 2022 13:30:55 +0930 Subject: [PATCH 4/4] add testing and bump stream version --- .../httpjson/_dev/deploy/docker/docker-compose.yml | 2 +- .../httpjson/_dev/deploy/docker/files/config.yml | 14 ++++++++++++++ .../generic/_dev/test/system/test-oauth-config.yml | 1 - .../_dev/test/system/test-oauth-scope-config.yml | 10 ++++++++++ packages/httpjson/manifest.yml | 2 +- 5 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 packages/httpjson/data_stream/generic/_dev/test/system/test-oauth-scope-config.yml diff --git a/packages/httpjson/_dev/deploy/docker/docker-compose.yml b/packages/httpjson/_dev/deploy/docker/docker-compose.yml index b480f3793ec..9c2cce542fa 100644 --- a/packages/httpjson/_dev/deploy/docker/docker-compose.yml +++ b/packages/httpjson/_dev/deploy/docker/docker-compose.yml @@ -1,7 +1,7 @@ version: "2.3" services: httpjson: - image: docker.elastic.co/observability/stream:v0.6.1 + image: docker.elastic.co/observability/stream:v0.7.0 ports: - 8080 volumes: diff --git a/packages/httpjson/_dev/deploy/docker/files/config.yml b/packages/httpjson/_dev/deploy/docker/files/config.yml index 217f51ce802..824a4ab4eb3 100644 --- a/packages/httpjson/_dev/deploy/docker/files/config.yml +++ b/packages/httpjson/_dev/deploy/docker/files/config.yml @@ -52,6 +52,20 @@ rules: - "application/json" body: |- {"access_token": "testaccess","token_type": "Bearer","expires_in": 172799,"refresh_token": "testrefresh"} + - path: /testoauth/scopedtoken + methods: [POST] + query_params: + scope: token_scope + request_headers: + Content-Type: + - application/x-www-form-urlencoded + responses: + - status_code: 200 + headers: + Content-Type: + - "application/json" + body: |- + {"access_token": "testaccess","token_type": "Bearer","expires_in": 172799,"refresh_token": "testrefresh"} - path: /testoauth/api methods: ["GET"] request_headers: diff --git a/packages/httpjson/data_stream/generic/_dev/test/system/test-oauth-config.yml b/packages/httpjson/data_stream/generic/_dev/test/system/test-oauth-config.yml index 815a677dc77..86d1ac30a7d 100644 --- a/packages/httpjson/data_stream/generic/_dev/test/system/test-oauth-config.yml +++ b/packages/httpjson/data_stream/generic/_dev/test/system/test-oauth-config.yml @@ -5,6 +5,5 @@ data_stream: data_stream.dataset: httpjson.generic oauth_id: test oauth_secret: test - oauth_scopes: ["http://{{Hostname}}:{{Port}}/.default"] oauth_token_url: http://{{Hostname}}:{{Port}}/testoauth/token request_url: http://{{Hostname}}:{{Port}}/testoauth/api diff --git a/packages/httpjson/data_stream/generic/_dev/test/system/test-oauth-scope-config.yml b/packages/httpjson/data_stream/generic/_dev/test/system/test-oauth-scope-config.yml new file mode 100644 index 00000000000..392895d7a6e --- /dev/null +++ b/packages/httpjson/data_stream/generic/_dev/test/system/test-oauth-scope-config.yml @@ -0,0 +1,10 @@ +input: httpjson +service: httpjson +data_stream: + vars: + data_stream.dataset: httpjson.generic + oauth_id: test + oauth_secret: test + oauth_scopes: ["token_scope"] + oauth_token_url: http://{{Hostname}}:{{Port}}/testoauth/scopedtoken + request_url: http://{{Hostname}}:{{Port}}/testoauth/api diff --git a/packages/httpjson/manifest.yml b/packages/httpjson/manifest.yml index bffdac60262..91bd750cf3c 100644 --- a/packages/httpjson/manifest.yml +++ b/packages/httpjson/manifest.yml @@ -3,7 +3,7 @@ name: httpjson title: Custom HTTPJSON Input description: Collect custom data from REST API's with Elastic Agent. type: integration -version: 1.2.1 +version: 1.2.2 release: ga conditions: kibana.version: "^7.16.0 || ^8.0.0"