Skip to content

Upgrade django-oauth-toolkit 1.7.1 to 3.3.0#375

Closed
blaipr wants to merge 2 commits into
ctrliq:mainfrom
blaipr:feature/django-oauth-toolkit-3
Closed

Upgrade django-oauth-toolkit 1.7.1 to 3.3.0#375
blaipr wants to merge 2 commits into
ctrliq:mainfrom
blaipr:feature/django-oauth-toolkit-3

Conversation

@blaipr

@blaipr blaipr commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

SUMMARY

Removes the long-standing django-oauth-toolkit<2.0.0 cap ("breaking changes that will need to be worked out") and upgrades to 3.3.0, working out those changes:

  • Migration 0198 brings the swapped models up to date with the new abstract models. OAuth2AccessToken.token_checksum is added in three stages exactly like django-oauth-toolkit's own 0012_add_token_checksum migration (nullable column → data migration computing checksums for existing tokens → unique + indexed), so existing access tokens keep working. token becomes a TextField. OAuth2Application gains post_logout_redirect_uris, allowed_origins and hash_client_secret.
  • hash_client_secret defaults to False on our model. AWX stores client secrets encrypted (reversible) via OAuth2ClientSecretField, not hashed. django-oauth-toolkit's _check_secret() falls back to constant-time comparison for non-hashed secrets, so existing application client credentials continue to authenticate unchanged, and new secrets keep AWX's encrypted storage (DOT's hashing field is fully overridden by ours).
  • The stale django-oauth-toolkit UPGRADE BLOCKER section in requirements/README.md (which suggested "may be fixable by creating a migration on our end?") is updated — that is what this PR does.
  • oauthlib 3.2.2 → 3.3.1 comes along as DOT 3.3's requirement.

Stacked on #374 — merge that first; this branch contains its commit.

ISSUE TYPE

  • New or Enhanced Feature

COMPONENT NAME

  • API

ASCENDER VERSION

awx: 25.4.1.dev5+gcda0899.d20260610

ADDITIONAL INFORMATION

  • awx-manage migrate applied cleanly to a populated dev database (including DOT's own packaged 0006–0014 migrations for the non-swapped RefreshToken/IDToken models).
  • Full suite against this branch state, best of three consecutive runs was fully clean:
py.test --create-db -n auto --dist=loadfile awx/main/tests/unit awx/main/tests/functional awx/conf/tests awx/sso/tests
3476 passed, 6 skipped
  • The other two runs each had 1–2 failures from a pre-existing main-branch flake, unrelated to this PR: the suite's four TransactionTestCase classes commit real rows to the per-worker SQLite DB, and Django's whole-DB FK check_constraints() at every rollback-test teardown can trip over the leaked state (victim test varies with xdist scheduling: test_update_model::test_normal_get, test_secret_key_regeneration::test_job_start_args, test_survey_spec password tests). Reproduced on unmodified main with unmodified dependency pins; all victims pass in isolation.
  • Note for whoever merges: if another migration lands before this, 0198 needs renumbering (regenerate with make dbchange).

blaipr added 2 commits June 11, 2026 00:48
…wed versions

- twisted 26.4.0rc2 -> 26.4.0 (rc promoted to stable, CVE-2026-42304 line unchanged)
- kubernetes 29.0.0 -> 36.0.2 (new transitive dep durationpy added; google-auth
  and rsa are no longer required and drop out of the lockfile)
- pyyaml 6.0.1 -> 6.0.3 (required by kubernetes 36.0.2)
- Cython 0.29.37 -> 3.2.5 (the <3 cap predated pyyaml 6.0.1 fixing Cython 3
  source builds; comment updated)
- django 5.2.14 -> 5.2.15 (latest 5.2 patch; <6.0 cap kept and annotated:
  django-ansible-base requires Django<6.0 and djangorestframework<3.16)
- licenses/: add durationpy, remove google-auth and rsa (keeps test_licenses green)
Removes the long-standing <2.0.0 cap. Migration 0198 brings the swapped
OAuth2 models up to date with the new abstract models:

- OAuth2AccessToken gains token_checksum, added in three stages exactly
  like django-oauth-toolkit's own 0012 migration (nullable column, data
  migration computing checksums for existing tokens, then unique+indexed)
  so existing tokens keep working; token becomes a TextField.
- OAuth2Application gains post_logout_redirect_uris, allowed_origins and
  hash_client_secret.

hash_client_secret defaults to False on our model: AWX stores client
secrets encrypted (reversible) via OAuth2ClientSecretField rather than
hashed, and django-oauth-toolkit's validator falls back to a
constant-time comparison for non-hashed secrets, so existing client
credentials continue to authenticate unchanged.

The stale django-oauth-toolkit UPGRADE BLOCKER note in
requirements/README.md is updated to describe the new state.
@blaipr

blaipr commented Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

Closing for now — will resubmit after #374 merges, so the PRs can be reviewed and merged one at a time.

@blaipr blaipr closed this Jun 10, 2026
@blaipr blaipr deleted the feature/django-oauth-toolkit-3 branch June 10, 2026 23:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant