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: (Azure AD) Check for valid profile picture response before converting to base64 #3656

Merged
merged 6 commits into from
Jan 20, 2022

Conversation

davidchalifoux
Copy link
Contributor

@davidchalifoux davidchalifoux commented Jan 17, 2022

Reasoning 💡

Currently, the profile() function for Azure AD takes a response from the Microsoft Graph API and converts it to base64 for profile pictures. Unfortunately, this has caused bugs for my project because it doesn't make sure that the response from Microsoft is valid before converting. Users without a photo set on their account will not recieve a valid response, but an invalid "image" will still be returned.

This PR adds a small check to the profile photo response to make sure the HTTP-status is 200-299. If the status is outside of that range, the profile image is left as an empty string.

Checklist 🧢

  • Documentation
  • Tests
  • Ready to be merged

Affected issues 🎟

None

@github-actions github-actions bot added core Refers to `@auth/core` providers labels Jan 17, 2022
@codecov-commenter
Copy link

codecov-commenter commented Jan 17, 2022

Codecov Report

Merging #3656 (d16354a) into main (a4d831d) will decrease coverage by 0.02%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3656      +/-   ##
==========================================
- Coverage   13.04%   13.01%   -0.03%     
==========================================
  Files          92       92              
  Lines        1449     1452       +3     
  Branches      385      387       +2     
==========================================
  Hits          189      189              
- Misses       1246     1249       +3     
  Partials       14       14              
Impacted Files Coverage Δ
src/providers/azure-ad.ts 0.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a4d831d...d16354a. Read the comment docs.

Copy link
Member

@balazsorban44 balazsorban44 left a comment

Choose a reason for hiding this comment

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

Thanks! Added a small suggestion.

src/providers/azure-ad.ts Outdated Show resolved Hide resolved
@balazsorban44 balazsorban44 merged commit 4824f8c into nextauthjs:main Jan 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Refers to `@auth/core` providers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants