Fork me on GitHub
#ring-swagger
<
2018-03-22
>
ikitommi08:03:53

@jmckitrick I think they should be handled in the web-tier. But should the auth-related restructurings be shipped with c-api? I’m not sure. There is already things like :components, which were helpers for request-based Component injection. Not sure if anyone uses that anymore as one can inject components/system via closure into a route tree. Much more explicit.

ikitommi08:03:29

But, I don’t have a answer yet, so open to suggestions. Options would be: 1) integrate buddy into c-api, add new keys into the core to easily restructure things &/ guard routes like :current-user, :auth-rules etc + api-level options for different auth-mechanisms 2) do examples how-to do these in the client side (as you have done, BIG thanks!!!!) 3) use more standard extensions like middleware to do this:

(context "/admin" []
   :middleware [[wrap-require-roles #{:admin}]]
   :description "only admins see these routes"
   ...)

ikitommi08:03:23

What do you think would be best?

jmckitrick13:03:56

Hmm, that’s a good question. I’d imagine the less-integrated approach is better, with people still having a choice of authentication libraries.

jmckitrick13:03:34

I’m going to add some more to the auth page of the wiki today.

👍 4
jooivind15:03:17

any good ways of disabling swagger-documentation in production environment?

ikitommi15:03:57

@jooivind it’s just data, so you can set the :swagger to nil:

(defn app [{:keys [dev?]}]
  (api
    {:swagger 
      (if dev? {:spec "/swagger.json", :ui "/api-docs"}})
    ...))

jmckitrick15:03:39

@ikitommi What helped you get to the level of meta-programming you use in compojure-api ?

ikitommi16:03:22

I tried to add swagger support to Spray (a functional Scala web framework) but I coudn’t - just too hard. I was determined that it’s easier with Clojure. Not sure it was, but got it working in the end. Lot of learning macros.

ikitommi16:03:53

oh, it’s over 4 years old now.

jmckitrick16:03:57

I’ve done a decent amount of Common Lisp macros, but not Clojure. Yet. And I’m working on the first Clojure projects in a Scala shop 😉

jmckitrick18:03:31

@ikitommi I think middleware is the best approach for authentication, since it’s consistent with ring’s approach. But I’ve not tried the other approach you suggested, with closures into a route tree. Do you have an example?