mirror of
https://github.com/juanfont/headscale.git
synced 2026-01-11 20:00:28 +01:00
[Bug] OIDC not working with Authentik > 2024.2? #699
Closed
opened 2025-12-29 02:22:18 +01:00 by adam
·
49 comments
No Branch/Tag Specified
main
update_flake_lock_action
gh-pages
kradalby/release-v0.27.2
dependabot/go_modules/golang.org/x/crypto-0.45.0
dependabot/go_modules/github.com/opencontainers/runc-1.3.3
copilot/investigate-headscale-issue-2788
copilot/investigate-visibility-issue-2788
copilot/investigate-issue-2833
copilot/debug-issue-2846
copilot/fix-issue-2847
dependabot/go_modules/github.com/go-viper/mapstructure/v2-2.4.0
dependabot/go_modules/github.com/docker/docker-28.3.3incompatible
kradalby/cli-experiement3
doc/0.26.1
doc/0.25.1
doc/0.25.0
doc/0.24.3
doc/0.24.2
doc/0.24.1
doc/0.24.0
kradalby/build-docker-on-pr
topic/docu-versioning
topic/docker-kos
juanfont/fix-crash-node-id
juanfont/better-disclaimer
update-contributors
topic/prettier
revert-1893-add-test-stage-to-docs
add-test-stage-to-docs
remove-node-check-interval
fix-empty-prefix
fix-ephemeral-reusable
bug_report-debuginfo
autogroups
logs-to-stderr
revert-1414-topic/fix_unix_socket
rename-machine-node
port-embedded-derp-tests-v2
port-derp-tests
duplicate-word-linter
update-tailscale-1.36
warn-against-apache
ko-fi-link
more-acl-tests
fix-typo-standalone
parallel-nolint
tparallel-fix
rerouting
ssh-changelog-docs
oidc-cleanup
web-auth-flow-tests
kradalby-gh-runner
fix-proto-lint
remove-funding-links
go-1.19
enable-1.30-in-tests
0.16.x
cosmetic-changes-integration
tmp-fix-integration-docker
fix-integration-docker
configurable-update-interval
show-nodes-online
hs2021
acl-syntax-fixes
ts2021-implementation
fix-spurious-updates
unstable-integration-tests
mandatory-stun
embedded-derp
prtemplate-fix
v0.28.0-beta.1
v0.27.2-rc.1
v0.27.1
v0.27.0
v0.27.0-beta.2
v0.27.0-beta.1
v0.26.1
v0.26.0
v0.26.0-beta.2
v0.26.0-beta.1
v0.25.1
v0.25.0
v0.25.0-beta.2
v0.24.3
v0.25.0-beta.1
v0.24.2
v0.24.1
v0.24.0
v0.24.0-beta.2
v0.24.0-beta.1
v0.23.0
v0.23.0-rc.1
v0.23.0-beta.5
v0.23.0-beta.4
v0.23.0-beta3
v0.23.0-beta2
v0.23.0-beta1
v0.23.0-alpha12
v0.23.0-alpha11
v0.23.0-alpha10
v0.23.0-alpha9
v0.23.0-alpha8
v0.23.0-alpha7
v0.23.0-alpha6
v0.23.0-alpha5
v0.23.0-alpha4
v0.23.0-alpha4-docker-ko-test9
v0.23.0-alpha4-docker-ko-test8
v0.23.0-alpha4-docker-ko-test7
v0.23.0-alpha4-docker-ko-test6
v0.23.0-alpha4-docker-ko-test5
v0.23.0-alpha-docker-release-test-debug2
v0.23.0-alpha-docker-release-test-debug
v0.23.0-alpha4-docker-ko-test4
v0.23.0-alpha4-docker-ko-test3
v0.23.0-alpha4-docker-ko-test2
v0.23.0-alpha4-docker-ko-test
v0.23.0-alpha3
v0.23.0-alpha2
v0.23.0-alpha1
v0.22.3
v0.22.2
v0.23.0-alpha-docker-release-test
v0.22.1
v0.22.0
v0.22.0-alpha3
v0.22.0-alpha2
v0.22.0-alpha1
v0.22.0-nfpmtest
v0.21.0
v0.20.0
v0.19.0
v0.19.0-beta2
v0.19.0-beta1
v0.18.0
v0.18.0-beta4
v0.18.0-beta3
v0.18.0-beta2
v0.18.0-beta1
v0.17.1
v0.17.0
v0.17.0-beta5
v0.17.0-beta4
v0.17.0-beta3
v0.17.0-beta2
v0.17.0-beta1
v0.17.0-alpha4
v0.17.0-alpha3
v0.17.0-alpha2
v0.17.0-alpha1
v0.16.4
v0.16.3
v0.16.2
v0.16.1
v0.16.0
v0.16.0-beta7
v0.16.0-beta6
v0.16.0-beta5
v0.16.0-beta4
v0.16.0-beta3
v0.16.0-beta2
v0.16.0-beta1
v0.15.0
v0.15.0-beta6
v0.15.0-beta5
v0.15.0-beta4
v0.15.0-beta3
v0.15.0-beta2
v0.15.0-beta1
v0.14.0
v0.14.0-beta2
v0.14.0-beta1
v0.13.0
v0.13.0-beta3
v0.13.0-beta2
v0.13.0-beta1
upstream/v0.12.4
v0.12.4
v0.12.3
v0.12.2
v0.12.2-beta1
v0.12.1
v0.12.0-beta2
v0.12.0-beta1
v0.11.0
v0.10.8
v0.10.7
v0.10.6
v0.10.5
v0.10.4
v0.10.3
v0.10.2
v0.10.1
v0.10.0
v0.9.3
v0.9.2
v0.9.1
v0.9.0
v0.8.1
v0.8.0
v0.7.1
v0.7.0
v0.6.1
v0.6.0
v0.5.2
v0.5.1
v0.5.0
v0.4.0
v0.3.6
v0.3.5
v0.3.4
v0.3.3
v0.3.2
v0.3.1
v0.3.0
v0.2.2
v0.2.1
v0.2.0
v0.1.1
v0.1.0
Labels
Clear labels
CLI
DERP
DNS
Nix
OIDC
SSH
bug
database
documentation
duplicate
enhancement
faq
good first issue
grants
help wanted
might-come
needs design doc
needs investigation
no-stale-bot
out of scope
performance
policy 📝
pull-request
question
regression
routes
stale
tags
tailscale-feature-gap
well described ❤️
wontfix
Mirrored from GitHub Pull Request
Milestone
No items
No Milestone
Projects
Clear projects
No project
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: starred/headscale#699
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @badsmoke on GitHub (Apr 29, 2024).
Is this a support request?
Is there an existing issue for this?
Current Behavior
after updating to authentik 2024.4.1, the connection to headscale no longer works properly.
after a headscale restart, for example, the exit node no longer works.
I assume that this is the problem?
Starting with authentik 2024.2, applications only receive an access token. To receive a refresh token, both applications and authentik must be configured to request the offline_access scope. In authentik this can be done by selecting the offline_access Scope mapping in the provider settings.I previously had an authentik smaller 2024, which ran without any problems
Expected Behavior
just like before :-D it should work
unfortunately I can no longer downgrade without further ado to test it further
Steps To Reproduce
headscale set up so that oidc runs via authentik (< 2024)
authentik update, which offline_access needs
connect to headscale, works but exit node does not work (no internet)
exit-node reauth, internet works again-> until the next headscale restart or a time?
Environment
Runtime environment
Anything else?
that's just a guess, but i updated authentik at the weekend and it hasn't worked since then
@yeyeoke commented on GitHub (May 4, 2024):
Same problem here!
@badsmoke commented on GitHub (May 8, 2024):
are you sure? so it has something to do with the offlice_access scope.
here is an explanation
go-oidc also supports the scope
https://pkg.go.dev/github.com/coreos/go-oidc/v3/oidc
search for "offlice_access"
i have added the scope in the headscale config and authentik but it does not bring any noticeable change
@Ziomal12 commented on GitHub (May 8, 2024):
@badsmoke
Could you share your config and explain in more detail what you've done? I think I've also added that and no authentik login screen appears anyways.
@sonroyaalmerol commented on GitHub (May 10, 2024):
Had this exact same problem. For authentik, you'd need an additional
extra_paramsand include theoffline_accessscope. Make sure to actually include the scope in authentik OAuth2 provider side as well.You would also need to set a Signing Key (you can use the self-signed one) for the OAuth2 provider of authentik to use RS256 for signing which I think is required for Headscale.
Here's a sample portion of the headscale config for the oidc:
@badsmoke commented on GitHub (May 14, 2024):
everything went smoothly over the weekend, did it work for you too? @yeyeoke and @Ziomal12
then I would close this issue
@julianq commented on GitHub (May 14, 2024):
@sonroyaalmerol @badsmoke I'm now having this exact issue.
My headscale config includes:
The OIDC provider on the Authentik side is using the self-signed certificate, not expired, and also has offline_access included in scope.
Keep getting:
connect: connection refusedAny ideas?
@Ziomal12 commented on GitHub (May 14, 2024):
In
docker logs headscaleI see this error:The address is accessible through the URL with valid LE cert.
Here is my config.yaml:
In authentik provider config I have set singing key and the same scopes as in the config file.
@julianq commented on GitHub (May 14, 2024):
@Ziomal12 I think you and I are having the exact same problem. I cannot figure out why it's not connecting.
@badsmoke commented on GitHub (May 14, 2024):
i have not extra params
@julianq commented on GitHub (May 14, 2024):
@badsmoke
extra_paramsseems to be mostly irrelevant, as i think the default isprompt: consentanyway. regardless, with or withoutextra_paramsI get the same error. What do you have for config on the authentik side?@Ziomal12 commented on GitHub (May 14, 2024):
Removing
extra_parmsdoes not help. Here is my Authentik config for headscale provider:@julianq commented on GitHub (May 14, 2024):
@Ziomal12 exactly what I have
@Ziomal12 commented on GitHub (May 14, 2024):
@julianq What versions are you using?
I'm running Authentik 2024.4.2 and headscale v0.23.0-alpha11
@julianq commented on GitHub (May 14, 2024):
@Ziomal12 2024.4.2 on authentik, on headscale its whatever the latest release (ie non-alpha) is. I forget the build number I'll go look it up.
ETA: 0.22.3
@badsmoke commented on GitHub (May 14, 2024):
I have the same config except for the redirect url, which is still very open with
.*@julianq commented on GitHub (May 14, 2024):
@Ziomal12 Okay so I seem to have fixed it by putting Headscale and Authentik on the same VLAN (they were on separate VLANs before). I have no idea how this got borked since there were no config changes before it stopped working. I also explicitly allowed all traffic between the VLANs and it still didn't work, only when they were put on the same VLAN. I'll have to do some more digging as to why this happened, but for now, I'm just happy its working.
@Ziomal12 commented on GitHub (May 14, 2024):
@julianq Glad to hear that! Unfortunately I'm unable to do that as both services run on different machines. Hopefully there's a fix soon, not a workaround.
@julianq commented on GitHub (May 14, 2024):
@Ziomal12 Agreed.
@julianq commented on GitHub (May 14, 2024):
For what it's worth, I removed
offline_accessfrom the scope and it's still working, so that's not a contributing factor here.@julianq commented on GitHub (May 14, 2024):
@Ziomal12 This is an Authentik issue. Second service having authentication issues, which were fixed by moving the service on to the same VLAN as Authentik. I'll file a bug report there.
@SpiderD555 commented on GitHub (Jun 8, 2024):
Just made headscale work with Authentik.
Comparing to what Ziomal12 wrote:
I don't have "offline_access" scope, and expiry is set to 180d, my "allowed_groups:" is set to "headscale"
Moreover I had to set callback URL in Authentik to ".*", and my user is part of "headscale" group which is attached to the application definition. Moreover I don't have the "offline_access" mapping defined in Authentik
My Authentik version is currently 2024.4.2
Headscale version is v0.22.3
I guess the only bug on headscale side I see here is the invalid callback URL which Authentik complains about if I don't set "."
I tried the same with Keycloak, and I also had to set "" there as redirect URL to make it work
@masterwishx commented on GitHub (Jun 22, 2024):
So if we have 180 day Expiry, do we need offline_access?
@grishio commented on GitHub (Nov 14, 2024):
I am on the latest version of authentik and all is well here with version v0.23.0. OIDC authentication works perfectly. Is this bug still valid?
@B08Z commented on GitHub (Dec 17, 2024):
Could you provide your config both Authentik and headscale config (less keys and passwords)
That would be super helpful
@Ziomal12 commented on GitHub (Dec 17, 2024):
I need to apologise as I've figured out what's wrong (i think).
RN my best answer is that Headscale cannot connect to Authentik as Headscale is running on vps, that also serves as reverse proxy for Authentik (which runs on local machine). TBH I'm not sure why it worked before if that's the case. On fix to that could be to allow periodic check (instead of only on startup) to see if OIDC provider is available.
I'm not sure how i'd provide Authentik config but it's basically the stock one. As for headscale (v0.23.0) config:
config.yaml.txt
EDIT: Authentik's config posted here: https://github.com/juanfont/headscale/issues/1916#issuecomment-2110462525
@masterwishx commented on GitHub (Dec 17, 2024):
Posted here : https://github.com/juanfont/headscale/issues/2295#issuecomment-2547779529
@B08Z commented on GitHub (Dec 17, 2024):
Thank you this is really really helpful.
This is probably a very stupid question...and maybe more related to Authentik.
But when you say: headscale Users is that my uses of headscale (alice bob etc) just an arbitrary variable.
In the same vain do I need to create a user bob in Authentik that is in the headscale Users group?
Thanks in advance, and sorry for the stupid questions.
@masterwishx commented on GitHub (Dec 17, 2024):
Yes but if you don't need group, you can use it without group I think
@masterwishx commented on GitHub (Dec 17, 2024):
It's Authentik group of users
@b4iterdev commented on GitHub (Jan 2, 2025):
I'm trying to setup OIDC with Authentik 2024.12.1 with the following oidc configuration: https://auth.b4iterdev.id.vn/application/o/headscale/.well-known/openid-configuration
on headscale config:
Authentik redirect URIs:
Preview with a test user:
With

only_start_if_oidc_is_available: truein place and observing logs, it does seems that headscale are able to contact with Authentik as it does send url to client for authentication, however I have this weird error:Not sure if this is a Authentik bug or headscale one, but does anyone having the same issue as I am, or am I missing something ?
@badsmoke commented on GitHub (Jan 2, 2025):
what kind of crazy domain is that ;-)
but the redirect url looks correct
headscale.domain.tld//oidc/callback , try it with regex
regex:
https://headscale.b4iterdev.net.eu.org/.*@b4iterdev commented on GitHub (Jan 2, 2025):
Free domain lol, I have a better one but I'd prefer using that domain for now
I tried but it still gave me the same error, worth to note that I also setup OIDC on /admin/oidc/callback and it worked flawlessly
@b4iterdev commented on GitHub (Jan 2, 2025):
I do compare the rediect url and realise that headscale redirect url does contain :443 as in headscale server url config, which lead to authentik returned as invalid url.
With that resolved I can now login, but I'm getting:
Authenticated as , you can now close this window.Also I realised that I have to reauthenicate every time tailscale get disconnected, any ideas how to resolve this ?
@badsmoke commented on GitHub (Jan 2, 2025):
great, yes you dont need the port in the server_url
the rest of the oidc settings looks good for me
Are there any noticeable headscale logs?
@b4iterdev commented on GitHub (Jan 2, 2025):
headscale logs indicated that nodes are registered successfully, but only that, I don't get anything related to username, also running
headscale users listgive me a list with a user that has empty name.@b4iterdev commented on GitHub (Jan 2, 2025):
Might worth to mention, after authenticate and connected to tailnet, in tailscale menu

