Skip to content

Set client session User-Agent when fetching server metadata and JWKs#867

Open
alex-ball wants to merge 2 commits intoauthlib:mainfrom
alex-ball:patch-1
Open

Set client session User-Agent when fetching server metadata and JWKs#867
alex-ball wants to merge 2 commits intoauthlib:mainfrom
alex-ball:patch-1

Conversation

@alex-ball
Copy link
Contributor

What kind of change does this PR introduce?

This is a fix for issue #704.

Requests for server metadata and JWKs (from the /.well-known/ Open ID Connect endpoints) as part of authorize_redirect() can fail if the user agent string is missing or inappropriate. This fix adds the Authlib user agent string in exactly the same way as OAuth1Base._get_oauth_client() and OAuth2Base._get_oauth_client().

Tests have been added to demonstrate the fix in both the synchronous case (Flask client) and asynchronous case (Starlette client). Since they test headers sent during load_server_metadata, the two test_oauth2_fetch_metadata tests could be adapted or extended to test PR #710 (dealing with a related but more general issue).

Checklist

  • The commits follow the conventional commits specification.
  • You ran the linters with prek.
  • You wrote unit test to demonstrate the bug you are fixing, or to stress the feature you are bringing.
  • You reached 100% of code coverage on the code you edited, without abusive use of pragma: no cover
  • If this PR is about a new feature, or a behavior change, you have updated the documentation accordingly. (N/A)

  • You consent that the copyright of your pull request source code belongs to Authlib's author.

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