-
Notifications
You must be signed in to change notification settings - Fork 100
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
Add Rest Web Server WIP
#810
Conversation
Added HTTP Basic Auth. Changed most classes to internal that didnt need to be public. Added Rest Server Middleware. Added the ability to block urls paths (for module rest server plugins). Added the ability to enable CORS and whitelist of urls. Added HTTP user and pass configurable. Added hot load of Controllers from plugin assemblies Changed Controllers to be "ApiController" class
…abled with no origins,.
Added MaxTransactionFee to config Added Anything for Kestrel to be configurable
Added Nep11 token controller. Changed namespaces and file names around.
Added peers route for node controller Changed RemoteNodeModel and TokenBalanceModel namespaces
Added Neo/Gas controller Added send raw transactions relay
Fixed formating Added blacklist/disable controllers Removed DisableRoute list from config (wasn't being used)
… format Added InvokeScript to helper class Added ConvertToScriptHash for address to scripthash
Changed all controller parameters for json converters Added custom error handling Fixed wallet sessions Added wallet session manager removed development mode (not needed) Added session timeout to config file Added max allow sessions to config file
Before i make client can someone make sure we are going to use this? |
@cschuchardt88, It is a mechanism that many developers requested to us in the past, as far as I can remember. One point that worries me a little bit is about the maintenance and security of some calls, how could we make it more generic related to the current RPC Server plugin or RPC Client? |
Swagger can be added to the list |
The RestServer implements the same things for Kestrel as RpcServer does. Plus newer features. Everything is configurable and can be turned off. For added security you can enable basic authentication and/or https, with the ability to use a forward proxy. Also you have the ability to disable controllers and by default we disable WalletController. So if anyone want to make this plugin be public on a public node. We don't want people trying to open wallets or search around on the node for one. This uses middleware to block the controllers from ever being loaded. This is very generic but may appear not to be. Most the code is Model/Json converters for serializing the Models to JSON and JSON to Objects. These include UInt160, UInt256, StackItem, Transactions and Blocks to just name a few. If the application breaks I have Middleware set to not leak sensitive information to the end user. Server will return generic responses like see below. In the event of a crash of the application from any controller will result in a generic exception json response. To ensure applications that are consuming this RestServer will not have inconsistent responses for crashes or errors. Also any exception that is thrown will also result in error response like see below. So instead of returning your own response in a plugin for example with your own error. You would just throw an exception and the result will be 400 response with see below as example {
"code": 1001,
"name": "ParameterFormatException",
"message": "Parameter hash is in an invalid format."
} if you have a look at theses files @shargon yes I can add it. Edit: |
This is at the point where you can try it out and see if it meets your requirements. Everything is up for discussion. If you can't use it either that's fine too. Some questions i have:
But i do think this is a good start to get it moving out the door for merger. |
too long to review every single line, but functioning ok, maybe we can have it at first, then optimize it little by little. I personally love and welcome new features added. |
@cschuchardt88 do you mind to provide a readme for this plugin? i know others dont have it, but we will add readme for every plugin in the future. Mainly about what it is, what it does, how to use it, extra. basically what you have in the description of this pr |
Merge since its a plugin, people dont install it if they dont like it. |
@Liaojinghui, you're rushing too fast with this, IMO. People will install it, people will try building things on it. I'm not sure it's tested enough and stable enough for them to do that. And notice that it could've been a separate plugin for some time exactly for these experiments. Now it's an official plugin from the Neo project, people have higher expectations of those. |
@roman-khimov |
Agree and reverted (8337202). Too many files without a deep review. |
Agree, but only if someone review it. I dont see how this can introduce more bugs than there has already be. I dont understand why you still stop merge and expect some one to review it while a pr has being there for 3 months and no one to review. I have checked the code and run it, no abvious issues found. |
I understand, but understand that you have to review the code before merging, the more changes, the more complicated and time-consuming it requires, imagine (which I don't think is the case) that you add a line to leak the private key, all the code must be reviewed by at least two core developers, and tested by the great @superboyiii team. Small pr will be reviewed faster than longer ones. |
Yes, the same reason why so many prs stay there for many years without anyone care about them. |
The solution is not merge all of them. |
@cschuchardt88 please open a new PR with these changes. |
Not all of them, but something i have reviewed, and no one else review it after months. We can wait, but should not be endless waiting. |
That's why roadmaps and plans matter. Set some target, like "this PR should be dealt with by this time" and work towards that goal. Not planned? Likely not critical for now then (sure, life is complicated and sometimes it is). Add it to some milestone in the future, but keep real concentration on the nearest goals. We can't solve all problems at once and we can't risk destabilizing the system by accepting everything without proper reviews and tests. Going one problem after another with intermediate stable releases is more viable. |
Adding Restful services to Neo N3 ecosystem. This uses
MVC
model without the view aspect. I currently don't know how much easier I can make this plugin. When it comes to flexibility and freedom. This system was design with usability. To allow the freedom of making what you want with plugins and will have a fault tolerant model. Also this model can allow upgrades, if Neo ever decides to makeneo-cli
have a built in webserver that handlesRPC
,Rest
,WSS
; this would be the code to do so. The already built plugins that are using this RestServer Plugin would not need to be changed.This plugin is
test
ready. I'm not trying to rush it and understand it takes a lot of time. But I would love some feedback on this plugin. If you decide to not use this plugin. By all means this plugin will not end here.The goal here is to have its client be dependency free of the
Neo.dll
and all its dependencies. Of course you can still add them if need be. LikeNeo.vm.dll
for building scripts to send viaRest
service call. I want to have this client and this plugins endpoints be available in other parts of thedotnet
ecosystem. Just to name a fewMono.Net
,.NET Maui
andUnity
. This will help the Neo user base have no limitations on whatever framework or technology they desire to use.As for maintainability, I'm not going anywhere; anytime soon and I have tons of time on my hands to write document, answer questions and update code. You have to start somewhere; so let's come together!
Yes I know it seemed fast; for me to make this plugin, But I really started at the begin of the year working on it and learning the neo-cli. 😸 So this is 5 months worth of learning and reading source code. 3 months of programming the code. My background is architecture design of systems.
See neo-project/neo#1004
Documentation
This RestServer Documentation explains the working of the
RestServer
plugin. Note still a work in progress.RestServer Addon Plugins
This Example Plugin Documentation explains how to make plugins for the
RestServer
.Downloads
Swagger UI
RestClient Code Example
Key Features
Change Log
Testing Progress
Neo-Cli Commands
You can just add Swagger OpenAPI 2.0 to any project by
Step1

Step 2

Step 3
