Add native support for external authentication providers such as OAuth2 / OIDC
What is your suggestion?
I would like code-server to support native authentication with standard external authentication systems, such as OAuth2, OpenID Connect (OIDC), SAML, LDAP, or other common authentication protocols.
Today, code-server mainly supports authentication through a configured password, either plain or hashed, or by disabling built-in authentication and placing a reverse proxy in front of code-server to handle authentication externally.
It would be useful to have first-class support for external identity providers directly in code-server configuration, for example:
- OAuth2 / OpenID Connect providers
- Enterprise SSO providers
- LDAP / Active Directory
- Generic authentication backends through a documented interface
Example configuration could look like:
auth: oidc
oidc:
issuer-url: https://auth.example.com
client-id: code-server
client-secret: ${OIDC_CLIENT_SECRET}
redirect-uri: https://code-server.example.com/callback
allowed-groups:
- developers
Why do you want this feature?
Using only a static password is not ideal for many environments, especially in enterprise or shared infrastructure contexts.
Native support for external authentication would provide several benefits:
- Centralized authentication management
- Better integration with existing identity providers
- Support for multi-factor authentication through the identity provider
- Easier user lifecycle management, such as onboarding and offboarding
- Better security posture compared to sharing or rotating a single password
- Simplified deployment, without requiring every user to configure and maintain a reverse proxy only for authentication
This would make code-server easier to deploy securely in professional, internal, and enterprise environments.
Are there any workarounds to get this functionality today?
Yes. The current workarounds are:
- Configure a password directly in the code-server configuration, either plain text or hashed.
- Disable or bypass code-server authentication and put a reverse proxy in front of it, such as NGINX, Traefik, Caddy, oauth2-proxy, Authelia, Keycloak Gatekeeper, etc.
However, these approaches have limitations:
- Password-based authentication does not integrate well with existing SSO systems.
- Reverse proxy authentication adds operational complexity.
- Each deployment must solve the same authentication problem independently.
- Misconfiguration can easily lead to security issues.
- Some environments prefer application-level authentication rather than relying only on an external proxy.
Are you interested in submitting a PR for this?
Not at the moment, as this would likely require design discussion around authentication architecture, provider configuration, session handling, and backward compatibility.
However, I would be interested in testing the feature, reviewing proposals, or helping provide feedback on expected enterprise/SSO use cases.
Honestly, i want the same thing since the last time i used the coder server standalone, it was going to be hacked as if someone figures the password, they can just simply head for docker privelage escalation as the root password as well is just simply available in the environment variable of the terminal in it. But, honestly it's not worth it to add to this repo. I'll explain why.
It's because there will be way too much complexity because as of now, Coder Server is designed to be accessed securely thorugh the coder dashboard where you create Dev Environment which manages authentication with proper measures. So if we were to add a standalone OIDC and Auth2 support for coder server, the complexity would increase drastically. And by that i don't just mean in this very repo but we would also have to push pull requests to the main dashboard repo.
While building, we would have to answer questions like: How does the Dashboard know whether Coder Server is already authenticated? How does Coder Server know the Dashboard session is valid? Who owns logout? What happens when the Dashboard session expires but the editor session doesn't? What if the editor refresh token is still valid? How are permissions synchronized? How are redirect URIs generated for every workspace URL? How do you support ephemeral workspaces that come and go?
I'm thinking of creating a custom fork or a seperate new project where this would be much feasible to do honestly speaking.
Yeah from what I recall we really only added the password to help less experienced people not accidentally get themselves immediately hacked as they tried to expose code-server to the internet.
I definitely agree that it would be too much complexity to maintain a full auth solution in code-server, especially when an auth proxy is already a really good solution.
But I will also say I think integration with the Coder dashboard does not really play into it, because we use --auth none there, so any auth changes here have no effect in Coder anyway.
Well, from that standpoint, It sounds like this would be feasible since the only thing i was afraid that was increasing complexity way too much was the dashboard integration. I think this would be a totally cool and actually necessary feature to exist or yeah then there's the fact that you're going so complex on the OIDC and Auth2 things, you could just use Authentik in front to redirect to application. It's the same thing i use for my important dashboards as well. So yeah, i guess for security purposes as for now at least, it would be perfect to rather include into documentation about how you could expose the server publically as securely as possible through using authentik and external OIDC which simply and securely redirect. simple.
We do have a section that says to use auth reverse proxies if you want to authenticate with external providers and the section provides some options. We just link out to them though, I think it would be difficult to document how to set them all up in our docs.
Well, i could try? I did set up this stuff like 2 months ago so it's still a bit fresh and i did document it at some extent.
Generally I think we should avoid documenting external software, buuuut we do document some things like NGINX and Caddy so there is some precedence. But those are things that users often have issues with, which is why we document them.
So, I am not sure if there is a lot of demand for us to maintain docs on how to set up an auth proxy, it might not be worth the effort to maintain them.
Well, I'll help maintain if you guys ever change your mind. All good hehe :)
Thanks everyone for the explanations and for taking the time to discuss this.
I understand now that it's not really a matter of whether it's technically possible, but rather the maintenance burden and long-term complexity. That answers my question, so I'll go ahead and close this issue.
Thanks again!