I looked at the sources, guess I catch the idea, but I have several notes/questions.
Firstly, looks like there is no option to login with JavaScript disabled, because Persona authentication on client side based on JavaScript itself, thus if I use it, I should not focus on how my site should work for clients without JavaScript [1].
Secondly, this is what I want:
- User requested a page
- If user does not logged in redirect him to homepage/sign-in page, where sign-in button is, otherwise show requested page.
- User clicks on "Sign in" button – show popup.
So in case of separated homepage and sign-in page, I need to be able change markup of sign-in page, which I believe hardcoded, even if I use redirect and/or rewrite rules (for example to have different translations for "Sign in" button itself).
So, one possible solution is to use AJAX and JSON API as you mentioned. Probably I'll use this way.
Second possibility is not to use auth plugin at all, but implement all process myself. It this case I should clearly understand how authentication handled on server side by Yesod. However, in general this should be quite trivial – I need a JavaScript on client side, so when user logs in or out, this script should send proper request to the server, where I have to manage session store correctly (I don't know is there something else about user authentication, I assume that other actions should be needed).
For now easiest way seems to have a sign-in button, Persona's javascript library and little custom script on home page, which will listen to Persona's events and when user logged in it should send AJAX request or redirect user to login verification page. Hmm, so I have to manage session manually anyway. But I could look BrowserId auth plugin source code again, to understand what should I do after login verified or not, right?