Change the default client token expiration from None to the value set in the site config.

Review Request #13410 — Created Nov. 8, 2023 and submitted

Information

Review Board
release-5.0.x

Reviewers

Previously, the WebAPITokens.objects.get_or_create_client_token would create
client tokens with no expiration date by default. In most cases, we want to
create client tokens with the client_token_expiration value set in the site
configuration (e.g. 1 year from now). Instead of carrying around the logic for
this to multiple areas, this change makes this value the default expiration
for WebAPITokens.objects.get_or_create_client_token.

  • Tested creating client/using client tokens with RBTool's login.
  • Ran unit tests.
Summary ID
Change the default client token expiration from None to the value set in
the site config.
4e6132d1dddbce11fc47b265d87c1bbea0fd2e32
Description From Last Updated

This approach definitely works, but I wonder if it might make sense to use some of the new symbol support …

chipx86chipx86
david
  1. Ship It!
  2. 
      
chipx86
  1. 
      
  2. reviewboard/webapi/managers.py (Diff revision 1)
     
     
     
     
     
     
    Show all issues

    This approach definitely works, but I wonder if it might make sense to use some of the new symbol support in Djblets. We'd want to backport some of the stuff in Djblets 4 to 3.4, but in Djblets 4, we have djblets.util.symbols with Unsettable[...] and UNSET, so you can do:

    expires: Unsettable[Optional[datetime.datetime]] = UNSET
    

    This has the advantage of having a clearly-defined, documented, doc-generated value that differs from a None and can't be confused with any other value.

    If that approach works for you, feel free to backport commit 0b0f0de79.

    1. Ah this is exactly the type of thing I was looking for. Thanks, I'll go ahead with this approach.

  3. 
      
maubin
david
  1. Ship It!
  2. 
      
chipx86
  1. Ship It!
  2. 
      
maubin
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-5.0.x (38203c0)
Loading...