Skip to content

Return userid from check_permission#948

Open
Maillol wants to merge 1 commit into
aio-libs:masterfrom
Maillol:check_permission-returns-user_id
Open

Return userid from check_permission#948
Maillol wants to merge 1 commit into
aio-libs:masterfrom
Maillol:check_permission-returns-user_id

Conversation

@Maillol

@Maillol Maillol commented Dec 6, 2025

Copy link
Copy Markdown
Contributor

What do these changes do?

check_permission now returns the userid instead of None.
This avoids an extra authorization lookup for callers.

Are there changes in behavior for the user?

These changes does not break existing logic (only adds a returned value)

Related issue number

Checklist

  • I think the code is well written
  • Unit tests for the changes exist
  • Documentation reflects the changes

@codecov

codecov Bot commented Dec 6, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.19%. Comparing base (3ad4302) to head (a7b650d).
⚠️ Report is 261 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #948      +/-   ##
==========================================
+ Coverage   94.13%   94.19%   +0.05%     
==========================================
  Files          11       11              
  Lines         597      620      +23     
  Branches       30       22       -8     
==========================================
+ Hits          562      584      +22     
- Misses         26       27       +1     
  Partials        9        9              
Flag Coverage Δ
unit 94.19% <100.00%> (+0.05%) ⬆️

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.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread aiohttp_security/api.py

If user is not authorized - raises HTTPUnauthorized,
if user is authorized and does not have permission -
raises HTTPForbidden.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend putting down what this function returns into the docstring but besides that that's really the only thing I could see as being a possible nitpick for anyone else reviewing this.

Suggested change
raises HTTPForbidden.
raises HTTPForbidden on failure, and returns the user id on success.

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.

2 participants