Microsoft SSO - Some PCs will not connect invalid jwt token #2174

Closed
opened 2025-11-20 07:05:17 -05:00 by saavagebueno · 5 comments
Owner

Originally created by @ewrmarketing on GitHub (Aug 11, 2025).

We have a handful of clients (under 10), which when they log in for the first time, they are unable to make the connection to netbird, even though the SSO screen comes up and says connected. We have tried at the cmd level and we get the following error:

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

In the management logs we see the following:
2025-08-11T07:59:32-07:00 INFO client/internal/connect.go:122: starting NetBird client version 0.54.0 on windows/amd64
2025-08-11T07:59:33-07:00 ERRO shared/management/client/grpc.go:349: failed to login to Management Service: rpc error: code = PermissionDenied desc = no peer auth method provided, please use a setup key or interactive SSO login
2025-08-11T08:00:02-07:00 INFO client/server/server.go:476: active profile: default for
2025-08-11T08:00:02-07:00 ERRO shared/management/client/grpc.go:349: failed to login to Management Service: rpc error: code = PermissionDenied desc = no peer auth method provided, please use a setup key or interactive SSO login
2025-08-11T08:00:02-07:00 WARN client/server/server.go:309: failed login: rpc error: code = InvalidArgument desc = invalid setup-key or no sso information provided, err: invalid UUID length: 0
2025-08-11T08:00:31-07:00 ERRO shared/management/client/grpc.go:349: failed to login to Management Service: rpc error: code = PermissionDenied desc = no peer auth method provided, please use a setup key or interactive SSO login
2025-08-11T08:00:32-07:00 ERRO shared/management/client/grpc.go:349: failed to login to Management Service: rpc error: code = InvalidArgument desc = invalid jwt token, err: token could not be parsed: Token is expired
2025-08-11T08:00:32-07:00 ERRO client/internal/login.go:152: failed registering peer rpc error: code = InvalidArgument desc = invalid jwt token, err: token could not be parsed: Token is expired
2025-08-11T08:00:32-07:00 WARN client/server/server.go:309: failed login: rpc error: code = InvalidArgument desc = invalid jwt token, err: token could not be parsed: Token is expired

If we setup a computer having this issue with a setup key, it gets logged in with no problem.
It seems there is a hit and miss issue with Microsoft SSO working and giving back a key.

We have restarted the management portal and still the same results.

***Update - 8/16/2025
We have our clients require re-authentication after 24 hours - This is the behavior we are seeing:
Computer 1:
Day 1 - Reauthenticate with no issue
Day 2 - Takes 4 times - Website shows Netbird Authenticated, but Netbird fails to connect
Day 3 - Reauthenticate with no issue
Day 4 - Takes 3 times - Website shows Netbird Authenticated, but Netbird fails to connect

Computer 2:
Day 1 - Reauthenticate with no issue
Day 2 - Takes 2 times - Website shows Netbird Authenticated, but Netbird fails to connect
Day 3 - Reauthenticate with no issue
Day 4 - Reauthenticate with no issue

Computer 3:
Day 1 - Reauthenticate with no issue
Day 2 - Reauthenticate with no issue
Day 3 - Reauthenticate with no issue
Day 4 - No longer will Authenticate - Had to delete peer and setup using key

Are you using NetBird Cloud?

Self Hosted

NetBird version
54.0

netbird version
54.0

Is any other VPN software installed?
No
Debug output

Have you tried these troubleshooting steps?

  • [Yes ] Reviewed client troubleshooting (if applicable)
  • [ Yes] Checked for newer NetBird versions
  • [ Yes] Searched for similar issues on GitHub (including closed ones)
  • [ Yes] Restarted the NetBird client
  • [ Yes] Disabled other VPN software
  • [ Yes] Checked firewall settings
