-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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 readonly api to gateway #1389
Conversation
There were the following issues with your Pull Request
Guidelines are available to help. Your feedback on GitCop is welcome on this issue This message was auto-generated by https://gitcop.com |
Issue ipfs#1322 Added the ability to expose individual commands to a read-only style handler that can be used on any http interface. Added the read-only handler to the gateway. License: MIT Signed-off-by: Travis Person <[email protected]>
fa319e7
to
988c310
Compare
License: MIT Signed-off-by: Travis Person <[email protected]>
|
I actually want some input on the idea above. One rework of this is to add a I also think having a way to define which commands can be used on a given http interface would be nice, because it will allow us to later define restricted interfaces. So right now I'm almost thinking of a mesh of these two. This would leave to a way to pass in a whitelist to the Issue with this is I'm not sure how to get all the commands with the GatewayAccess flag set into the whitelist. So for now, I'd like to get some ideas about the direction this should go. |
@@ -71,6 +77,30 @@ func NewHandler(ctx cmds.Context, root *cmds.Command, allowedOrigin string) *Han | |||
return &Handler{internal, c.Handler(internal)} | |||
} | |||
|
|||
func NewReadOnlyHandler(ctx cmds.Context, root *cmds.Command, allowedOrigin string) *Handler { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
problem with making two handlers is drift in the implementations.
maybe instead of creating two different handlers, make the original handler always check a list of available commands, and then we can just instantiate the read-only and read-write handlers by passing two different command lists.
that way the
if i.readOnly == true {
if _, ok := readOnlyCmds[req.Command()]; !ok { ... }
}
can turn into
if _, ok := availableCmds[req.Command()]; !ok { ... }
This PR adds the ability to expose commands to the gateway. Each commands handler uses a whitelist to expose the commands on the http interface. All commands listed under the root command are exposed by default to the commands port. Only commands with the `GatewayAccess` flag will be exposed on the gateway. License: MIT Signed-off-by: Travis Person <[email protected]>
Update the test to include the command lists Added test to to make sure an emptyu command list rejects requests License: MIT Signed-off-by: Travis Person <[email protected]>
Sorry for this taking so long. If I can get a quick CR on this as well as a list of command/subcommands that need gateway access I think we could merge this sometime this weekend (maybe tomorrow). |
(I think I may of accidentally overwrote one of my commits, I seem to be missing some code that lets it compile by adding the command lists to NewHandler) |
License: MIT Signed-off-by: Travis Person <[email protected]>
@@ -25,7 +29,13 @@ func NewGateway(conf GatewayConfig) *Gateway { | |||
} | |||
} | |||
|
|||
func (g *Gateway) ServeOption() ServeOption { | |||
func (g *Gateway) ServeOption(cctx * commands.Context) ServeOption { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i dont think this is properly go fmt
-ed ?
comments above, but this LGTM. i dont like the for now, list of (readonly!!) cmds to have:
|
Ya agree on the context being moved around so much. I'll put that as a note and this weekend I may investigate the context a bit. I noticed there was a comment to replace the structure or get rid of it, and this PR definitely doesn't help with that idea. I'll get those read-only commands added this afternoon. |
Awesome, thanks @travisperson. |
License: MIT Signed-off-by: Travis Person <[email protected]>
On Fri, Jun 26, 2015 at 02:17:47AM -0700, Juan Batiz-Benet wrote:
Maybe ‘ipfs file ls’ too? |
I'll test this out for the dataviz case when it's ready. |
Hey @travisperson were you able to take a look at not makign the cmds context expand in scope? |
I took a quick look, but didn't really do too much digging yet. |
ok, can someone with some gateway experience take care of this? it's been outstanding for months now... :( |
cc @diasdavid |
|
||
commandList := map[*commands.Command]bool{} | ||
|
||
handler := NewHandler(commands.Context{}, corecommands.Root, "*", commandList) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@travisperson another option is to define corecommands.RootRO
inside corecommands
and use it here. This way, no need for extra commandList
arguments elsewhere.
@rht could you take this one over? |
Based on ipfs#1389 License: MIT Signed-off-by: rht <[email protected]>
Based on ipfs#1389 License: MIT Signed-off-by: rht <[email protected]>
Based on ipfs#1389 License: MIT Signed-off-by: rht <[email protected]>
I beleive this can be closed now. @rht ? |
@whyrusleeping I think so. |
Based on ipfs/kubo#1389 License: MIT Signed-off-by: rht <[email protected]> This commit was moved from ipfs/kubo@dd99a70
Issue #1322
Added the ability to expose individual commands to a read-only style
handler that can be used on any http interface.
Added the read-only handler to the gateway.
Tests to come