r/Clojure • • Aug 20 '21

JUXT Clojure Radar 2021

https://www.juxt.pro/radar
86 Upvotes

8 comments sorted by

View all comments

2

u/SimonGray Aug 28 '21

Where's Pedestal?

1

u/radioactiveoctopi Sep 05 '21

I’ve asked this before…as well as hunted for more info… outside of interceptors can you tell some of the more inexperienced developers ‘me’ where pedestal shines over ring?

2

u/SimonGray Sep 05 '21 edited Sep 05 '21

Basically, the primary advantage of Pedestal is the simple, data-oriented approach vs. Ring's separate router + middleware (= function decorator) approach. This adds a lot of flexibility to dynamically inspect your web service code during runtime, allowing you do to stuff like what I describe in my second comment which wouldn't be possible in Ring.

This is the actual function that checks routes in advance (and just below that the interceptor chain that adds authorization to a route): https://github.com/kuhumcst/glossematics/blob/master/src/dk/cst/pedestal/sp/interceptors.clj#L386-L402

This is then used for example here: https://github.com/kuhumcst/glossematics/blob/master/src/dk/cst/pedestal/sp/example.clj#L21-L81

So based on SAML assertions about the user (returned from an external service after login), routes are dynamically tested while generating e.g. this basic page and links are either crossed over or not based on the authorization level of the user. The routes are looked up using the router which is fetched out of the interceptor context, making the whole thing entirely decoupled and reusable in other contexts.

I set the required authorization at the route level in my router exactly once per route and then I can call permit-request? from anywhere, with no knowledge of router or the SAML code. It really simplified authorization for me to be able to inspect and run the router in this super decoupled way. And it is highly efficient, both in terms of lines of code and computationally.

1

u/radioactiveoctopi Sep 07 '21

I see… well makes sense. I’m using it now, although slowly. I feel long term I’ll do better learning the ends and outs of pedestal.