[GH-ISSUE #4054] Users can not be added / re-authed , JWT Token expired, max_age=0, self-hosted EntraID #8603

Open
opened 2026-08-05 01:18:49 -04:00 by saavagebueno · 0 comments
Owner

Originally created by @natechit on GitHub (Jun 25, 2025).
Original GitHub issue: https://github.com/netbirdio/netbird/issues/4054

Hello to all,

I'm self hosting an instance with EntraID as my SSO provider. This setup has always worked fine for the last couple of months but the last few days although my users are getting logged in correctly, the client errors out with :

Error: waiting sso login failed with: rpc error: code = InvalidArgument desc = invalid jwt token, err: token could not be parsed: Token is expired

Image

By researching the issue I found the following from : https://stackoverflow.com/questions/77307924/azure-entra-id-tokens-endpoint-issues-an-expired-token

The problem was in the max_age query parameter of the authorization URL provided by our client (the one that a client redirects a user to in order to get an authorization code). The max_age had a value of 0 (e.g. max_age=0) which for some reason caused Entra to issue an authorization code that would provide a token that was seemingly issued 5 minutes in the past and immediately expired in the present. We fixed it by removing the query parameter altogether. This resulted into getting a token with the default 60-90 minutes lifetime. More about the query parameter can be read in the OIDC specification.

So I tried it, and when I start the auth procedure from a terminal, grab the url string it creates and instead of max_age=0 in the string, I change it >5 say max_age=60 then the client authenticates and connects as it should.

To exhaust all of the troubleshooting, I nuked my whole EntraID app registration/enterprise app for Netbird and recreated it, still the same issue.
Also, tried a fresh install of the management plane, still the same issue.

Could not find anywhere to change the max_age value, seems to be hardcoded (on the client?)

My Entra sign-in logs show the users doing successful logins, so it should not be a matter of MFA, Conditional Policies or other controls.
I also created custom token (as described here: https://learn.microsoft.com/en-us/graph/api/tokenlifetimepolicy-post-tokenlifetimepolicies?view=graph-rest-1.0&tabs=powershell#request), assigned it to the Netbird object but still the issue persists.

Logs from the management when trying with the altered max_age=60 url string (when a new user logs in, if a user is already created I'm not seeing the successful connection logs):
management-1 | 2025-06-26T03:26:41Z INFO [context: GRPC, requestID: 494a883c-c8a7-44c3-bc2f-421e8f735355, accountID: UNKNOWN, peerID: 47/7RI8peog35sftFW0AlQsjb7ly6X4rV1aSjsXLoGs=] management/server/account.go:939: refreshing cache for account cvnnvkf762kc73ersog0

Logs from the management on failed attempt:
management-1 | 2025-06-26T03:29:52Z WARN [context: GRPC, requestID: 76ac07ea-2493-465c-b63a-0a1f32f8b08b, accountID: UNKNOWN, peerID: 47/7RI8peog35sftFW0AlQsjb7ly6X4rV1aSjsXLoGs=] management/server/grpcserver.go:553: failed validating JWT token sent from peer 47/7RI8peog35sftFW0AlQsjb7ly6X4rV1aSjsXLoGs= with error rpc error: code = InvalidArgument desc = invalid jwt token, err: token could not be parsed: Token is expired. Trying again as it may be due to the IdP cache issuee

Versions are the latest (v0.49.0) on both the management side and all the clients. Also tried to downgrade but to no avail.

The setup.env is pretty basic, what the how-to guide describes and the ,json files are what the ./configure.sh creates.
setup.env:
NETBIRD_DOMAIN="netbird.my.domain" NETBIRD_AUTH_OIDC_CONFIGURATION_ENDPOINT="https://login.microsoftonline.com/TENANT-ID/v2.0/.well-known/openid-configuration" NETBIRD_USE_AUTH0=false NETBIRD_AUTH_CLIENT_ID="AppID" NETBIRD_AUTH_SUPPORTED_SCOPES="openid profile email offline_access User.Read api://AppID/api" NETBIRD_AUTH_AUDIENCE="AppID" NETBIRD_AUTH_REDIRECT_URI="/auth" NETBIRD_AUTH_SILENT_REDIRECT_URI="/silent-auth" NETBIRD_AUTH_USER_ID_CLAIM="oid" NETBIRD_TOKEN_SOURCE="idToken" NETBIRD_LETSENCRYPT_EMAIL="email@provider.com" NETBIRD_AUTH_DEVICE_AUTH_PROVIDER="none" NETBIRD_MGMT_DNS_DOMAIN="custom.domain" NETBIRD_MGMT_IDP="azure" NETBIRD_IDP_MGMT_CLIENT_ID="AppID" NETBIRD_IDP_MGMT_CLIENT_SECRET="secret" NETBIRD_IDP_MGMT_EXTRA_OBJECT_ID="ObjectID" NETBIRD_IDP_MGMT_EXTRA_GRAPH_API_ENDPOINT="https://graph.microsoft.com/v1.0" NETBIRD_MGMT_IDP_SIGNKEY_REFRESH=true

For the time being, I have instructed my users to do the workaround with max_age=60 in the url string and have disabled the "Peer Session Expiration" on the Dashboard so after the first successful authentication they stay connected,.
That kind of works, but it's a bit kludgy and would like to re-enable the peer expiration.
Also to add, clients with setup keys work fine.

If there is a way to either omit the max_age parameter or change it to another value, I think that would solve my problem completely.

Sorry for the long post and thank you beforehand for the time reading this and helping out.

Originally created by @natechit on GitHub (Jun 25, 2025). Original GitHub issue: https://github.com/netbirdio/netbird/issues/4054 Hello to all, I'm self hosting an instance with EntraID as my SSO provider. This setup has always worked fine for the last couple of months but the last few days although my users are getting logged in correctly, the client errors out with : `Error: waiting sso login failed with: rpc error: code = InvalidArgument desc = invalid jwt token, err: token could not be parsed: Token is expired` ![Image](https://github.com/user-attachments/assets/a4078cfc-baa5-4b5d-a381-66482a6c21b4) By researching the issue I found the following from : https://stackoverflow.com/questions/77307924/azure-entra-id-tokens-endpoint-issues-an-expired-token > The problem was in the max_age query parameter of the authorization URL provided by our client (the one that a client redirects a user to in order to get an authorization code). The max_age had a value of 0 (e.g. max_age=0) which for some reason caused Entra to issue an authorization code that would provide a token that was seemingly issued 5 minutes in the past and immediately expired in the present. We fixed it by removing the query parameter altogether. This resulted into getting a token with the default 60-90 minutes lifetime. More about the query parameter can be read in the [OIDC specification](https://openid.net/specs/openid-connect-core-1_0.html). So I tried it, and when I start the auth procedure from a terminal, grab the url string it creates and instead of max_age=0 in the string, I change it >5 say max_age=60 then the client authenticates and connects as it should. To exhaust all of the troubleshooting, I nuked my whole EntraID app registration/enterprise app for Netbird and recreated it, still the same issue. Also, tried a fresh install of the management plane, still the same issue. Could not find anywhere to change the max_age value, seems to be hardcoded (on the client?) My Entra sign-in logs show the users doing successful logins, so it should not be a matter of MFA, Conditional Policies or other controls. I also created custom token (as described here: https://learn.microsoft.com/en-us/graph/api/tokenlifetimepolicy-post-tokenlifetimepolicies?view=graph-rest-1.0&tabs=powershell#request), assigned it to the Netbird object but still the issue persists. Logs from the management when trying with the altered max_age=60 url string (when a new user logs in, if a user is already created I'm not seeing the successful connection logs): `management-1 | 2025-06-26T03:26:41Z INFO [context: GRPC, requestID: 494a883c-c8a7-44c3-bc2f-421e8f735355, accountID: UNKNOWN, peerID: 47/7RI8peog35sftFW0AlQsjb7ly6X4rV1aSjsXLoGs=] management/server/account.go:939: refreshing cache for account cvnnvkf762kc73ersog0` Logs from the management on failed attempt: `management-1 | 2025-06-26T03:29:52Z WARN [context: GRPC, requestID: 76ac07ea-2493-465c-b63a-0a1f32f8b08b, accountID: UNKNOWN, peerID: 47/7RI8peog35sftFW0AlQsjb7ly6X4rV1aSjsXLoGs=] management/server/grpcserver.go:553: failed validating JWT token sent from peer 47/7RI8peog35sftFW0AlQsjb7ly6X4rV1aSjsXLoGs= with error rpc error: code = InvalidArgument desc = invalid jwt token, err: token could not be parsed: Token is expired. Trying again as it may be due to the IdP cache issuee` Versions are the latest (v0.49.0) on both the management side and all the clients. Also tried to downgrade but to no avail. The setup.env is pretty basic, what the how-to guide describes and the ,json files are what the ./configure.sh creates. setup.env: ` NETBIRD_DOMAIN="netbird.my.domain" NETBIRD_AUTH_OIDC_CONFIGURATION_ENDPOINT="https://login.microsoftonline.com/TENANT-ID/v2.0/.well-known/openid-configuration" NETBIRD_USE_AUTH0=false NETBIRD_AUTH_CLIENT_ID="AppID" NETBIRD_AUTH_SUPPORTED_SCOPES="openid profile email offline_access User.Read api://AppID/api" NETBIRD_AUTH_AUDIENCE="AppID" NETBIRD_AUTH_REDIRECT_URI="/auth" NETBIRD_AUTH_SILENT_REDIRECT_URI="/silent-auth" NETBIRD_AUTH_USER_ID_CLAIM="oid" NETBIRD_TOKEN_SOURCE="idToken" NETBIRD_LETSENCRYPT_EMAIL="email@provider.com" NETBIRD_AUTH_DEVICE_AUTH_PROVIDER="none" NETBIRD_MGMT_DNS_DOMAIN="custom.domain" NETBIRD_MGMT_IDP="azure" NETBIRD_IDP_MGMT_CLIENT_ID="AppID" NETBIRD_IDP_MGMT_CLIENT_SECRET="secret" NETBIRD_IDP_MGMT_EXTRA_OBJECT_ID="ObjectID" NETBIRD_IDP_MGMT_EXTRA_GRAPH_API_ENDPOINT="https://graph.microsoft.com/v1.0" NETBIRD_MGMT_IDP_SIGNKEY_REFRESH=true` For the time being, I have instructed my users to do the workaround with max_age=60 in the url string and have disabled the "Peer Session Expiration" on the Dashboard so after the first successful authentication they stay connected,. That kind of works, but it's a bit kludgy and would like to re-enable the peer expiration. Also to add, clients with setup keys work fine. If there is a way to either omit the max_age parameter or change it to another value, I think that would solve my problem completely. Sorry for the long post and thank you beforehand for the time reading this and helping out.
saavagebueno added the idpconfig-idpself-hostingazure labels 2026-08-05 01:18:49 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#8603