Skip to content

Token renew + updated for Rust 1.83#26

Merged
ldpr merged 9 commits intorpdl-net:token-renewfrom
sudisk:token-renew
May 14, 2025
Merged

Token renew + updated for Rust 1.83#26
ldpr merged 9 commits intorpdl-net:token-renewfrom
sudisk:token-renew

Conversation

@sudisk
Copy link
Copy Markdown

@sudisk sudisk commented May 11, 2025

Added two parameters in the auth section of the config.toml file (seconds) :

session_duration_seconds = 3600 ## The normal token duration (example : 1 h)
renewal_grace_time = 604800 ## The grace period duration for token renewal (example : 1 week)

Added/Modified API endpoints :

verify email address

  • /user/verify/{token} ==> /user/email/verify/{token}

verify if user token is valid

  • POST /user/token/verify
    • content-type: Application/json
    • body:
{
	"login": "<username>",
	"token": "<user-token>"
}
  • response:
    • 200 : {"data": "Token is valid."}
    • 401 : {"error": "Token expired. Please sign in again."}

renew user token

will remain the same during validity period
will be renewed afterwards until grace period expires

  • POST /user/token/renew
    • content-type: Application/json
    • body:
{
	"login": "<username>",
	"token": "<user-token>"
}
  • Success response:
    • 200 :
{
   "data": 
   {
      "token": "<new-token>",
      "username": "<username>",
      "admin": "<boolean indicating if user is admin>"
   }
}
  • Error response:
    • 401 : {"error": "Token expired. Please sign in again."}

Other error responses (user not found, invalid user, ...) are unchanged

@ldpr ldpr merged commit 4a760bb into rpdl-net:token-renew May 14, 2025
ldpr added a commit that referenced this pull request May 14, 2025
ldpr added a commit that referenced this pull request May 14, 2025
* Update user.rs

Backport upstream backend PR torrust#58

* Update mailer.rs

Backport upstream backend PR torrust/torrust-index#58

* Token renew + updated for Rust 1.83 (#26)

* remove odd bar under search box

* reverting

* take 2 - remove buggy white bar under search

* Add click handling to magnifying glass icon on sidebar

Epic

* - Fix token renewal management and add configuration parameters
- Bump some crate versions for recent Rust versions.
- Improve logging capability
- Bump crate versions for Rust update
- Finalize renew token
- Add logging support

* - Fix token renewal management and add configuration parameters

- Bump some crate versions for recent Rust versions.
- Improve logging capability

* Lower log level and remove unnecessary logs in user.rs

---------

Co-authored-by: 63A9F0EA7BB98050796B649E85481845 <[email protected]>
Co-authored-by: rakema01 <[email protected]>

* Revert "Token renew + updated for Rust 1.83 (#26)"

This reverts commit 4a760bb.

---------

Co-authored-by: rakema01 <[email protected]>
Co-authored-by: sudisk <[email protected]>
@sudisk sudisk mentioned this pull request May 14, 2025
ldpr pushed a commit that referenced this pull request May 14, 2025
* Update user.rs

Backport upstream backend PR torrust#58

* Update mailer.rs

Backport upstream backend PR torrust/torrust-index#58

* - Fix token renewal management and add configuration parameters
- Bump some crate versions for recent Rust versions.
- Improve logging capability
- Bump crate versions for Rust update
- Finalize renew token
- Add logging support

* - Fix token renewal management and add configuration parameters

- Bump some crate versions for recent Rust versions.
- Improve logging capability

* Lower log level and remove unnecessary logs in user.rs

---------

Co-authored-by: rakema01 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants