pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedApproach to creating users in Database
2+ messages / 2 participants
[nested] [flat]
* Approach to creating users in Database
@ 2021-04-27 10:32 Sanjay Minni <sanjay.minni@gmail.com>
0 siblings, 1 reply; 2+ messages in thread
From: Sanjay Minni @ 2021-04-27 10:32 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
Hi,
what is the usual approach in creating users / role in a postgresql
database serving as the data repository to a hosted multi-tenanted
application with a large number of users.
the 2 approaches I can think of is
A. The user stays and is controlled only in the application level, the
application in turn connects with the postgresql database as a single user
name. Any userid to be stored as part of the data is injected by the
application
B. Each user is also created in the postgresql database with grant or
required rights to the tables.
what is the usual practice ?
I am unable to see any benefit in (B) above - i.e. recreating each user in
the postgres database
So what am i missing. A change in approach later can mean a huge rework
later
with warm regards
Sanjay Minni
+91-9900-902902
http://planage.com
https://www.linkedin.com/in/sanjayminni/
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Approach to creating users in Database
@ 2021-04-27 16:05 Stephen Frost <sfrost@snowman.net>
parent: Sanjay Minni <sanjay.minni@gmail.com>
0 siblings, 0 replies; 2+ messages in thread
From: Stephen Frost @ 2021-04-27 16:05 UTC (permalink / raw)
To: Sanjay Minni <sanjay.minni@gmail.com>; +Cc: pgsql-general@lists.postgresql.org
Greetings,
* Sanjay Minni (sanjay.minni@gmail.com) wrote:
> what is the usual approach in creating users / role in a postgresql
> database serving as the data repository to a hosted multi-tenanted
> application with a large number of users.
>
> the 2 approaches I can think of is
> A. The user stays and is controlled only in the application level, the
> application in turn connects with the postgresql database as a single user
> name. Any userid to be stored as part of the data is injected by the
> application
> B. Each user is also created in the postgresql database with grant or
> required rights to the tables.
>
> what is the usual practice ?
> I am unable to see any benefit in (B) above - i.e. recreating each user in
> the postgres database
Both approaches are used pretty commonly. The advantages of B include:
- The permissions can be managed using GRANT/REVOKE at the database
level and you remove the risk, for the most part, of things like SQL
injection attacks because the user you're connected to the database as
has only the rights that they should have, unlike in approach A where
the user connected to the database has rights to basically everything.
- Auditing is able to be done of who did what using the database rather
than having to trust to application logs and auditing.
There's other up-sides and down-sides, of course.
Thanks,
Stephen
Attachments:
signature.asc (application/pgp-signature, 818B) download
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2021-04-27 16:05 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-04-27 10:32 Approach to creating users in Database Sanjay Minni <sanjay.minni@gmail.com>
2021-04-27 16:05 ` Stephen Frost <sfrost@snowman.net>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox