Skip to content

Add GET authentication #2428

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

Closed
wants to merge 12 commits into from
Closed

Add GET authentication #2428

wants to merge 12 commits into from

Conversation

JammSpread
Copy link
Contributor

Adds config option enable-get-requests to enable authentication in the URL.
(i.e. logging in on someone going to a link like, 192.168.1.49:8080/login?pass=SamplePassword)
This pr adds both the password and pass queries with the password query taking higher precedence in the URL.

This may have functionality when sharing a workspace with someone trusted.

Issues that had mentioned this ability:

Copy link
Member

@code-asher code-asher left a comment

Choose a reason for hiding this comment

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

This looks great!

Maybe we should add the ability to generate keys/tokens? Then you could give out tokens to people which would let you revoke them without having to change your password.

For example we could have something like:

$ code-server --generate-token
<token here>

And it would insert into a tokens array in the config.yaml.

Maybe out of scope for this PR though.

@@ -147,6 +148,10 @@ const options: Options<Required<Args>> = {
port: { type: "number", description: "" },

socket: { type: "string", path: true, description: "Path to a socket (bind-addr will be ignored)." },
"enable-get-requests": {
Copy link
Member

Choose a reason for hiding this comment

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

What do you think about naming this enable-get-auth or something with auth in the name?

Copy link
Member

Choose a reason for hiding this comment

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

If we went the token route we could call it enable-token-auth or something.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That seems quick and concise! I might try that. :) Yeah, I agree that tokens seem to be safer.

@@ -125,6 +125,10 @@ const main = async (args: DefaultedArgs): Promise<void> => {
logger.info(` - Authentication is disabled ${args.link ? "(disabled by --link)" : ""}`)
}

if (args["enable-get-requests"]) {
logger.info(` - Login via GET is enabled ${args.auth === AuthType.None ? "(however auth is disabled)" : ""}`)
Copy link
Member

Choose a reason for hiding this comment

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

Should we just skip this output entirely if auth is disabled?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought that it might seem intrusive to people who are just using normal POST passwords.

@code-asher code-asher self-assigned this Dec 10, 2020
JammSpread and others added 3 commits December 11, 2020 00:21
Co-authored-by: Asher <ash@coder.com>
Co-authored-by: Asher <ash@coder.com>
@JammSpread
Copy link
Contributor Author

Should GET passwords be completely gone if tokens are added?

@code-asher
Copy link
Member

@JammSpread I feel absolutely terrible for doing this to you after you've written all of this (really great!) code. 😭

We had an internal discussion about whether we want to support additional authentication methods (such as GET tokens or GET passwords) and while we think it's a cool idea ultimately we came to the conclusion that these are a little out of code-server's scope and it would be more secure to rely on external authentication mechanisms.

For example SSH or something like https://github.com/oauth2-proxy/oauth2-proxy.

I'm sorry I didn't check whether we wanted to integrate this feature before reviewing! Please let me know if you have any questions/concerns/counterpoints.

@code-asher code-asher closed this Dec 14, 2020
@JammSpread
Copy link
Contributor Author

Oh that's fine. If that's what might be best for code-server then that's great! I agree things might get bloated (and can vastly complicate things) if we focus too much on some features and keeping things light is what the experience of VSC is known for. Simplicity is sometimes far more appealing! 😄

@JammSpread JammSpread deleted the master branch December 15, 2020 18:38
@jhgoebbert
Copy link

This patch would make it possible to call code-server from the launchpad of a JupyterLab (using the extension jupyter-server-proxy).
You can find the code-server-proxy here . At the moment we need to disable any authentication [code-details] as we cannot forward the password of code-server using url parameters.

Perhaps you might want to rethink this PR once more 🤔

@code-asher
Copy link
Member

Upstream does have token-based authentication now so I think this could be done. We might need to add a new flag but otherwise there would be no overhead on our end.

@jhgoebbert
Copy link

jhgoebbert commented Jun 15, 2022

Cool. That would be fantastic!

It would be great, if code-server could be started with something like --generate-token (or perhaps even with --token <hash>) which could be used then in the URL like https://myserver.org/code-server?token=<hash> to bypass the login-screen.

In the case of an integration into JupyterLab's launchpad the request for a token would then be added HERE. And this token would be passed to the code-server's launchpad-button-link HERE.

image

@code-asher
Copy link
Member

The way upstream does it is that you can pass --connection-token <token> or --connection-token-file <file> so that sounds like it should meet the requirements.

I just realized there would be overhead though because code-server has its own routes so we would need to update our authentication to support the token. Unfortunate but I think since upstream supports token-based authentication that is a strong reason for us to support it as well.

@jhgoebbert
Copy link

Do you have any idea what priority this token-based authentication has for code-server?
Code-Server currently is the only solution which supports to run behind a configurable-http-proxy and can therefore handle URLs like:
https://jupyter-jsc-staging.fz-juelich.de/user/j.goebbert.fz-juelich.de/de47c0193b364c36b9da34e681f14911/code-server

@code-asher
Copy link
Member

code-asher commented Jul 21, 2022 via email

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.

3 participants