This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-04-14
Channels
- # babashka (53)
- # beginners (158)
- # calva (25)
- # cider (21)
- # clara (1)
- # clj-kondo (12)
- # cljsrn (6)
- # clojure (94)
- # clojure-australia (2)
- # clojure-bay-area (6)
- # clojure-europe (40)
- # clojure-nl (10)
- # clojure-spec (16)
- # clojure-uk (18)
- # clojurescript (95)
- # cursive (14)
- # data-science (1)
- # datascript (6)
- # datomic (18)
- # depstar (2)
- # duct (36)
- # emacs (15)
- # events (4)
- # fulcro (16)
- # graalvm (10)
- # helix (25)
- # honeysql (6)
- # jackdaw (4)
- # jobs (2)
- # leiningen (24)
- # lsp (4)
- # malli (10)
- # off-topic (3)
- # pathom (3)
- # polylith (19)
- # practicalli (4)
- # prelude (1)
- # re-frame (6)
- # reagent (13)
- # reitit (3)
- # remote-jobs (10)
- # ring (12)
- # ring-swagger (2)
- # shadow-cljs (54)
- # testing (17)
- # tools-deps (10)
- # xtdb (14)
Hello! I'm trying to use oauth2 lib https://github.com/weavejester/ring-oauth2 with reitit. But for some reason the uri-redirection (from oauth2) doesn't work. There is the following note in the lib: Please note, you should enable cookies to be sent with cross-site requests, in order to make the callback request handling work correctly, eg:
(wrap-defaults handler (-> site-defaults (assoc-in [:session :cookie-attrs :same-site] :lax)))
which I thought it was the main suspect.
After a long debug session I figured out that indeed, something went wrong with the session.
Did some search in google and found this https://github.com/metosin/reitit/issues/205
So, it seems that this is a reitit problem? I tried to apply any of the mentioned fixes but nothing worked.
I use a default middleware this way (from here https://github.com/ring-clojure/ring-defaults) :
(defn site-defaults-middlewares
[handler]
(ring-mid-def/wrap-defaults handler (-> ring-mid-def/site-defaults
(assoc-in [:security :anti-forgery] false)
(assoc-in [:session :cookie-attrs :same-site] :lax))))
and I just have a github oauth2 middleware:
(defn github-oauth2-middleware
[handler]
(oauth2/wrap-oauth2
handler
{:github
{:authorize-uri ""
:access-token-uri ""
:client-id "client-id"
:client-secret "secret"
:scopes ["user:email"]
:launch-uri "/oauth2/github"
:redirect-uri "/oauth2/github/callback"
:landing-uri "/welcome"}}))
finally my routers are define this way
(ring/ring-handler
(ring/router
[["/routes"..{:handler ...}......]]
{:data {:middleware [midlewares here....]})))
Sorry for the long post, thanks in advance