On Wed, Feb 1, 2023 at 3:37 PM Jacob Champion <jchamp...@timescale.com> wrote: > > I'm not an expert on this stuff, but to me that feels like a weak and > > fuzzy concept. If the client is going to tell the server something, > > I'd much rather have it say something like "i'm proxying a request > > from my local user rhaas, who authenticated using such and such a > > method and connected from such and such an IP yadda yadda". That feels > > to me like really clear communication that the server can then be > > configured to something about via pg_hba.conf or similar. Saying "use > > in-band authentication only", to me, feels much murkier. As the > > recipient of that message, I don't know exactly what to do about it, > > and it feels like whatever heuristic I adopt might end up being wrong > > and something bad happens anyway. > > Is it maybe just a matter of terminology? If a proxy tells the server, > "This user is logging in. Here's the password I have for them. DO NOT > authenticate using anything else," and the HBA says to use ident auth > for that user, then the server fails the connection. That's what I > mean by in-band -- the proxy says, "here are the credentials for this > connection." That's it.
I don't think that's quite the right concept. It seems to me that the client is responsible for informing the server of what the situation is, and the server is responsible for deciding whether to allow the connection. In your scenario, the client is not only communicating information ("here's the password I have got") but also making demands on the server ("DO NOT authenticate using anything else"). I like the first part fine, but not the second part. Consider the scenario where somebody wants to allow a connection that is proxied and does not require a password. For example, maybe I have a group of three machines that all mutually trust each other and the network is locked down so that we need not worry about IP spoofing or whatever. Just be doubly sure, they all have SSL certificates so that they can verify that an incoming connection is from one of the other trusted machines. I, as the administrator, want to configure things so that each machine will proxy connections to the others as long as local user = remote user. When the remote machine receives the connection, it can trust that the request is legitimate provided that the SSL certificate is successfully verified. The way I think this should work is, first, on each machine, in the proxy configuration, there should be a rule that says "only proxy connections where local user = remote user" (and any other rules I want to enforce). Second, in the HBA configuration, there should be a rule that says "if somebody is trying to proxy a connection, it has to be for one of these IPs and they have to authenticate using an SSL certificate". In this kind of scenario, the client has no business demanding that the server authenticate using the password rather than anything else. The server, not the client, is in charge of deciding which connections to accept; the client's job is only to decide which connections to proxy. And the human being is responsible for making sure that the combination of those two things implements the intended security policy. > Agreed. The danger from my end is, I'm trained on configuration > formats that have infinite bells and whistles. I don't really want to > go too crazy with it. Yeah. If I remember my math well enough, the time required to implement infinite bells and whistles will also be infinite, and as a wise man once said, real artists ship. It does seem like a good idea, if we can, to make the configuration file format flexible enough that we can easily extend it with more bells and whistles later if we so choose. But realistically most people are going to have very simple configurations. > > and that maybe > > has something in common with our existing configuration file syntaxes. > > But if we have to invent something new, then we can do that. > > Okay. Personally I'd like > - the ability to set options globally (so filters are optional) > - the ability to maintain many options for a specific scope (host? IP > range?) without making my config lines grow without bound > - the ability to audit a configuration without trusting its comments > > But getting all of my wishlist into a sane configuration format that > handles all the use cases is the tricky part. I'll think about it. Nobody seemed too keen on my proposal of a bunch of tab-separated fields; maybe we're all traumatized from pg_hba.conf and should look for something more complex with a real parser. I thought that tab-separated fields might be good enough and simple to implement, but it doesn't matter how simple it is to implement if nobody likes it. We could do something that looks more like a series of if-then rules, e.g. target-host 127.0.0.0/8 => reject authentication-method scram => accept reject But it's only a hop, skip and a jump from there to something that looks an awful lot like a full-blown programing language, and maybe that's even the right idea, but, oh, the bike-shedding! Cue someone to suggest that it's about time we embed a Lua interpreter. -- Robert Haas EDB: http://www.enterprisedb.com