This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-04-30
Channels
- # aleph (12)
- # beginners (23)
- # boot (12)
- # cider (40)
- # cljs-dev (8)
- # cljsrn (20)
- # clojars (1)
- # clojure (122)
- # clojure-canada (2)
- # clojure-dev (21)
- # clojure-gamedev (2)
- # clojure-italy (3)
- # clojure-nl (12)
- # clojure-norway (1)
- # clojure-sanfrancisco (3)
- # clojure-spec (59)
- # clojure-uk (114)
- # clojurescript (50)
- # clojurex (1)
- # cursive (2)
- # datascript (2)
- # datomic (26)
- # emacs (5)
- # fulcro (19)
- # garden (1)
- # hoplon (54)
- # leiningen (42)
- # luminus (14)
- # off-topic (24)
- # om (5)
- # onyx (7)
- # re-frame (2)
- # reagent (31)
- # reitit (3)
- # ring-swagger (39)
- # shadow-cljs (8)
- # sql (3)
- # tools-deps (13)
Im trying to add token based authentication to my fulcro app. I found some authentication related stuff in the docs and fulcro-template, but these are username/password/session based, but for my use case i need to pass a token on each request. Are there any examples of token based authentication out there?
So far, i’m using a a custom fulcro network on the client, that adds an authorization header with the token to each api request, but i’m not sure where I should check the token on the server
Hey Chris, I’m trying to do the same thing. How have you managed to do this client side? Because I thought it would be as simple as adding a custom request-middleware wrapper, but as that only receives the request, I don’t know how it can access the token it needs. (I’m sorry I don’t have an answer for your question, because we are using the fulcro easy server with the pre-hook for that).
The entire request should be in the env in the mutations and query handlers on the server already.
Should I wrap fulcro.server/server-read
and fulcro.server/server-write
of check it via a ring middleware (only for “/api”)?
@chrisblom did you check this one out http://book.fulcrologic.com/#_adding_to_the_ring_stack ?
yes, but i’m not using the easy server, and i’m not sure what the hooks can return. Could i just return a {:status 401
here?
Havrent tried it. There is also a http://book.fulcrologic.com/#_adding_to_the_ring_stack . Not sure if its the best place but looks like wrap-api
fn could be a place where to do the token check and return a 401 if it is invalid
Hey Chris, I’m trying to do the same thing. How have you managed to do this client side? Because I thought it would be as simple as adding a custom request-middleware wrapper, but as that only receives the request, I don’t know how it can access the token it needs. (I’m sorry I don’t have an answer for your question, because we are using the fulcro easy server with the pre-hook for that).
@liesbeth @chrisblom http://book.fulcrologic.com/#_doing_the_parsing_yourself The env includes the Ring request on the server, which includes the headers, etc.
@U0CKQ19AQ thanks, i’ll try it there
Since you need it for every request I’d probably build it into the client networking. The new fulcro-http-remote
has a middleware feature for the client, and it’d probably be easiest to add it there at client startup. Implementation mainly depends on whether you have it before or after startup
If I had it only after startup, how would I get my request-middleware to know the token?