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

[server] fix private GitHub avatars #20461

Merged
merged 2 commits into from
Dec 17, 2024
Merged

[server] fix private GitHub avatars #20461

merged 2 commits into from
Dec 17, 2024

Conversation

filiptronicek
Copy link
Member

Description

A recent GitHub change changed the way of accessing a user's avatar. Potentially as an anti-bot/spam measure, GitHub now issues JWT-signed URLs for avatars on both https://github.com and as part of their API responses to some users, making it impossible for us to continue storing them like we do now - i.e. without any refreshes ever. Additionally, these JWT signatures inflate the URL length, preventing it from fitting into our DB's avatarUrl column.

Let's take a look at the new URL structure:

https://private-avatars.githubusercontent.com/u/37021919?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTEiLCJleHAiOjE3MzQ0MjYwMDAsIm5iZiI6MTczNDQyNDgwMCwicGF0aCI6Ii91LzM3MDIxOTE5In0.zOrR2kgZWVvZqcVgoUwADtQqQmZ6Yh9Tie1CQPi7ADY&s=200&v=4

Here, we can see the jwt query param being used to authorize the request. If it's omitted, invalid, or when the underlying JWT expires, we get a 404.

The old avatar URLs seem to still work as before, but don't get issued anymore to the users in this cohort.

https://avatars.githubusercontent.com/u/37021919?v=4

What this PR does is that it simply rewrites the private-avatars.githubusercontent.com URL into a avatars.githubusercontent.com if it encounters it.

Related Issue(s)

Fixes CLC-1050

How to test

Try logging in into the preview environment, that's all.

https://ft-gh-public-avatars.preview.gitpod-dev.com/workspaces

/hold

@roboquat roboquat merged commit da1d931 into main Dec 17, 2024
18 checks passed
@roboquat roboquat deleted the ft/gh-public-avatars branch December 17, 2024 09:20
@filiptronicek
Copy link
Member Author

I raised a discussion about this in the GitHub community forum: https://github.com/orgs/community/discussions/147297

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants