ring

synthomat 2020-07-09T12:27:26.109100Z

Hey, I have a rather weird bug: after authentification with friend , the browser (sometimes?) redirects to /favicon.ico – I don’t have a favicon in my code and this error also happens from time to time in my other projects; is this a known ring issue, does it have to do with order of middlewares or is it connected to friend-auth? I can’t find a reason for this behaviour; Does someone have an idea? – Thank you!

jumar 2020-07-09T18:58:27.110300Z

Browsers often request favicon.ico to display it as a mini-icon in the browser tab but I don't see a reason why you should be explicitly redirected there. We use both friend and ring and I've never seen such a behavior

synthomat 2020-07-09T21:10:09.111900Z

so after a successful login the POST /login endpoint returns a 303, and a location header pointing to the favicon file 😐

synthomat 2020-07-09T22:04:46.113600Z

seems like :default-landing-uri of friend is being ignored when this favicon thingy kicks in… on a subsequent login, it works as expected

synthomat 2020-07-09T22:23:28.114200Z

just looking at the session data, there is :cemerick.friend/unauthorized-uri <http://localhost:3000/favicon.ico> … I don’t even…

seancorfield 2020-07-09T22:29:35.115500Z

@synthomat So a request is being made for the favicon before you've auth'd -- which makes sense. I would recommend setting up auth so /favicon.ico is allowed through without requiring auth -- make it an exempt route.

synthomat 2020-07-09T22:30:28.115700Z

oh god, no please…

synthomat 2020-07-09T22:30:31.115900Z

yes!

synthomat 2020-07-09T22:30:52.116400Z

just found this out myself:man-facepalming:

synthomat 2020-07-09T22:31:13.116800Z

had do inject a logging middleware to find out what’s going on…

synthomat 2020-07-09T22:33:37.119500Z

so friend stores the originally requested resource before the authentication page kicks in to conveniently redirect the user back to the original request after successful authentification; but because (technically) favicon.ico happens to be the latest requested resource, friend redirects the user to that file after successful authentification

synthomat 2020-07-09T22:33:43.119700Z

mind -> blown

synthomat 2020-07-09T22:34:10.120100Z

thanks @jumar and @seancorfield!

seancorfield 2020-07-09T22:47:07.121800Z

I only know because it has bitten me countless times in various situations and so now I always make sure that URL is readable regardless of auth/login stuff...

synthomat 2020-07-09T22:47:47.122700Z

wouldn’t it be better if friend stored the redirect url in a query parameter like many other libs do instead in the session?

synthomat 2020-07-09T22:51:02.123600Z

good point @seancorfield, I now just added a fake favicon to my resource folder and it seems to do the trick; friend does not intercept because it’s a file that can actually be fetched

seancorfield 2020-07-09T22:58:40.124400Z

(I've never used Friend or Buddy or any other Clojure auth lib)