Originally created by @ewrmarketing on GitHub (Aug 11, 2025). We have a handful of clients (under 10), which when they log in for the first time, they are unable to make the connection to netbird, even though the SSO screen comes up and says connected. We have tried at the cmd level and we get the following error: Error: daemon up failed: sso login failed: waiting sso login failed with: rpc error: code = InvalidArgument desc = invalid jwt token, err: token could not be parsed: Token is expired In the management logs we see the following: 2025-08-11T07:59:32-07:00 INFO client/internal/connect.go:122: starting NetBird client version 0.54.0 on windows/amd64 2025-08-11T07:59:33-07:00 ERRO shared/management/client/grpc.go:349: failed to login to Management Service: rpc error: code = PermissionDenied desc = no peer auth method provided, please use a setup key or interactive SSO login 2025-08-11T08:00:02-07:00 INFO client/server/server.go:476: active profile: default for 2025-08-11T08:00:02-07:00 ERRO shared/management/client/grpc.go:349: failed to login to Management Service: rpc error: code = PermissionDenied desc = no peer auth method provided, please use a setup key or interactive SSO login 2025-08-11T08:00:02-07:00 WARN client/server/server.go:309: failed login: rpc error: code = InvalidArgument desc = invalid setup-key or no sso information provided, err: invalid UUID length: 0 2025-08-11T08:00:31-07:00 ERRO shared/management/client/grpc.go:349: failed to login to Management Service: rpc error: code = PermissionDenied desc = no peer auth method provided, please use a setup key or interactive SSO login 2025-08-11T08:00:32-07:00 ERRO shared/management/client/grpc.go:349: failed to login to Management Service: rpc error: code = InvalidArgument desc = invalid jwt token, err: token could not be parsed: Token is expired 2025-08-11T08:00:32-07:00 ERRO client/internal/login.go:152: failed registering peer rpc error: code = InvalidArgument desc = invalid jwt token, err: token could not be parsed: Token is expired 2025-08-11T08:00:32-07:00 WARN client/server/server.go:309: failed login: rpc error: code = InvalidArgument desc = invalid jwt token, err: token could not be parsed: Token is expired If we setup a computer having this issue with a setup key, it gets logged in with no problem. It seems there is a hit and miss issue with Microsoft SSO working and giving back a key. We have restarted the management portal and still the same results. ***Update - 8/16/2025 We have our clients require re-authentication after 24 hours - This is the behavior we are seeing: Computer 1: Day 1 - Reauthenticate with no issue Day 2 - Takes 4 times - Website shows Netbird Authenticated, but Netbird fails to connect Day 3 - Reauthenticate with no issue Day 4 - Takes 3 times - Website shows Netbird Authenticated, but Netbird fails to connect Computer 2: Day 1 - Reauthenticate with no issue Day 2 - Takes 2 times - Website shows Netbird Authenticated, but Netbird fails to connect Day 3 - Reauthenticate with no issue Day 4 - Reauthenticate with no issue Computer 3: Day 1 - Reauthenticate with no issue Day 2 - Reauthenticate with no issue Day 3 - Reauthenticate with no issue Day 4 - No longer will Authenticate - Had to delete peer and setup using key **Are you using NetBird Cloud?** Self Hosted **NetBird version** 54.0 `netbird version` 54.0 **Is any other VPN software installed?** No **Debug output** **Have you tried these troubleshooting steps?** - [Yes ] Reviewed [client troubleshooting](https://docs.netbird.io/how-to/troubleshooting-client) (if applicable) - [ Yes] Checked for newer NetBird versions - [ Yes] Searched for similar issues on GitHub (including closed ones) - [ Yes] Restarted the NetBird client - [ Yes] Disabled other VPN software - [ Yes] Checked firewall settings
saavagebueno added the self-hostingazure labels 2025-11-20 07:05:17 -05:00
Author
Owner

@nazarewk commented on GitHub (Aug 18, 2025):

Did you see or try verifying this configuration https://github.com/netbirdio/netbird/issues/4054#issuecomment-3007539611 ?

@nazarewk commented on GitHub (Aug 18, 2025): Did you see or try verifying this configuration https://github.com/netbirdio/netbird/issues/4054#issuecomment-3007539611 ?
Author
Owner

@ewrmarketing commented on GitHub (Aug 18, 2025):

I will try this.

@ewrmarketing commented on GitHub (Aug 18, 2025): I will try this.
Author
Owner

@nazarewk commented on GitHub (Aug 18, 2025):

Did you verify the time skew on the client devices? I'm not 100% sure, but I think that could also affect token expiration. The code in library we're using is pretty straightforward and I don't see what else it could be other than:

  • PKCEAuthorizationFlow.ProviderConfig.LoginFlag set to a value other than 0 for Entra ID
  • time skew on the server and/or the client
  • a bug or temporary fluke in Entra ID
@nazarewk commented on GitHub (Aug 18, 2025): Did you verify the time skew on the client devices? I'm not 100% sure, but I think that could also affect token expiration. The [code in library we're using](https://github.com/golang-jwt/jwt/blob/4bbdd8ac624fc7a9ef7aec841c43d99b5fe65a29/map_claims.go#L100-L103) is pretty straightforward and I don't see what else it could be other than: - `PKCEAuthorizationFlow.ProviderConfig.LoginFlag` set to a value other than `0` for Entra ID - time skew on the server and/or the client - a bug or temporary fluke in Entra ID
Author
Owner

@ewrmarketing commented on GitHub (Aug 18, 2025):

I did just make the change to the management.json and was able to connect the person with no issues.

Last question: Does this need to be done each time we upgrade to the latest on the server? Or do we need to change the base.setup.env to always be 1?

@ewrmarketing commented on GitHub (Aug 18, 2025): I did just make the change to the management.json and was able to connect the person with no issues. Last question: Does this need to be done each time we upgrade to the latest on the server? Or do we need to change the base.setup.env to always be 1?
Author
Owner

@nazarewk commented on GitHub (Aug 18, 2025):

Last question: Does this need to be done each time we upgrade to the latest on the server?

No, this was simply introduced with the wrong default value and you were unfortunate to use it while it was broken. The default is already fixed for almost 2 months.

Or do we need to change the base.setup.env to always be 1?

This should pretty much always have a value of 0 for Entra ID, because their implementation is not following the OIDC spec by handling max_age=0 literally (emitting already expired tokens) instead of as if it were prompt=login:

max_age
OPTIONAL. Maximum Authentication Age. Specifies the allowable elapsed time in seconds since the last time the End-User was actively authenticated by the OP. If the elapsed time is greater than this value, the OP MUST attempt to actively re-authenticate the End-User. (The max_age request parameter corresponds to the OpenID 2.0 PAPE [OpenID.PAPE] max_auth_age request parameter.) When max_age is used, the ID Token returned MUST include an auth_time Claim Value. Note that max_age=0 is equivalent to prompt=login.

@nazarewk commented on GitHub (Aug 18, 2025): > Last question: Does this need to be done each time we upgrade to the latest on the server? No, this was simply introduced with the wrong default value and you were unfortunate to use it while it was broken. The default is [already fixed for almost 2 months](https://github.com/netbirdio/netbird/pull/4055/files). > Or do we need to change the base.setup.env to always be 1? This should pretty much always have a [value of `0`](https://github.com/netbirdio/netbird/blob/7320684dd1893d8edc731f9d3ef71579b6e40869/shared/management/client/common/types.go#L6-L11) for Entra ID, because their implementation is not following the [OIDC spec](https://openid.net/specs/openid-connect-core-1_0.html) by handling `max_age=0` literally (emitting already expired tokens) instead of as if it were `prompt=login`: > max_age > OPTIONAL. Maximum Authentication Age. Specifies the allowable elapsed time in seconds since the last time the End-User was actively authenticated by the OP. If the elapsed time is greater than this value, the OP MUST attempt to actively re-authenticate the End-User. (The max_age request parameter corresponds to the OpenID 2.0 [PAPE](https://openid.net/specs/openid-connect-core-1_0.html#OpenID.PAPE) [OpenID.PAPE] max_auth_age request parameter.) When max_age is used, the ID Token returned MUST include an auth_time Claim Value. **Note that max_age=0 is equivalent to prompt=login.**
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: SVI/netbird#2174