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

Fix parsing of PEM and RSA keys #65

Merged
merged 1 commit into from
Jun 27, 2022
Merged

Fix parsing of PEM and RSA keys #65

merged 1 commit into from
Jun 27, 2022

Conversation

paulineribeyre
Copy link
Contributor

Fix a bug introduced in 6.0.2 by #52 when using authutils.token.fastapi.access_token:

Traceback (most recent call last):
  File "/env/lib/python3.9/site-packages/authutils/token/fastapi.py", line 90, in getter
    pub_keys = await pub_keys
fastapi.exceptions.HTTPException

This is caused by calling the OrderedDict constructor with a list of dicts instead of a list of tuples.

Fence's /.well-known/jwks endpoint returns:

{
  keys: [
    {
      kid: "<kid>",
      kty: "RSA",
      n: "<key>",
      [...]
    }
  ]
}

while the /jwt/keys endpoint returns the keys in PEM format:

{
  keys: [
    [
      "<kid>",
      "-----BEGIN PUBLIC KEY----- <key> -----END PUBLIC KEY----- ",
    ]
  ]
}

Since version 6.0.2, get_keys_url can return the URL to either endpoint, and access_token was not updated to work with the non-PEM format.

Bug Fixes

  • Fix authutils.token.fastapi.access_token to accept both PEM and RSA key formats

@github-actions
Copy link

The style in this PR agrees with black. ✔️

This formatting comment was generated automatically by a script in uc-cdis/wool.

@paulineribeyre paulineribeyre merged commit 41295ce into master Jun 27, 2022
@paulineribeyre paulineribeyre deleted the fix/key-parsing branch June 27, 2022 20:58
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