Commit e7af23b
authored
fix: support IdPs with 5 min token expiry and no refresh flow MONGOSH-2498 (#232)
Before this change, our OIDC plugin could exhibit undesirable behavior in a
specific configuration edge case, which, unfortunately, matches the default
behavior of at least one identity provider software.
Specifically, Ping Identity software does not typically provide us with
JWTs that are usable for authentication and authorization, so users may
opt to use ID tokens instead. Ping, however, by default does not provide
clients with new ID tokens on a refresh operations, and also only gives
those tokens a default validity of 5 minutes.
(We do recommend to Ping customers to enable passing new ID tokens on
refresh if they have this setup.)
However, 5 minutes also happens to be the time at which the plugin
prefers either refreshing tokens or prompting the user for re-authentication
instead of re-using tokens with a short leftover validity.
This means that when the driver requests a new token multiple times, or
multiple driver instances request tokens in quick succession (which can
easily happen, especially if they used the same token beforehand, which
obviously then expires at around the same time for each driver), the
plugin would try to refresh the token, then when that failed, prompt
the user for a new authentication attempt not just once every minutes,
but multiple times in quick succession as well.
To avoid this issue, we refactor the code that chooses a token acquisition
mechanism so that even if the current token still has a leftover validity
of less than 5 minutes and refreshing fails, we still keep using it until
the driver signals to us that it has become fully unusable.1 parent 24f095e commit e7af23b
3 files changed
+63
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1299 | 1299 | | |
1300 | 1300 | | |
1301 | 1301 | | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
1302 | 1337 | | |
1303 | 1338 | | |
1304 | 1339 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
964 | 964 | | |
965 | 965 | | |
966 | 966 | | |
967 | | - | |
968 | | - | |
969 | | - | |
970 | | - | |
971 | | - | |
972 | | - | |
973 | | - | |
974 | | - | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
975 | 973 | | |
976 | 974 | | |
977 | 975 | | |
978 | 976 | | |
979 | 977 | | |
980 | 978 | | |
| 979 | + | |
| 980 | + | |
981 | 981 | | |
982 | 982 | | |
983 | 983 | | |
984 | 984 | | |
985 | 985 | | |
986 | 986 | | |
987 | 987 | | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
988 | 1007 | | |
989 | 1008 | | |
990 | 1009 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | | - | |
| 84 | + | |
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
| |||
0 commit comments