vechain / thor

A general purpose blockchain highly compatible with Ethereum's ecosystem
GNU Lesser General Public License v3.0
799 stars 248 forks source link

CORS + Cookies flags #790

Open otherview opened 1 month ago

otherview commented 1 month ago

Description

This is a tentative fix for https://github.com/vechain/b3tr/issues/1123#issuecomment-2219331553

Issue:

This PR adds the following flags: api-allowed-creds and api-allowed-origins that used together changes the response headers so that it's ok to use Cookies and CORS.

api-allowed-creds sets the Access-Control-Allow-Credentials header to true. api-allowed-origins sets the Access-Control-Allow-Origin to be set as the Origin request.

Example: Before Request{ Type:GET, To:www.yahoo.com, Header{'Origin:www.google.com', 'Access-Control-Allow-Credentials: true'}} Response{ Type:GET, To:www.yahoo.com, Header{Access-Control-Allow-Origin:"*"}} - which fails

With flags enabled Request{ Type:GET, To:www.yahoo.com, Header{'Origin:www.google.com', 'Access-Control-Allow-Credentials: true'}} Response{ Type:GET, To:www.yahoo.com, Header{Access-Control-Allow-Origin:"www.google.com", 'Access-Control-Allow-Credentials: true'}} - which is ok

Fixes # (issue)

Type of change

Please delete options that are not relevant.

How Has This Been Tested?

Checklist:

codecov-commenter commented 1 month ago

Codecov Report

Attention: Patch coverage is 0% with 16 lines in your changes missing coverage. Please review.

Project coverage is 62.63%. Comparing base (e5d76aa) to head (7180749).

Files Patch % Lines
api/api.go 0.00% 8 Missing :warning:
cmd/thor/main.go 0.00% 8 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #790 +/- ## ========================================== - Coverage 62.65% 62.63% -0.03% ========================================== Files 199 199 Lines 18196 18210 +14 ========================================== + Hits 11401 11405 +4 - Misses 5713 5724 +11 + Partials 1082 1081 -1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

kgapos commented 1 month ago

Now that google scraps their plan to block 3rd party cookies, perhaps it's a good idea to explore this implementation further?