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

Pass request headers when making application config calls #6164

Merged
merged 7 commits into from
Mar 19, 2024

Conversation

tianleh
Copy link
Member

@tianleh tianleh commented Mar 15, 2024

Description

Application config plugin allows external plugin to register a different storage other than the default OpenSearch. The external plugin may need some additional information about the request headers when handling the requests.

Issues Resolved

Screenshot

Testing the changes

Update the csp rules.

call

curl 'http://localhost:5601/api/appconfig/csp.rules' -X POST -H 'Accept: application/json' -H 'Content-Type: application/json' -H 'osd-xsrf: osd-fetch' -H 'Sec-Fetch-Dest: empty' --data-raw '{"newValue":"frame-ancestors https://example-site.org"}'

response

{"newValue":"frame-ancestors https://example-site.org"}%

Confirm on UI that the new value is used.

Screenshot 2024-03-15 at 2 51 39 PM

Check API calls to all configs

curl 'http://localhost:5601/api/appconfig'

response

{"value":{"csp.rules":"frame-ancestors https://example-site.org"}}%

Check API to get only csp rules.

curl 'http://localhost:5601/api/appconfig/csp.rules'

response

{"value":"frame-ancestors https://example-site.org"}%

Delete

curl 'http://localhost:5601/api/appconfig/csp.rules' -X DELETE -H 'osd-xsrf: osd-fetch' -H 'Sec-Fetch-Dest: empty'

Response

{"deletedEntity":"csp.rules"}%

Get all again

curl 'http://localhost:5601/api/appconfig'

response

{"value":{}}%

verify that default csp with frame ancestors is used.

Screenshot 2024-03-15 at 2 52 04 PM

Check List

  • All tests pass
    • yarn test:jest
    • yarn test:jest_integration
  • New functionality includes testing.
  • New functionality has been documented.
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

Copy link

codecov bot commented Mar 15, 2024

Codecov Report

Attention: Patch coverage is 90.00000% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 67.24%. Comparing base (a9e874f) to head (b607403).

Files Patch % Lines
.../plugins/application_config/server/routes/index.ts 88.88% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6164      +/-   ##
==========================================
+ Coverage   67.21%   67.24%   +0.02%     
==========================================
  Files        3344     3344              
  Lines       64792    64796       +4     
  Branches    10427    10427              
==========================================
+ Hits        43552    43572      +20     
+ Misses      18697    18683      -14     
+ Partials     2543     2541       -2     
Flag Coverage Δ
Linux_1 31.64% <ø> (?)
Linux_2 55.45% <ø> (ø)
Linux_3 44.69% <90.00%> (+<0.01%) ⬆️
Linux_4 35.06% <ø> (ø)
Windows_1 31.67% <ø> (ø)
Windows_2 55.41% <ø> (?)
Windows_3 44.70% <90.00%> (+<0.01%) ⬆️
Windows_4 35.06% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tianleh tianleh force-pushed the update-request branch 2 times, most recently from 93dcf8a to 34703ce Compare March 16, 2024 07:02
@tianleh
Copy link
Member Author

tianleh commented Mar 18, 2024

kavilla
kavilla previously approved these changes Mar 18, 2024
tianleh added 7 commits March 18, 2024 22:57
Signed-off-by: Tianle Huang <[email protected]>
Signed-off-by: Tianle Huang <[email protected]>
Signed-off-by: Tianle Huang <[email protected]>
Signed-off-by: Tianle Huang <[email protected]>
Signed-off-by: Tianle Huang <[email protected]>
Signed-off-by: Tianle Huang <[email protected]>
Copy link
Member

@kavilla kavilla left a comment

Choose a reason for hiding this comment

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

Cypress test likely to fail unrelated

@bandinib-amzn
Copy link
Member

Re-running failed CI

@kavilla kavilla merged commit bfab07c into opensearch-project:main Mar 19, 2024
68 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Mar 19, 2024
Application config plugin allows external plugin to register a different storage other than the default OpenSearch. The external plugin may need some additional information about the request headers when handling the requests.

* Allow extra information in the application config calls

Signed-off-by: Tianle Huang <[email protected]>

* only expose headers

Signed-off-by: Tianle Huang <[email protected]>

* update jsdoc

Signed-off-by: Tianle Huang <[email protected]>

* add more logs

Signed-off-by: Tianle Huang <[email protected]>

* update change log

Signed-off-by: Tianle Huang <[email protected]>

* update readme

Signed-off-by: Tianle Huang <[email protected]>

* update readme

Signed-off-by: Tianle Huang <[email protected]>

---------

Signed-off-by: Tianle Huang <[email protected]>
(cherry picked from commit bfab07c)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

# Conflicts:
#	CHANGELOG.md
kavilla pushed a commit that referenced this pull request Mar 19, 2024
)

Application config plugin allows external plugin to register a different storage other than the default OpenSearch. The external plugin may need some additional information about the request headers when handling the requests.

* Allow extra information in the application config calls

Signed-off-by: Tianle Huang <[email protected]>

* only expose headers

Signed-off-by: Tianle Huang <[email protected]>

* update jsdoc

Signed-off-by: Tianle Huang <[email protected]>

* add more logs

Signed-off-by: Tianle Huang <[email protected]>

* update change log

Signed-off-by: Tianle Huang <[email protected]>

* update readme

Signed-off-by: Tianle Huang <[email protected]>

* update readme

Signed-off-by: Tianle Huang <[email protected]>

---------

Signed-off-by: Tianle Huang <[email protected]>
(cherry picked from commit bfab07c)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

# Conflicts:
#	CHANGELOG.md

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants