Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Support dynamically updating authentication headers #6954

Closed
wants to merge 10 commits into from
Closed

[WIP] Support dynamically updating authentication headers #6954

wants to merge 10 commits into from

Conversation

faph
Copy link
Contributor

@faph faph commented Sep 21, 2022

[Work in progress]

Initial basic refactor of BasicAuth object, generalized as an async callable/coroutine.

What do these changes do?

TODO

Are there changes in behavior for the user?

TODO

Related issue number

#6915

Checklist

  • I think the code is well written
  • Unit tests for the changes exist
  • Documentation reflects the changes
  • If you provide code modification, please add yourself to CONTRIBUTORS.txt
    • The format is <Name> <Surname>.
    • Please keep alphabetical order, the file is sorted by names.
  • Add a new news fragment into the CHANGES folder
    • name it <issue_id>.<type> for example (588.bugfix)
    • if you don't have an issue_id change it to the pr id after creating the pr
    • ensure type is one of the following:
      • .feature: Signifying a new feature.
      • .bugfix: Signifying a bug fix.
      • .doc: Signifying a documentation improvement.
      • .removal: Signifying a deprecation or removal of public API.
      • .misc: A ticket has been closed, but it is not of interest to users.
    • Make sure to use full sentences with correct case and punctuation, for example: "Fix issue with non-ascii contents in doctest text files."

@faph faph requested a review from asvetlov as a code owner September 21, 2022 14:36
@faph faph marked this pull request as draft September 21, 2022 14:38
class Auth:
"""Authorization handler base class"""

async def __call__(self, request) -> None:
Copy link
Member

Choose a reason for hiding this comment

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

__call__() is for normal callables, it'd be weird for it to be async. There's an __await__() that exists for awaitables. Maybe don't go for magic methods? It looks like you're reinventing a protocol pattern.

Also, it feels like for the use-case you described using an async generator interface could be a better fit then an async function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the feedback @webknjaz.

It might be useful to collect these high-level design considerations in the corresponding issue #6915. I was using this PR largely just to give an example what an implementation could look like.

@faph faph closed this by deleting the head repository Sep 3, 2023
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.

None yet

2 participants