Skip to content

packages/django-channels-postgres: refresh pool credentials on connection attempts - #26505

Merged
rissson merged 2 commits into
goauthentik:mainfrom
montiblanc97:codex/refresh-channel-pool-credentials
Sep 29, 2026
Merged

rissson merged 2 commits into
goauthentik:mainfrom
montiblanc97:codex/refresh-channel-pool-credentials

Conversation

@montiblanc97

@montiblanc97 montiblanc97 commented Sep 28, 2026 •

Copy link
Copy Markdown

Details

What does this PR change?

Pass make_conninfo as a callable so the channel-layer pool reads fresh credentials on each connection attempt.

Calling make_conninfo() reads the password once when the pool is created. Passing make_conninfo lets psycopg call it for each new connection or retry, picking up the current token from the password file. Existing connections are unaffected.

Why is this change needed?

The pool currently saves the password when it's created. With RDS IAM tokens, reconnects can keep using an expired token even after the password file has been refreshed.

authentik documents file-based configuration and password hot-reloading. This makes pool reconnects follow that behavior. The existing psycopg_pool dependency supports it.

How was this tested?

Added a regression test that rotates credentials between failed connection attempts. It fails before the fix and passes afterward using the real pool with mocked connections.

Tested in the authentik 2026.2.6 image with the updated source. Ruff passes. Full make all and Black were not run.

Linked issues

None.

AI assistance

Codex helped investigate the bug, write and test the fix, and draft this description.


Checklist

  • The project has been linted, built, and tested (make all)
  • The documentation has been updated and formatted (make docs)
  • I have read the AI usage policy.

@netlify

netlify Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for authentik-integrations ready!

Name Link
🔨 Latest commit 5c3c5e2
🔍 Latest deploy log https://app.netlify.com/projects/authentik-integrations/deploys/6abb27b5fd5297000899696a
😎 Deploy Preview https://deploy-preview-26505--authentik-integrations.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for authentik-storybook ready!

Name Link
🔨 Latest commit 5c3c5e2
🔍 Latest deploy log https://app.netlify.com/projects/authentik-storybook/deploys/6abb27b554a72a00074993c6
😎 Deploy Preview https://deploy-preview-26505--authentik-storybook.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for authentik-docs ready!

Name Link
🔨 Latest commit 5c3c5e2
🔍 Latest deploy log https://app.netlify.com/projects/authentik-docs/deploys/6abb27b5bc5d540008401185
😎 Deploy Preview https://deploy-preview-26505--authentik-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@montiblanc97
montiblanc97 marked this pull request as ready for review September 28, 2026 13:22
@montiblanc97
montiblanc97 requested a review from a team as a code owner September 28, 2026 13:22
@codecov

codecov Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.11%. Comparing base (53d9421) to head (5c3c5e2).
⚠️ Report is 12 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #26505      +/-   ##
==========================================
+ Coverage   92.02%   92.11%   +0.08%     
==========================================
  Files        1179     1180       +1     
  Lines       77366    77400      +34     
  Branches     4121     4121              
==========================================
+ Hits        71198    71296      +98     
+ Misses       6115     6051      -64     
  Partials       53       53              
Flag Coverage Δ
conformance 33.18% <0.00%> (-0.02%) ⬇️
e2e 37.92% <0.00%> (+0.45%) ⬆️
integration 29.52% <0.00%> (-0.46%) ⬇️
rust 44.79% <ø> (ø)
unit 93.64% <100.00%> (+<0.01%) ⬆️
unit-migrate 93.65% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@BeryJu
BeryJu requested a review from rissson September 28, 2026 16:03
@rissson rissson self-assigned this Sep 28, 2026
@rissson rissson added area:backend backport/version-2026.5 Add this label to PRs to backport changes to version-2026.5 backport/version-2026.8 Add this label to PRs to backport changes to version-2026.8 labels Sep 28, 2026
@rissson
rissson merged commit 359e1cc into goauthentik:main Sep 29, 2026
138 of 139 checks passed
@authentik-cherry-pick

Copy link
Copy Markdown
Contributor

🍒 Cherry-pick to version-2026.8 created: #26548

@authentik-cherry-pick

Copy link
Copy Markdown
Contributor

🍒 Cherry-pick to version-2026.5 created: #26549

rissson pushed a commit that referenced this pull request Sep 30, 2026
…tion attempts (cherry-pick #26505 to version-2026.5) (#26549)

packages/django-channels-postgres: refresh pool credentials on connection attempts (#26505)

Co-authored-by: Andrew Wong <[email protected]>
Co-authored-by: Dominic Roy <[email protected]>
rissson pushed a commit that referenced this pull request Sep 30, 2026
…tion attempts (cherry-pick #26505 to version-2026.8) (#26548)

packages/django-channels-postgres: refresh pool credentials on connection attempts (#26505)

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

Labels

area:backend backport/version-2026.5 Add this label to PRs to backport changes to version-2026.5 backport/version-2026.8 Add this label to PRs to backport changes to version-2026.8

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants