Re: Allow +group in pg_ident.conf

Поиск
Список
Период
Сортировка
Искать
От
Michael Paquier
Тема
Re: Allow +group in pg_ident.conf
Дата
Msg-id
Y7y8BVRHFvXXKJEJ@paquier.xyz
Ответ на
Список
Дерево обсуждения
Allow +group in pg_ident.conf Andrew Dunstan <andrew@dunslane.net>
Re: Allow +group in pg_ident.conf Nathan Bossart <nathandbossart@gmail.com>
Re: Allow +group in pg_ident.conf Andrew Dunstan <andrew@dunslane.net>
Re: Allow +group in pg_ident.conf Jelte Fennema <me@jeltef.nl>
Re: Allow +group in pg_ident.conf Jelte Fennema <me@jeltef.nl>
Re: Allow +group in pg_ident.conf Andrew Dunstan <andrew@dunslane.net>
Re: Allow +group in pg_ident.conf Michael Paquier <michael@paquier.xyz>
Re: Allow +group in pg_ident.conf Jelte Fennema <me@jeltef.nl>
Re: Allow +group in pg_ident.conf "Gregory Stark (as CFM)" <stark.cfm@gmail.com>
Re: Allow +group in pg_ident.conf Michael Paquier <michael@paquier.xyz>
Re: Allow +group in pg_ident.conf Michael Paquier <michael@paquier.xyz>
On Mon, Jan 09, 2023 at 05:33:14PM -0500, Andrew Dunstan wrote:
> I've adapted a sentence from the pg_hba.conf documentation so we stay
> consistent.

+  
+   If the database-username begins with a
+   + character, then the operating system user can login as
+   any user belonging to that role, similarly to how user names beginning with
+   + are treated in pg_hba.conf.
+   Thus, a + mark means match any of the roles that
+   are directly or indirectly members of this role, while a name
+   without a + mark matches only that specific role.
+  

Should this also mention that the behavior is enforced even in cases
where we expect a case-sensitive match?

> It's not really relevant. We're not comparing role names here; rather we
> look up two roles and then ask if one is a member of the other. I've
> added a comment.
> 
> Thanks for the review (I take it you're generally in favor).

-       if (case_insensitive)
+       if (regexp_pgrole[0] == '+')
+       {
+           /*
+            * Since we're not comparing role names here, use of case
+            * insensitive matching doesn't really apply.
+            */
+           Oid roleid = get_role_oid(pg_role, true);
+           Assert(false);
+           if (is_member(roleid, regexp_pgrole +1))
+               *found_p = true;
+       }
+       else if (case_insensitive)

Hmm.  As check_ident_usermap() is now coded, it means that the case of
a syntax substitution could be enforced to use a group with the user
name given by the client.  For example, take this ident entry:
mymap   /^(.*)@mydomain\.com$      \1

Then, if we attempt to access Postgres with "+testrole@mydomain.com",
we would get a substitution to "+testrole", which would be enforced to
check on is_member() with this expected role name.  I am not sure what
should be the correct behavior here.
--
Michael
В списке pgsql-hackers по дате отправления
От: Andres Freund
Дата:
От: Andres Freund
Дата:
FAQ