This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-03-22
Channels
- # beginners (240)
- # boot (23)
- # bristol-clojurians (3)
- # cider (101)
- # cljs-dev (52)
- # cljsrn (17)
- # clojure (212)
- # clojure-dusseldorf (2)
- # clojure-greece (2)
- # clojure-italy (9)
- # clojure-russia (1)
- # clojure-spec (91)
- # clojure-uk (33)
- # clojurescript (164)
- # community-development (23)
- # core-async (24)
- # core-logic (9)
- # cursive (18)
- # datavis (1)
- # datomic (119)
- # emacs (13)
- # events (1)
- # figwheel (2)
- # fulcro (86)
- # graphql (1)
- # immutant (5)
- # jobs-discuss (6)
- # leiningen (19)
- # lumo (46)
- # nyc (7)
- # off-topic (23)
- # parinfer (15)
- # pedestal (3)
- # planck (32)
- # re-frame (48)
- # reagent (75)
- # ring-swagger (13)
- # rum (32)
- # shadow-cljs (402)
- # spacemacs (5)
- # specter (3)
- # tools-deps (11)
- # unrepl (20)
- # vim (135)
- # yada (3)
@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.
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"
...)
Hmm, that’s a good question. I’d imagine the less-integrated approach is better, with people still having a choice of authentication libraries.
@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"}})
...))
@ikitommi What helped you get to the level of meta-programming you use in compojure-api
?
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.
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 😉
@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?