Skip to content

Commit 3e2cef7

Browse files
authored
Try old refresh token if we fail to decode jwt (#6629)
1 parent 2af9d21 commit 3e2cef7

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/auth.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,8 +1210,20 @@ pub async fn refresh_tokens(
12101210
) -> ApiResult<(Device, AuthTokens)> {
12111211
let refresh_claims = match decode_refresh(refresh_token) {
12121212
Err(err) => {
1213-
debug!("Failed to decode {} refresh_token: {refresh_token}", ip.ip);
1214-
err_silent!(format!("Impossible to read refresh_token: {}", err.message()))
1213+
error!("Failed to decode {} refresh_token: {refresh_token}: {err:?}", ip.ip);
1214+
//err_silent!(format!("Impossible to read refresh_token: {}", err.message()))
1215+
1216+
// If the token failed to decode, it was probably one of the old style tokens that was just a Base64 string.
1217+
// We can generate a claim for them for backwards compatibility. Note that the password refresh claims don't
1218+
// check expiration or issuer, so they're not included here.
1219+
RefreshJwtClaims {
1220+
nbf: 0,
1221+
exp: 0,
1222+
iss: String::new(),
1223+
sub: AuthMethod::Password,
1224+
device_token: refresh_token.into(),
1225+
token: None,
1226+
}
12151227
}
12161228
Ok(claims) => claims,
12171229
};

0 commit comments

Comments
 (0)