off-topic

https://github.com/clojurians/community-development/blob/master/Code-of-Conduct.md Clojurians Slack Community Code of Conduct. Searchable message archives are at https://clojurians-log.clojureverse.org/
uosl 2020-11-06T11:42:13.300100Z

Any opinions on how HTTP requests and authentication should be managed on a SPA that has to communicate with multiple servers on different domains? Obviously saving auth data only in the backend's session is most secure, but this would mean all requests from the SPA need to be proxied through this backend. On the other hand, using localstorage to store auth data is less secure, and the SPA would still need to send OPTIONS preflight requests, which also is a performance penalty. Which is actually better from a performance standpoint?

Mno 2020-11-06T13:02:58.301400Z

I'm no expert by any regard but normally for this kind of situation I use a middleman backend which talks to all the secondary servers

Mno 2020-11-06T13:03:49.302600Z

So auth can be shared but also remains in the backend

Mno 2020-11-06T13:04:54.303700Z

I don't really know the performance implications in your original question, unfortunately

uosl 2020-11-06T16:15:40.305500Z

Yea, I think that's the most common. I just wonder how much it affects performance, as all requests will essentially have a detour added to them. This SPA is a frontend to multiple biological databases managed by different organizations, and it's up to the user to decide which server to use.

rakyi 2020-11-06T16:21:16.306700Z

> using localstorage to store auth data is less secure What do you mean by auth data? I donโ€™t see a problem with having session cookies set by different servers.

2020-11-06T16:33:34.308Z

(Maybe overkill) You can look at the PKCE Oauth Flow, that is meant to securely obtain an access token for your APIs (say a JWT) without having to trust the client in storing some form of secret

๐Ÿ‘Œ 1
rakyi 2020-11-06T16:34:56.308700Z

and yeah, donโ€™t store anything sensitive in localStorage, itโ€™s not secure

2020-11-06T16:36:24.308800Z

To elaborate, storing tokens in localstorage can mean tokens can get stolen by XSS attacks

๐Ÿ‘ 2
uosl 2020-11-06T17:25:01.309800Z

By auth data I mean tokens, and yes I'm aware of XSS.

seancorfield 2020-11-06T17:50:23.311Z

@regen We use an OAuth flow for this: an Auth Server (that just hands out tokens), a Login Server for actual authentication, and then all the other services invoked from our SPA pass the access token.

seancorfield 2020-11-06T17:50:55.311700Z

(and the SPA talks to the Auth Server periodically to update its access token from the refresh token that it got from the Auth Server after login)

dpsutton 2020-11-06T20:44:44.312100Z

https://ocaml.org/ is erroring out ๐Ÿ˜ž

2020-11-06T22:03:30.325600Z

it works for me right now?

2020-11-06T22:03:40.325800Z

it's a great language, one of my favorites

2020-11-06T22:04:00.326Z

@regen I would go with the broker backend. This will limit your auth complexity to the broker and provide more flexibility for security. It also means that if any of the services you need to access change their auth processes or add new auth services, you only need to update the broker, not every client. The downside is that it will increase network traffic, may represent a single point of failure, could be a performance bottleneck and provides a rich target for adversaries. This type of question is challenging because the right answer also depends a lot on context. The level of threat and associated risk depends a lot on the types of services your accessing and the value (to others) of the data you need to protect. My preference has been for a architecture similar to what @seancorfield outlines. The additional traffic querying the auth server is minimal and having tokens with timeouts and authz as well as authn info provides a lot of flexibility and you can control access from a single point.

dpsutton 2020-11-06T22:04:03.326100Z

back up now i guess

dpsutton 2020-11-06T22:04:23.326300Z

yeah i've been dabbling recently. i really miss HM type systems

2020-11-06T22:05:45.326500Z

I've been having some fun with zig lately - it simplifies a lot of the cruftiness of C while being as low level, and adds HM type inference as well

2020-11-06T22:06:03.326700Z

c : c++ :: zig : rust, more or less

2020-11-06T22:06:30.326900Z

also zig does modules the same way OCaml does, they are data structures