reitit

https://cljdoc.org/d/metosin/reitit/ https://github.com/metosin/reitit/
sudakatux 2020-06-11T18:55:05.106300Z

Hi

sudakatux 2020-06-11T18:55:26.106800Z

has anyone integrated buddy access rules with reitit

sudakatux 2020-06-11T18:56:18.107700Z

i would like to know whats the best way of doing it because it seems to me i could somehow define the access rule in the route itself

sudakatux 2020-06-11T18:56:36.108100Z

instead of having a separate function.

sudakatux 2020-06-11T18:57:03.108500Z

Im currently doing it before the router with a middleware

sudakatux 2020-06-11T18:57:07.108800Z

(def rules
  [{:uri "/api/user/*"
    :handler authenticated-or-preflight?}
   {:uri "/api/identity"
    :handler authenticated-or-preflight?}])

(defn on-error
  [request value]
  {:status 403
   :headers {
             "Content-Type" "text"
             }
   :body "Not authorized"})


(defn my-authfn
  [__ token]
  (session-store/get-user-from-store token))

(def backend (backends/token {:authfn my-authfn}))

(defn wrap-base [handler]
  (-> ((:middleware defaults) handler)
      (wrap-access-rules {:rules rules :on-error on-error})
      ;(wrap-authorization auth-backend)
      (wrap-authentication backend)

sudakatux 2020-06-11T18:58:11.109800Z

I was wondering if there is a way i could define it in the route itself using a reitit middlware

sudakatux 2020-06-11T19:27:20.110100Z

disregard

sudakatux 2020-06-11T19:27:32.110400Z

found an example of what i was looking here https://github.com/lipas-liikuntapaikat/lipas

emil0r 2020-06-11T20:40:46.111200Z

Is there any way to have routes in reitit that are on the same level in the hierarchy?

emil0r 2020-06-11T20:41:17.111300Z

emil0r 2020-06-11T20:42:00.112200Z

I’d like to be able to have /word/add and /word/1 for the URI, but reitit is telling me it’s not allowed

ikitommi 2020-06-11T20:50:35.113100Z

@emil0r just add :conflicts nil.

emil0r 2020-06-11T20:51:11.114100Z

In the router options itself?

ikitommi 2020-06-11T20:51:27.114400Z

reitit will use linear router and match the first one. for router options

ikitommi 2020-06-11T20:51:55.114900Z

the exception should have that info in the message

emil0r 2020-06-11T20:52:14.115100Z

Cool. works

emil0r 2020-06-11T20:52:46.116Z

Mostly needed it for breadcrumbs so that I can easily decide a hierarchal structure

emil0r 2020-06-11T20:54:00.116400Z

Hmm… I really need to learn to look for cljdoc. I’m too used to readme’s

emil0r 2020-06-11T20:54:46.116600Z

Thanks @ikitommi

👍 1
gekkostate 2020-06-11T21:17:04.118100Z

Hi all, quick question. Is there an idiomatic way to do route restrictions on the front end? For the moment, I am designating some routes as public in my routes and then my router component, is filtering in/out the public routes.