SSO avatars not being overridden

AI-generated summary

User windy reported that SSO avatars were not being overridden despite avatar_force_update and sso_overrides_avatar settings being enabled, seeking help after testing on both production and dev environments. Contributor Falco suggested checking specific logs and manually enqueuing the avatar download job. The root cause was identified by lukegb, who traced a code issue where the sso_overrides_avatar flag failed to trigger a Gravatar override because the override_gravatar parameter was not being passed through the necessary job queue. lukegb questioned if this was intentional, to which zogstrip confirmed it was a bug and invited a pull request. Finally, techAPJ announced the issue was fixed in a specific commit, resolving the misleading behavior for future users.

I know there are a few other posts about this, but none of them were able to solve my problem. Everything else in our SSO implementation works fine; this is the only thing that’s not working as expected. I’ve tried setting avatar_force_update to both true and 1 to no avail.

Code snippet w/ verbose log output: SSO.scala · GitHub

Any insight is much appreciated, thanks.

If you’re in development, maybe it’s this:

Edit: nevermind, you’re using non-local URLs.

Bump (sorry)…

DId you enable sso overrides avatar ?

Yes I did. Sorry should have mentioned that.

@Falco Any other possible fixes you can think of? Kind of important I work this out.

In your gist avatar_force_update isn’t set, did you manage to make it true in verbose logging?

Yes sorry, I tried both with and without, I had another instance where it was set to true and still no update.

So even with verbose_logging showing avatar_force_update = true the avatar isn’t updated?

Are you runiing against a production docker instance?

Yeah, I tested on both production and a dev instance on OS X.

EDIT: Just realized I haven’t tested avatar_force_update on prod, will try that and report back.

Ok just tested on our production docker instance @Falco and still no update with avatar_force_update: true in verbose logging.

The user already exists or is he being created as part of the SSO log in?

Also is /sidekiq with a queue? Any errors regarding DownloadAvatarFromUrl?

Also try this in a rails console in a production instance:

user = User.find_by_email(AUSEREMAILHERE)
Jobs.enqueue(:download_avatar_from_url, url: 'http://mycoolavatar.png', user_id: user.id)

and watch logs.

For what it’s worth, it works fine. The main problem is that sso_overrides_avatar is misleadingly named, because it won’t, in fact, override a Gravatar set on a user.

The call to download_avatar_from_url here:

doesn’t pass override_gravatar, so:

doesn’t pass on override_gravatar, so:

won’t set it to the avatar from SSO.

Is this intentional behavior?

No it’s not. Feel free to do a pull request :wink:

Fixed via:

https://github.com/discourse/discourse/commit/0791c2c96636e9af5992d5d0ea6f991018cf4ef6

Thanks! I wasn’t sure if there was an obvious edgecase I’d missed :slight_smile: