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

Allow configuring CORS origins in config file #811

Merged
merged 9 commits into from
Mar 16, 2023
Merged

Conversation

baont
Copy link
Contributor

@baont baont commented Feb 23, 2023

This is my implementation for the issue #754.

Motivation
Provide a way to configure CORS policies, so that web applications hosted in a different origin can call Central Dogma REST API.

Modifications

  • Add corsAllowedOrigins to CentralDogmaConfig
  • Add Cors decorator when setting up HttpApi

Result:

@CLAassistant
Copy link

CLAassistant commented Feb 23, 2023

CLA assistant check
All committers have signed the CLA.

@codecov
Copy link

codecov bot commented Feb 23, 2023

Codecov Report

Patch coverage: 86.84% and project coverage change: -0.11 ⚠️

Comparison is base (bda3bec) 65.71% compared to head (84a7a94) 65.61%.

Additional details and impacted files
@@             Coverage Diff              @@
##             master     #811      +/-   ##
============================================
- Coverage     65.71%   65.61%   -0.11%     
- Complexity     3289     3319      +30     
============================================
  Files           350      355       +5     
  Lines         13731    13852     +121     
  Branches       1488     1498      +10     
============================================
+ Hits           9024     9089      +65     
- Misses         3863     3917      +54     
- Partials        844      846       +2     
Impacted Files Coverage Δ
...a/com/linecorp/centraldogma/server/CorsConfig.java 78.26% <78.26%> (ø)
...com/linecorp/centraldogma/server/CentralDogma.java 74.61% <100.00%> (+0.57%) ⬆️
...ecorp/centraldogma/server/CentralDogmaBuilder.java 54.19% <100.00%> (+0.71%) ⬆️
...necorp/centraldogma/server/CentralDogmaConfig.java 80.95% <100.00%> (+0.26%) ⬆️

... and 12 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@baont baont force-pushed the config_cors branch 2 times, most recently from 72ee254 to 99e21e4 Compare March 1, 2023 02:11
@baont baont marked this pull request as ready for review March 1, 2023 03:22
Copy link
Contributor

@jrhee17 jrhee17 left a comment

Choose a reason for hiding this comment

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

Looks good! I'm guessing with the next iteration of reviews this PR should be good for merging 👍

- allow using a string or an array of strings to specify cors allowed origins
- fix code style
- use assertJ in tests
Copy link
Contributor

@ikhoon ikhoon left a comment

Choose a reason for hiding this comment

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

Mostly looks good. Left only minor comments.

- don't allow unpositive maxAge
- fix doc
Copy link
Contributor

@ikhoon ikhoon left a comment

Choose a reason for hiding this comment

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

Thanks, @baont! 🚀💯
Left a minor comment.

@ikhoon ikhoon added this to the 0.60.2 milestone Mar 7, 2023
Copy link
Contributor

@jrhee17 jrhee17 left a comment

Choose a reason for hiding this comment

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

I think this will be my last review. Looking really nice 👍 Left only nit comments 🙇

Copy link
Contributor

@jrhee17 jrhee17 left a comment

Choose a reason for hiding this comment

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

Thanks for your patience @baont ! Looks good to me 👍 🚀 💯

Co-authored-by: jrhee17 <guins_j@guins.org>
Copy link
Member

@trustin trustin left a comment

Choose a reason for hiding this comment

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

Excellent work, @baont! 🙇

@jrhee17
Copy link
Contributor

jrhee17 commented Mar 9, 2023

gentle ping @minwoox 😄

@jrhee17
Copy link
Contributor

jrhee17 commented Mar 13, 2023

gentle ping @minwoox 😄

Copy link
Member

@minwoox minwoox left a comment

Choose a reason for hiding this comment

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

Sorry about the late review. Thanks a lot for adding this configuration! 😄

@minwoox minwoox changed the title allow config CORS origins in config file Allow configuring CORS origins in config file Mar 16, 2023
@minwoox minwoox merged commit 9fbb0b6 into line:master Mar 16, 2023
@minwoox
Copy link
Member

minwoox commented Mar 16, 2023

Thanks a lot, @baont! 🎉 🎉 🎉

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.

Provide a way to configure CORS policies
6 participants