r/Clojure • • May 16 '16

Ask /r/Clojure: Secure web frameworks for building REST Api?

I'm evaluating Pedestal and I guess I like it's built-in security features although I'm not sure whether this is just a fluff piece of somebody has actually done a thorough auditing.

I'm working in fintech space and since I'm using datomic I'm pondering what my backend endpoint api stack is going to be. I like the appeal of keeping everything clojure to save the cognitive cost of switching between backend server / datomic, and all in all I've gone through the clojure essentials yesterday and was just blown away by it's concise and straight forwardness, no ambiguity, and see it as a powerful language for dealing with lot of data, and more importantly it feels like the first time I began learning programming, but I digress, I'm turning to the community to get some advice preferably from people who work in fintech.

So should I use Pedestal + Datomic?

I'm sort of wary about using "collection of libraries" that people seem to advocate, and this arises from my experience of using "microframeworks" like Flask in the Python world and ending up googling "how to get stuff I got for free in full MVC frameworks but in Flask + 3rd party libraries that seem sporadically updated by individuals". It left a very bad taste and I've made some pre-judgement here coming to clojure....

However, if I could attain a better security feature by employing the "collection of libraries from the shelf" to build backend API, I might consider it seeing how tight the community is and not flaky like Flask....but again if Pedestal or some full framework on clojure lets me achieve higher productivity and security features then I'd much much prefer the full framework approach.

Anyways I'm going through the more advanced topics on clojure and will come back time to time to check on people's replies.

Thanks y'all.

7 Upvotes

57 comments sorted by

View all comments

Show parent comments

3

u/nefreat May 20 '16

I agree that the OP didn't really state the goals, objectives, and attributes they were targeting. I was hoping my comment would start that dialog. Maybe Pedestal is a great fit, maybe Ring is better, but we don't know until we look deeper.

My point was that if you're starting Clojure I don't think Pedestal (at the moment) is a good fit based on the state of the documentation. Lack of docs coupled with the fact that there are a lot more ring experts on this sub and elsewhere (on this sub: weavejester,yogthos,etc) than pedestal people. A new person would have a much easier time finding code examples and help for ring than pedestal. I'll be happy to change my opinion when the docs improve. Besides the link to my comment from another thread, here's the sample pedestal app which was last touched 3 years ago.

I can talk about the use of Java ServletFilters and Security Frameworks in Pedestal, if you're interested in hearing more about that.

Yep, I am interested to hear more about that. Is the need for interop with servlet based stacks the reason you went with Jetty and not something like Netty?

1

u/ohpauleez May 20 '16

Great questions all around!

Note that Pedestal is just a set Clojure libraries for server-side development. Pedestal App doesn't exist anymore. The Pedestal Samples are all kept up to date with the latest code changes. The community has been really great about contributing to the docs, but they will be overhauled soon.

There is a lot of fantastic prior work for Servlet-based stacks, and they are the most common and well-supported in the Java Web space. Just like Clojure, Pedestal adheres to the "embrace the host" mentality - that means if you're on a Servlet Container, you should be able to leverage everything on that container. Servlet 3.0 provided async capabilities (which Pedestal uses) and Servlet 3.1 provided non-blocking capabilities (which Pedestal also uses in some cases). Pedestal also allows containers to make their own optimizations for sending payloads (especially NIO payloads) using a protocol.

In the upcoming release (which will be cut this month), Pedestal will have Servlet independence. We'll still continue forward with the same default container support we have now (Jetty, Immutant/Undertow, Tomcat), but you're free to run your Pedestal application on whatever you like using Chain Providers - Netty, Vert.x, nginx, whatever fits your problem/solution domain. I can speak more to Chain Providers, their motivation and rationale, if you're interested.