TencentBlueKing / TencentBlueKing/bkpaas-python-sdk

bkpaas_auth DjangoAuthUserCompatibleBackend 丢失了用户的time_zone

Open Beginner friendly
#301 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
34
Forks
34
Avg merge
18m
Merged PRs (30d)
1

Description

https://github.com/TencentBlueKing/bkpaas-python-sdk/blob/61976219d7ea78df38de30025e54ffeb7b47e8dd/sdks/bkpaas-auth/bkpaas_auth/backends.py#L180

Reason: bkpaas_auth already declares time_zone as a supported user-info field and already stores it in LoginToken.user_info, but DjangoAuthUserCompatibleBackend.connect_to_django_user() drops it when converting the bkpaas_auth.models.User into the project’s Django AuthUser. That makes any downstream app using the compatible backend unable to read request.user.time_zone.

I’d keep our local subclass as a production hotfix, but file an upstream issue/PR so we can remove the shim after upgrading. The upstream fix should probably copy all relevant transient user-info fields, at minimum:

db_user.display_name = getattr(user, "display_name", user.username)
db_user.tenant_id = getattr(user, "tenant_id", None)
db_user.time_zone = getattr(user, "time_zone", None)

Maybe also review chinese_name, avatar_url, email, etc., because bkpaas_auth.models.AbstractUserWithProvider.USERINFO_FIELDS includes more fields than the compatible backend currently propagates. For our immediate bug, time_zone is the concrete missing field.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with sdks/bkpaas-auth/bkpaas_auth/backends.py at DjangoAuthUserCompatibleBackend.connect_to_django_user(), then compare it with bkpaas_auth.models.AbstractUserWithProvider.USERINFO_FIELDS and LoginToken.user_info. Done means the compatible Django AuthUser preserves the concrete time_zone value, with the other supported transient fields reviewed for consistency.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
authentication, backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.