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

RcpServer: Fixed CORS and Basic Auth #812

Merged
merged 18 commits into from
Jan 4, 2024

Conversation

cschuchardt88
Copy link
Member

@cschuchardt88 cschuchardt88 commented Aug 28, 2023

closes #811

Change Log

  • Fixed basic auth to work now, and popup auth window in browser
  • Fixed CORS with basic auth
  • Added AllowOrigins for basic auth to work (config.json)

Fixed CORS with basic auth
Added AllowOrigins for basic auth to work
@shargon shargon self-requested a review August 28, 2023 08:37
cschuchardt88 and others added 4 commits August 28, 2023 05:32
Fixed a typo with EnableCors using SessionEnabled for default value if no value is present for EnableCors.

>Copy and paste isn't your friend sometimes.
@vncoelho
Copy link
Member

vncoelho commented Sep 4, 2023

We are facing some CORS issue using Gitpod.

I tried to re-route C# RPC Plugin with express node, using Axios to make the post request.
Then it worked. The Gitpod behaved normally withour CORS problems.

I am not understanding why the browser is having issues with the request directly to the RPC plugin.

The strange situation is that this just happens when there are multiple requests. Let's say 5 requests per second.

@cschuchardt88
Copy link
Member Author

Some stuff to note here is the KeepAliveTimeout is hard coded to 1 minute and the max allow concurrent connections is configurable in the config.json aka open connections. More than likely the browser is sending Keep-Alive header. But note CORS specification states that setting origins to "*" (all origins) is invalid if the Access-Control-Allow-Credentials header is present aka basic authentication headers & cookies.

But if you could elaborate a little bit more. Like what is C# RPC Plugin? RpcClient? Also did this PR fix the issue at hand? Your having another issue with multi-requests per second? with or without the code changes?

@vncoelho
Copy link
Member

vncoelho commented Sep 4, 2023

@cschuchardt88, considering your comment it was found that MaxConcurrentConnections was the problem for our case.
The good part is that I tested this PR in different scenarios.

For me it is ready.

Thanks for you attention.

@vncoelho
Copy link
Member

vncoelho commented Sep 4, 2023

Maybe we can also move KeepAliveTimeout and RequestHeadersTimeout to config.

                // Default value is 1 minutes
                options.Limits.KeepAliveTimeout = TimeSpan.FromMinutes(1);
                // Default value is 15 seconds
                options.Limits.RequestHeadersTimeout = TimeSpan.FromSeconds(15);

@cschuchardt88
Copy link
Member Author

do you want that in seconds or minutes for KeepAliveTimeout, also should CORS be enabled by default?

@cschuchardt88
Copy link
Member Author

Also something we may want to consider in the future is "Enable forward proxies"; will help with web hosting and cloud stuff.

@vncoelho
Copy link
Member

vncoelho commented Sep 4, 2023

I think the PR should keep the same behavior as nowadays, @cschuchardt88.

Parameters could be in seconds.

Regarding or issue about the neo-cli handling all this configurations, that is also a possibility for the future that we should consider.

@vncoelho
Copy link
Member

vncoelho commented Sep 4, 2023

Also something we may want to consider in the future is "Enable forward proxies"; will help with web hosting and cloud stuff.

sure!

vncoelho
vncoelho previously approved these changes Sep 26, 2023
Copy link
Member

@vncoelho vncoelho left a comment

Choose a reason for hiding this comment

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

@superboyiii ,can you test?

src/RpcServer/RpcServer.cs Show resolved Hide resolved
src/RpcServer/Settings.cs Outdated Show resolved Hide resolved
@vncoelho
Copy link
Member

ping @superboyiii

@cschuchardt88
Copy link
Member Author

Any update on this @superboyiii ? Just fyi, this fixes a bug in the wild.

@Jim8y Jim8y merged commit 1a77a6d into neo-project:master Jan 4, 2024
2 checks passed
@cschuchardt88 cschuchardt88 deleted the RcpServer-CORS branch January 4, 2024 12:21
Jim8y added a commit to Jim8y/neo-modules that referenced this pull request Jan 10, 2024
* 'master' of github.com:neo-project/neo-modules:
  Ensure max length (neo-project#845)
  Update .editorconfig and run code analyze (neo-project#866)
  Added AspNetCore (neo-project#863)
  RcpServer: Fixed CORS and Basic Auth (neo-project#812)
  Fix response from getversion due to WS removal (neo-project#859)
  Local dev setup (neo-project#861)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RPC Server: Basic Authentication doesn't work with CORS
4 participants