clojure

New to Clojure? Try the #beginners channel. Official docs: https://clojure.org/ Searchable message archives: https://clojurians-log.clojureverse.org/
emccue 2021-07-01T03:08:13.235200Z

I've been trying to retrofit friend to accept JWT auth

emccue 2021-07-01T03:08:23.235500Z

not having much luck

emccue 2021-07-01T03:09:00.236200Z

we just need some token based auth scheme for an app to be able to call protected api routes

emccue 2021-07-01T03:09:08.236500Z

has anyone done something similar?

nate sire 2021-07-01T15:11:43.246100Z

Oauth2 is good for protecting APIs. You could use a service on AWS. JWT can work with Oauth2. JWT is a way to format the tokens. Oauth is the protocal (directions, standards) for running it.

nate sire 2021-07-01T15:12:28.246300Z

https://aws.amazon.com/cognito/

emccue 2021-07-01T15:46:02.246900Z

I am reluctant to touch cognito at this point, partially from echoes of screams from previous coworkers

emccue 2021-07-01T15:46:24.247100Z

but it still doesn't really help me significantly at this juncture

emccue 2021-07-01T15:54:42.247300Z

like, i can pretty straightforwardly just issue a token based on email/pass

emccue 2021-07-01T15:55:17.247500Z

I'm just stuck at making the change to let friend say "let them pass if they have session auth or if they gave a jwt"

emccue 2021-07-01T03:11:30.236900Z

it wouldn't be in scope to move to something like buddy unless its required

kennytilton 2021-07-01T12:09:48.242800Z

Someone who thought I knew things asked me how to build a Clojure backend for a React/Vue app. ISTR just starting from a Compojure template, but they asked specifically about Luminus and Fulcro. They had kinda figured out that Fulcro was full-stack and otherwise challenging; they are new to Clojure and wanted "easy". So Luminus would get the nod, but are there other good lightweight backends we should be considering? Thx! 🙏

borkdude 2021-07-01T12:25:25.243700Z

@hiskennyness I personally like #yada as well, but it doesn't seem to be actively worked on at the moment. Having said that, it worked well for the last 4 or so years of using it, for me.

👀 1
➕ 2
cjmurphy 2021-07-01T12:41:18.245300Z

Fulcro is front end only, leaving Pathom to do the back-end work. Fulcro RAD uses Pathom on the back-end. So the lightweight back-end choice in the Fulcro space is really Pathom. I have heard of companies using Pathom as a BE when the FE is Re-frame. Your FE just needs to do EQL (keyword-based) queries.

kennytilton 2021-07-01T13:48:16.245800Z

I know what you mean, but I did get an "all-in" feeling reading the Fulcro docs. I guess this sums it up "Fulcro's architecture spans the entire stack..." and "and providing the architecture for managing that model across the entire stack reduces the number of things you have to cope with when solving your real problems.".

nate sire 2021-07-01T15:13:44.246500Z

I was playing with Coast on Clojure and Duct. I tried Luminus but it was difficult for me to find docs. Maybe it is better. That was a few years ago.

2021-07-01T16:51:41.247800Z

luminus has more comprehensive docs than anything else I know of in its class https://luminusweb.com/docs/guestbook of course you'll usually be looking for docs about the actual libs that luminus gives you

seancorfield 2021-07-01T17:25:11.248100Z

I don't think Luminus is really as "easy" as it might appear on first look. Sure, it's a nice, comprehensive template that can create a full-featured project outline but it uses a lot of libraries and has a pretty opinionated structure. Beginners tend to flail as soon as anything goes wrong because there are so many moving parts.

seancorfield 2021-07-01T17:25:56.248300Z

I recommend beginners start with just compojure + ring. Compojure-api if they specifically want an API with Swagger support.

kennytilton 2021-07-01T17:29:14.248500Z

Agreed on Compojure, and thanks for the heads up on Luminus. My compatriot is a brave and very bright Clojure noob tasked with building a serious production backend, so he may be game for steeper learning curve that gets him where he needs to be faster. I'll give him the options!

kennytilton 2021-07-01T17:31:20.249200Z

Interesting suggestion. Inactive may not be bad if it means "done", and it sounds like it is mature. I have shared that option with my firend. Thx!

emccue 2021-07-01T18:53:24.249800Z

personally compojure still confuses me sometimes - if starting from scratch I would prob. point someone to https://github.com/metosin/reitit since it requires less macro understanding

seancorfield 2021-07-01T19:03:33.250100Z

That's a good point. I would probably choose reitit now for a new web app, but I haven't used it at all so I don't tend to think of it when folks ask about simply getting started.

nikolavojicic 2021-07-01T23:55:09.254200Z

Anybody using https://github.com/metosin/jsonista knows how to read JSON date as date and not as string?

(json/read-value (json/write-value-as-string (java.util.Date.)))
(json/read-value (json/write-value-as-string (java.time.Instant/now)))
(json/read-value (json/write-value-as-string (java.time.LocalDateTime/now)))
(json/read-value (json/write-value-as-string (java.time.OffsetDateTime/now)))
All of these are read as strings. Ofc I can call e.g. java.time.Instant/parse on string but imagine nested JSON object.

cjmurphy 2021-07-01T23:56:55.254400Z

@hiskennyness Yeah the 'architecture [of Fulcro] spans the entire stack' (quote copied from https://fulcro.fulcrologic.com/) if you haven't yet introduced EQL and Fulcro RAD (which is where Fulcro starts to use Pathom). Another thing that should probably be said is that Pathom is not necessarily 'server-side'. For example for a Fulcro app against a REST back-end the recommended approach is to put Pathom on the browser (Fulcro's BE just being the default first one: :remote). (Of course with a Vue.js FE Pathom would be on the server).