pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Restrict connection from pgadmin.
8+ messages / 6 participants
[nested] [flat]

* Restrict connection from pgadmin.
@ 2020-02-03 06:47  Pawan Sharma <pawanpg0963@gmail.com>
  0 siblings, 2 replies; 8+ messages in thread

From: Pawan Sharma @ 2020-02-03 06:47 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

Hi All,

Is there any way to restrict the connection only from pgadmin???  The same
user can connect through application but can't from pgadmin.. Or any logon
triggers..???

^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Restrict connection from pgadmin.
@ 2020-02-03 17:03  Adrian Klaver <adrian.klaver@aklaver.com>
  parent: Pawan Sharma <pawanpg0963@gmail.com>
  1 sibling, 1 reply; 8+ messages in thread

From: Adrian Klaver @ 2020-02-03 17:03 UTC (permalink / raw)
  To: Pawan Sharma <pawanpg0963@gmail.com>; pgsql-general@lists.postgresql.org

On 2/2/20 10:47 PM, Pawan Sharma wrote:
> Hi All,
> 
> Is there any way to restrict the connection only from pgadmin???  The 
> same user can connect through application but can't from pgadmin.. Or 
> any logon triggers..???
> 

Not that I know of. pgAdmin is just another client so you just have the 
methods available here:

https://www.postgresql.org/docs/12/auth-pg-hba-conf.html

-- 
Adrian Klaver
adrian.klaver@aklaver.com





^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Restrict connection from pgadmin.
@ 2020-02-03 17:13  David G. Johnston <david.g.johnston@gmail.com>
  parent: Pawan Sharma <pawanpg0963@gmail.com>
  1 sibling, 0 replies; 8+ messages in thread

From: David G. Johnston @ 2020-02-03 17:13 UTC (permalink / raw)
  To: Pawan Sharma <pawanpg0963@gmail.com>; +Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>

On Sun, Feb 2, 2020 at 11:48 PM Pawan Sharma <pawanpg0963@gmail.com> wrote:

> Hi All,
>
> Is there any way to restrict the connection only from pgadmin???  The same
> user can connect through application but can't from pgadmin.. Or any logon
> triggers..???
>

Why just pgAdmin?  Why not psql?  How do you expect to know the difference?
Its all the same protocol going back-and-forth no matter what kind of user
interface you provide to the user.

You can make it difficult for the user to gain direct access from their
machine while allowing a local application to do so, but I'm doubtful it
can be made hacker-proof.  Specifically the user can be assumed to be
allowed to attempt a connection but if they lack valid credentials they
will be unable to get in.  If you need connection-level security you want
to host the application on a separate machine that does have access to
PostgreSQL and only provide user interface access to the application to the
user.  As they are never truly on the machine that has access to the
database they will be unable to establish their own connection.

You can log and monitor logon attempts but there is no server level
triggers.  Again, the client sends along all of the validation information
and so can make up values for any parameters you might wish to check so
that they look like, i.e., your application as far as the authentication
code is concerned.

David J.

^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Restrict connection from pgadmin.
@ 2020-02-03 17:15  Ravi Krishna <ravikrishna@vivaldi.net>
  parent: Adrian Klaver <adrian.klaver@aklaver.com>
  0 siblings, 1 reply; 8+ messages in thread

From: Ravi Krishna @ 2020-02-03 17:15 UTC (permalink / raw)
  To: Adrian Klaver <adrian.klaver@aklaver.com>; +Cc: Pawan Sharma <pawanpg0963@gmail.com>; pgsql-general@lists.postgresql.org

> 
> Not that I know of. pgAdmin is just another client so you just have the methods available here:
> 
> https://www.postgresql.org/docs/12/auth-pg-hba-conf.html
> 

will the col application_name from pg_stat_activity list pgadmin as pgadmin. if yes, then the closest one can achieve
is to have a daemon process wake up every 1 min or so and terminate any pgadmin app.







^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Restrict connection from pgadmin.
@ 2020-02-03 17:43  Adrian Klaver <adrian.klaver@aklaver.com>
  parent: Ravi Krishna <ravikrishna@vivaldi.net>
  0 siblings, 1 reply; 8+ messages in thread

From: Adrian Klaver @ 2020-02-03 17:43 UTC (permalink / raw)
  To: Ravi Krishna <ravikrishna@vivaldi.net>; +Cc: Pawan Sharma <pawanpg0963@gmail.com>; pgsql-general@lists.postgresql.org

On 2/3/20 9:15 AM, Ravi Krishna wrote:
>>
>> Not that I know of. pgAdmin is just another client so you just have the methods available here:
>>
>> https://www.postgresql.org/docs/12/auth-pg-hba-conf.html
>>
> 
> will the col application_name from pg_stat_activity list pgadmin as pgadmin. if yes, then the closest one can achieve

Make a connection from pgAdmin and see.

> is to have a daemon process wake up every 1 min or so and terminate any pgadmin app.

I can do a lot of damage in a minute.




-- 
Adrian Klaver
adrian.klaver@aklaver.com





^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Restrict connection from pgadmin.
@ 2020-02-04 05:55  Pawan Sharma <pawanpg0963@gmail.com>
  parent: Adrian Klaver <adrian.klaver@aklaver.com>
  0 siblings, 1 reply; 8+ messages in thread

From: Pawan Sharma @ 2020-02-04 05:55 UTC (permalink / raw)
  To: Adrian Klaver <adrian.klaver@aklaver.com>; +Cc: Ravi Krishna <ravikrishna@vivaldi.net>; pgsql-general@lists.postgresql.org

Yes I will show the pgadmin in stat_activity but how  can block that..

I think I need to create a job to terminate the pgadmin connections and
schedule it for  every 5 min and so that I will check any new connections
from pgadmin.

On Mon, 3 Feb 2020, 11:13 pm Adrian Klaver, <adrian.klaver@aklaver.com>
wrote:

> On 2/3/20 9:15 AM, Ravi Krishna wrote:
> >>
> >> Not that I know of. pgAdmin is just another client so you just have the
> methods available here:
> >>
> >> https://www.postgresql.org/docs/12/auth-pg-hba-conf.html
> >>
> >
> > will the col application_name from pg_stat_activity list pgadmin as
> pgadmin. if yes, then the closest one can achieve
>
> Make a connection from pgAdmin and see.
>
> > is to have a daemon process wake up every 1 min or so and terminate any
> pgadmin app.
>
> I can do a lot of damage in a minute.
>
>
>
>
> --
> Adrian Klaver
> adrian.klaver@aklaver.com
>

^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Restrict connection from pgadmin.
@ 2020-02-04 06:07  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Pawan Sharma <pawanpg0963@gmail.com>
  0 siblings, 1 reply; 8+ messages in thread

From: Tom Lane @ 2020-02-04 06:07 UTC (permalink / raw)
  To: Pawan Sharma <pawanpg0963@gmail.com>; +Cc: Adrian Klaver <adrian.klaver@aklaver.com>; Ravi Krishna <ravikrishna@vivaldi.net>; pgsql-general@lists.postgresql.org

Pawan Sharma <pawanpg0963@gmail.com> writes:
> Yes I will show the pgadmin in stat_activity but how  can block that..
> I think I need to create a job to terminate the pgadmin connections and
> schedule it for  every 5 min and so that I will check any new connections
> from pgadmin.

I think onlookers are still completely mystified as to why you consider
this a useful activity.

pgadmin is nothing but a GUI.  Whatever can be done through it can be
done equally well through psql, or any other client software.  So if
you're looking for security against unwanted SQL commands, you're going
about it the wrong way (better to look at preventing logins of privileged
accounts, and/or use of SQL permissions to limit what can be done).
If your objective is something else, you haven't explained what that is.

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Restrict connection from pgadmin.
@ 2020-02-04 22:12  raf <raf@raf.org>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 8+ messages in thread

From: raf @ 2020-02-04 22:12 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

Tom Lane wrote:

> Pawan Sharma <pawanpg0963@gmail.com> writes:
> > Yes I will show the pgadmin in stat_activity but how  can block that..
> > I think I need to create a job to terminate the pgadmin connections and
> > schedule it for  every 5 min and so that I will check any new connections
> > from pgadmin.
> 
> I think onlookers are still completely mystified as to why you consider
> this a useful activity.
> 
> pgadmin is nothing but a GUI.  Whatever can be done through it can be
> done equally well through psql, or any other client software.  So if
> you're looking for security against unwanted SQL commands, you're going
> about it the wrong way (better to look at preventing logins of privileged
> accounts, and/or use of SQL permissions to limit what can be done).
> If your objective is something else, you haven't explained what that is.
> 
> 			regards, tom lane

You could give normal/application users/roles very
limited permissions (i.e. just the ability to execute
pre-existing security-defining functions and nothing
else), and have a database owner user/role with all the
permissions to create those functions. That's my insane
setup and I love it. Then use pg_hba.conf to limit
which IP addresses the database owner user/role can log
in from. You could also uninstall pg_admin. :-)

Also, if you are worried about "doing a lot of damage
in a minute", always script everything and test it
first either in a transaction that will rollback or on
a test server before executing it in production. I
don't think a GUI is suitable for this.

cheers,
raf






^ permalink  raw  reply  [nested|flat] 8+ messages in thread


end of thread, other threads:[~2020-02-04 22:12 UTC | newest]

Thread overview: 8+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-02-03 06:47 Restrict connection from pgadmin. Pawan Sharma <pawanpg0963@gmail.com>
2020-02-03 17:03 ` Adrian Klaver <adrian.klaver@aklaver.com>
2020-02-03 17:15   ` Ravi Krishna <ravikrishna@vivaldi.net>
2020-02-03 17:43     ` Adrian Klaver <adrian.klaver@aklaver.com>
2020-02-04 05:55       ` Pawan Sharma <pawanpg0963@gmail.com>
2020-02-04 06:07         ` Tom Lane <tgl@sss.pgh.pa.us>
2020-02-04 22:12           ` raf <raf@raf.org>
2020-02-03 17:13 ` David G. Johnston <david.g.johnston@gmail.com>

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