Why I want to use Tailscale
Tailscale is a VPN service that makes it easy to create secure networks and connections between devices. The main reason I want to use Tailscale is that I need a secure and private way to access services that should not be publicly accessible. Tailscale allows me to create a virtual private network (VPN) where my devices and services can communicate securely over the internet, without exposing them to the public.
Why I want to use ZITADEL as an OIDC provider
ZITADEL is an IdP that provides identity and access management. It is already my main IdP for other services, so it makes sense to use it for Tailscale as well. By using ZITADEL as my OIDC provider, I can reuse my existing user accounts and authentication mechanisms, which simplifies the overall management of my Tailscale network.
Why I created this guide
Even though setting up Tailscale with an OIDC provider is quite well documented, I still faced some difficulties during the configuration process. Therefore, I decided to create this guide to help others who might face similar challenges when setting up Tailscale with ZITADEL as their OIDC provider.
First, some background on how this works: Tailscale loads the OIDC configuration using WebFinger, based on the domain of
the email address you use to log in. For example, if I want to use my own email account name@example.com to
authenticate with Tailscale, Tailscale will look for the OIDC configuration at:
https://example.com/.well-known/webfinger
This endpoint must return the following JSON:
| |
The href field points to the issuer URL of the OIDC provider. You can find this value in the OpenID configuration
endpoint:
https://account.example.com/.well-known/openid-configuration
Also note that the rel field is a fixed value defined by the OpenID Connect specification.
Using the WebFinger of my main domain
Since I already have a website running at example.com, but did not want to add the WebFinger file to my main website,
I tried to set up a dedicated WebFinger server. However, there are only a few WebFinger server implementations
available, and none of them worked well for my use case. Most of them are no longer actively maintained, or cannot
easily be deployed on Kubernetes.
For example, I tried https://github.com/peeley/carpal, which seemed to be one of the
more popular and maintained projects. However, it defines the WebFinger subject (such as acct:name@example.com)
directly in the filename. Kubernetes does not allow mounting files with special characters like : and @, which made
this approach unusable for me. I also did not want to introduce an external database just for running a WebFinger
server.
In the end, I decided to use a static Caddy server and simply serve a static JSON file.
Caddyfile - ConfigMap
| |
webfinger.json - ConfigMap
| |
Deployment
| |
Service
| |
Ingress
You can keep your other ingress for the main website and just add a new path for the webfinger service. However, both need to be accessible on the same host.
| |
Configure ZITADEL
Create a new ZITADEL application for Tailscale and make sure that the user you want to use for login has access to this
application. It is important that the email address or username matches the subject you configured in the WebFinger
setup.
Create a Web Application of type Code and add the following Redirect URI:
https://login.tailscale.com/a/oauth_response
Configure Tailscale
In Tailscale, go to the sign-up page and choose OIDC as the authentication method. Enter the email address associated
with your ZITADEL account (for example, name@example.com). Tailscale will use WebFinger to discover the OIDC provider
and then redirect you to ZITADEL for authentication.
After a successful login, you will be prompted to enter the clientId and clientSecret of the ZITADEL application you
created earlier. Once these credentials are entered, you should be redirected back to Tailscale and logged in
successfully.
How to verify that everything works
To verify that everything is working correctly, you can open an incognito or private browsing window in your web browser and try to log in to Tailscale using the same email address.
Keep in mind that you must first enter your email address on the Tailscale sign-in page. After that, you will be redirected to ZITADEL for authentication.
Conclusion
Setting up Tailscale with ZITADEL as a OIDC provider needs some tweaks, especially when it comes to the WebFinger server. However, this only lets you create a basic Tailscale account. If you want to protect your services with Tailscale, you will need to add Tailscale in front of your services, which is a topic for another guide.