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

x/crypto/ssh: allow returning arbitrary data from the server authorization callbacks #21689

nhooyr opened this issue Aug 30, 2017 · 2 comments


Copy link

@nhooyr nhooyr commented Aug 30, 2017

By server authorization callbacks, I mean the various callbacks listed here on godoc that return the Permissions structure.

I'm writing a SSH server that will check against a database to authorize the user's public key and then it will allow the user various abilities based on their permissions as listed in the database. The permissions are returned with the user. They are a integer type.

The problem is that I cannot pass those permissions from the public key callback straight to my implementation code. Instead, right now, I'm encoding the permissions as a string, putting them into the Extensions field of the Permissions structure and then decoding them in my implementation code. This is janky and will not scale well if I have to add more data that needs to be passed to my implementation code. I could query for the user in the database again in my implementation code, but that would be 2 queries for the exact same thing which is inefficient. Furthermore, I could use a shared map (that has its own set of issues) but I think there is a better solution.

I propose we add a new field to the Permissions structure that will carry arbitrary data. Presently, there exists the Extensions field but that is only a map from a string to a string, but I think we should add a new field that is a interface{} and will carry implementation specific data. I'm unsure of the name but that could be figured out later.

@gopherbot gopherbot added this to the Unreleased milestone Aug 30, 2017
Copy link

@hanwen hanwen commented Aug 30, 2017

I understand your problem, but marshalling an int to string seems straightforward enough, so your case by itself doesn't warrant an API change.

I'd love to see some more reports of what people want to pass around.

(Maybe we should this be fold this together with a context-ization of the SSH package?)

Copy link

@hanwen hanwen commented Mar 8, 2018

closing this for now.

@hanwen hanwen closed this Mar 8, 2018
@golang golang locked and limited conversation to collaborators Mar 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.