Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix error in throttling when request.user is None#8370

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

4nickel
Copy link
Contributor

While trying to remove the Django authentication module, I've ran into an error when using the configuration below.
Specifically, anAttributeError is raised because DRF does not expect the user to beNone.

# settings.pyREST_FRAMEWORK= {    ..."DEFAULT_THROTTLE_CLASSES": ("rest_framework.throttling.AnonRateThrottle",    ),"DEFAULT_THROTTLE_RATES": {"anon":"10000/day"},'DEFAULT_AUTHENTICATION_CLASSES': [],'DEFAULT_PERMISSION_CLASSES': [],'UNAUTHENTICATED_USER':None,}

This PR fixes the issue by checking ifrequest.user is set before proceeding with further authentication checks.
The test suite and pre-commit hooks are passing. If needed, I'll be happy to write a test-case for this.

As this is my first contribution to DRF please let me know in case I am missing any contribution guidelines. I'd like for the process to be as seamless as possible.

Thank you for your time and consideration.

alexgutjahr reacted with hooray emoji
Check to see if request.user is set before proceeding with furtherauthentication checks.
@shredding
Copy link

This affects me as well. Is there a chance to merge that soon?

@alexgutjahr
Copy link

+1

@stale
Copy link

stalebot commentedJun 23, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stalestalebot added the stale labelJun 23, 2022
@tomchristie
Copy link
Member

Normally you'd expect anUnauthenticatedUser instance in this case, but I don't have any objections to this.

@tomchristietomchristie merged commit129890a intoencode:masterJun 24, 2022
@stalestalebot removed the stale labelJun 24, 2022
@4nickel4nickel deleted the fix/allow-none-user-in-throttling branchJune 27, 2022 08:55
sigvef pushed a commit to sigvef/django-rest-framework that referenced this pull requestDec 3, 2022
Check to see if request.user is set before proceeding with furtherauthentication checks.
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@AliRn76AliRn76AliRn76 approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

5 participants
@4nickel@shredding@alexgutjahr@tomchristie@AliRn76

[8]ページ先頭

©2009-2025 Movatter.jp