Commit Graph

7 Commits (master)

Author SHA1 Message Date
radex 6f51489194 Add Gravatar-style avatar endpoint, rename user-based requests to /avatar/user/<uid> 2023-10-23 19:48:03 +02:00
radex 20acdee93c avatar: remove expired cache entries 2023-10-14 16:03:39 +02:00
radex b10f6478da avatar: don't generate avatars for non-users 2023-10-14 16:02:47 +02:00
radex a6cc147595 avatar: move timeout to config 2023-10-14 15:59:55 +02:00
radex fede3f68e5 preprocess avatar when uploading 2023-10-14 15:53:06 +02:00
radex 92a5ebac2f delete user avatar 2023-10-14 15:31:27 +02:00
q3k a435e15698 Implement LDAP avatar serving
This adds a /avatar/<uid> endpoint which serves any jpegPhoto associated
with a given user account.

In true 'lol ldap' fashion, only `photo` and `jpegPhoto` fields are
defined. The first one is for G3 photos (a fax format!). The latter is
technically for JPEG. But we expect to abuse this and basically contain
_any_ sensible photo format in there, as long as Python's PIL can parse
it.

The serving function always resamples images to a 256x256 PNG. This
makes sure people don't leak EXIF and lets us depend on square avatars.

This entire code assumes that it is safe to PIL.Image.open untrusted
user data. My understanding is that it is, bar some DoS for very large
images. We limit the potential for DoS by storing the images in LDAP,
which I hope has some kind of field length limit...

Oh, and this also adds a 'default avatar' functionality which serves
simple generative mermaid art for any user who doesn't have an explicit
avatar set. To prevent leaking the existence of users who don't have an
avatar set, we serve such a generated avatar for all UIDs, including
UIDs which don't exist.
2023-10-08 18:14:00 +02:00