Gert Verhoog
unread,Oct 9, 2012, 5:25:55 PM10/9/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to shorele...@googlegroups.com
Hi!
I'm building a Clojurescript application that gets its data from a Clojure server app. Authentication/authorisation are handled server-side, using Chas Emerick's Friend.
If I ask for a piece of data on the server for which I am not authorised, an unauthorised exception is thrown. In a classic server-side application, Ring middleware would catch this exception and either redirect to a login page (when the user is not authenticated), or display an "unauthorised" error message.
In a client-side app that gets its data via XHR requests, things would need to work a little differently.
One possibility would be to have a ring-like middleware stack on the client side, that could be used to observe/intercept/capture/modify responses sent from the remote side. Responses with a certain status (e.g. 401, 403, 404, 5xx) or certain content (a map with an :error key?) could be captured, and an appropriate action could be triggered (e.g. dispatch the event using pub/sub).
My question is: does this sound like a good idea? Does anything like this already exist?
cheers,
gert