@badsmoke commented on GitHub (Jan 9, 2025):
Have you got any further?
which headscale version are you actually using?
@b4iterdev commented on GitHub (Jan 9, 2025):
I actually solved that, the reason is that it require the user to have a email present, which initally I don't have, by adding email on Authentik it can login now
@javito1081 commented on GitHub (Apr 21, 2025):
Hi, im trying to setup headscale with authentik but so far i havent been able to, whenever i try to start the headscale server i get an error saying:
headscale | 2025-04-20T22:38:43Z FTL home/runner/work/headscale/headscale/cmd/headscale/cli/serve.go:24 > Error initializing error="creating OIDC provider from issuer config: 404 Not Foundcould u post a brief explanation of how u did it?
@javito1081 commented on GitHub (Apr 21, 2025):
which url did u set for the issuer? could u post a brief explanation of how u set headscale up with authentik?
@javito1081 commented on GitHub (Apr 21, 2025):
So i manage to finally get it working, at least headscale is now up, but when i go to https://headscale.mydomain.com i just get a 404 screen, i dont get to the authentik login page, i feel im missing something i just dont know what it is, im using ngnix proxy manager for headscale and i dont have anything setup on the advanced tab, dont know if i have to or not
@nblock commented on GitHub (Apr 21, 2025):
The tailscale client will redirect you to its login page when you register a new client.
@javito1081 commented on GitHub (Apr 21, 2025):
ya i got it working now hehe, i realize that when the clients log in for the first time is when they get the redirection site to log in, after that if im already logged in, i get a 404 :-)
@javito1081 commented on GitHub (Apr 22, 2025):
have you manage to get the allowed_groups working? i created a group in the authentik interface and put that grp into the config but everyone is still able to authenticate, its not stopping anyone from doing it
config.yaml
@masterwishx commented on GitHub (Apr 22, 2025):
What your config in authentik for this group?
@javito1081 commented on GitHub (Apr 22, 2025):
Only thing i did on authentik for this was to create a group and fill it with users, didn't do anything else, is there something aditional i should be doing?
@masterwishx commented on GitHub (Apr 22, 2025):
Sure you need to link group to oidc of headscale login
@javito1081 commented on GitHub (Apr 22, 2025):
How do it do that?
@masterwishx commented on GitHub (Apr 23, 2025):