Fork me on GitHub
#reitit
<
2021-04-28
>
jacekschae07:04:52

Today’s episode of ClojureScript Podcast is with @miikka about Reitit — check it out https://clojurescriptpodcast.com

🎉 8
wegi07:04:20

Hey, I use reitit for the frontend and have use-fragments set to false . But now jump links do not seem to work, i.e. when a link http://example.com#any-id is klicked, nothing happens. Is this a reitit thing, or am I looking in the wrong direction?

wegi07:04:33

Okay, the solution is actually in the docs for anyone looking: https://cljdoc.org/d/metosin/reitit/0.5.12/api/reitit.frontend.easy :ignore-anchor-click? is customizable and takes a function.

Michaël Salihi07:04:22

Yes, it's also explain in this part of this vid: https://youtu.be/ChUzrcB9L1c?t=551

👍 2
Ronny Løvtangen20:04:22

Hi. Is it possible to configure authorizations when using reitit-swagger? What I am trying to accomplish, is a Authorize-button in upper right corner where I can provide a token on a global level. Example of Swagger docs with such button: https://api.prodreg.no/restapi/v1/doc3/#/ So far we have only added authorization header to routes:

(ring/router
...
  ["/client" {:parameters {:header [:map schema/AccessToken]}
              ...
(def token-pattern #"^Bearer (.+)$")

(def AccessToken [:authorization
                  {:description "SSO access token"
                   :json-schema/example "Bearer eyJhbGciOiJS..."}
                  [:re token-pattern]])
But then I need to provide token for each invocation

Ronny Løvtangen20:04:59

Looks like I’m onto something:

{:get {:no-doc true
       :swagger {:info {:title "Title"
                        :description "Desc"}
                 :securityDefinitions {}}
       :handler (swagger/create-swagger-handler)}}
After adding :securityDefinitions {} I got the Authorize button Now I just need to figure out what to put inside {}

Ronny Løvtangen21:04:51

Finally got it working:

:securityDefinitions {:bearerAuth {:type "apiKey" :name "Authorization" :in "header"}}
In addition, routes must be configured to use this securityDefinition:
["/client" {:swagger {:security [{:bearerAuth []}]}}
   ...
Documentation: https://swagger.io/docs/specification/2-0/authentication/ What got me on the right track was this example, although it has empty :securityDefinitions: https://github.com/metosin/ring-swagger/blob/master/test/ring/swagger/swagger2_test.clj

Ronny Løvtangen21:04:11

:security [{:bearerAuth []}]
can be set alongside securityDefinitions as well:
["/swagger.json" {:get {:no-doc true
                        :swagger {:info {:title "Title"
                                         :description "Desc"}
                                  :security [{:bearerAuth []}]
                                  :securityDefinitions {:bearerAuth {:type "apiKey" :name "Authorization" :in "header"}}}
                        :handler (swagger/create-swagger-handler)}}]

👍 3