4 ms·
First, "client". A client is anything that calls a server but is outside the trust boundary of that server. And yes, of course there's code that accesses the d
by Spearchucker 10y ago
First, "client". A client is anything that calls a server but is outside the trust boundary of that server.
And yes, of course there's code that accesses the database. The problem is that if it's client code, that code must be trusted by the database.
A better approach is where there's code between the client and the database, also on the server (server estate, at least), that verifies data going into and out of the database.
That isolates client-side changes - malicious, unintentional or otherwise, that might impact the data, because there's a server-side gatekeeper.
So all of a sudden FAAS is more appealing than BAAS, and the FAAS API gateway doesn't just do routing, it does validation too. Guess what, you just created an application/business logic layer on a middle tier, and it's no longer serverless.
"...Why do you think that lambda functions cannot be in the second category..."
They can indeed be in the second category. The author, however, specifically calls out direct database access from the client without lambda functions.
- SideburnsOfDoom 10y agoWhy would a lambda fn be considered untrusted client code? If the database and the lamdba fn are both in AWS, then they're on the same "server estate". How is this any different from the server portion a web app?
- Spearchucker 10y agoMaybe I wasn't clear on that - a lambda function calling the database is indeed trusted.
- lostcolony 10y agoAPI Gateway in AWS can't directly talk to the DB. It has to either hit a mock (where a canned response is sent back), a lambda function, or serve as an HTTP proxy. You may of course be referring to the more abstract concept of an API Gateway that then talks to a backend DB directly without passing through intervening code, and yes, that would be stupid. But you hardly need serverless infrastructure to achieve that level of wrongness; even with a server in between, you can easily achieve the equivalent of that by taking a SQL string from the client verbatim and executing it against your DB.
- solipsism 10y agoThis is something that annoys me about relative terms like "client" and "backend". An entity can simultaneously be the client of one pair and the server of another. No good solution comes to mind, aside from being very explicit. "database client" vs "user client".
- SideburnsOfDoom 10y agoIndeed, this was a very confusing conversation because of it. If by client you mean "a web browser" then "a better approach is where there's code between the client and the database" makes perfect sense; but in the meaning of "client" where any code that calls the database is a client of the database, it's balderdash. I honestly don't think that a "trust boundary" has anything to do with it, generally.
- SideburnsOfDoom 10y ago> The author, however, specifically calls out direct database access from the client without lambda functions. Ah sorry, I missed this part: > 2 Using another example of BaaS, we’ve allowed the client direct access to a subset of our database (for product listings) "The client" in this sense is a web browser and is thus completely untrustworthy. He seems to be talking about read access, hopefully with an api gateway for auth and rate limiting in front of it. But yes, it is wise to be much more wary of this case.