FYI, here is the code for it: https://github.com/discourse/discourse/blob/master/lib/guardian/user_guardian.rb#L41-L48
And https://github.com/discourse/discourse/blob/master/lib/guardian/post_guardian.rb#L63-L69