Skip to content

Commit 0ff6c7b

Browse files
authored
fix!: increase default JWT expiration time via AuthNew (#6475)
1 parent 90ebac8 commit 0ff6c7b

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727

2828
### Breaking
2929

30+
- [#6475](https://github.com/ChainSafe/forest/pull/6475): Increased default JWT (generated via `Filecoin.AuthNew`) expiration time from 24 hours to 100 years to match Lotus behavior and ensure compatibility with clients like Curio.
31+
3032
### Added
3133

3234
- [#6466](https://github.com/ChainSafe/forest/pull/6466) Enabled `Filecoin.EthGetBlockTransactionCountByHash` for API v2.

src/rpc/methods/auth.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,13 @@ impl RpcMethod<2> for AuthNew {
2929
) -> Result<Self::Ok, ServerError> {
3030
let ks = ctx.keystore.read();
3131
let ki = ks.get(JWT_IDENTIFIER)?;
32-
let token = create_token(
33-
permissions,
34-
ki.private_key(),
35-
// default to 24h
36-
chrono::Duration::seconds(expiration_secs.unwrap_or(60 * 60 * 24)),
37-
)?;
32+
// Lotus admin tokens do not expire but Forest requires all JWT tokens to
33+
// have an expiration date. So we set the expiration date to 100 years in
34+
// the future to match user-visible behavior of Lotus.
35+
let token_exp = expiration_secs
36+
.map(chrono::Duration::seconds)
37+
.unwrap_or_else(|| chrono::Duration::days(365 * 100));
38+
let token = create_token(permissions, ki.private_key(), token_exp)?;
3839
Ok(token.as_bytes().to_vec())
3940
}
4041
}

0 commit comments

Comments
 (0)