Re: Restrict user to create only one db with a specific name

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: Restrict user to create only one db with a specific name
Дата
Msg-id CAKFQuwb4yvm0LvEh=eAgF-gARucRC16fo9vPdDx0E9AbL=U1gA@mail.gmail.com
обсуждение исходный текст
Ответ на Restrict user to create only one db with a specific name  (Tiffany Thang <tiffanythang@gmail.com>)
Ответы Re: Restrict user to create only one db with a specific name
Re: Restrict user to create only one db with a specific name
Список pgsql-general
On Fri, Mar 6, 2020 at 4:28 PM Tiffany Thang <tiffanythang@gmail.com> wrote:
Hi,
Is there a way in PostgreSQL 12 to restrict user to creating a database with a specific database name?

For example, userA can only create a database with a name called mydb. Any other names would generate an error. 

If that is not possible, will it be possible then to limit userA to creating only one database? Granting the createdb privilege would allow the user to create any  number of databases which I want to avoid.

No.  Though you could prevent them from being able to connect to unexpected databases via the pg_hba.conf file.

Why does userA need create database privileges?

You could just have them log into an admin database and run a function that creates the database for them using function owner privileges then you can add whatever special logic you want to that function.

David J.

В списке pgsql-general по дате отправления:

Предыдущее
От: Tiffany Thang
Дата:
Сообщение: Restrict user to create only one db with a specific name
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: Restrict user to create only one db with a specific name