how to restrict a user from accessing a specific database?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • osman7king
    New Member
    • Sep 2010
    • 61

    how to restrict a user from accessing a specific database?

    when I create a user "user1" and give this user the permissions on a database "db1" (including login privilage), this user can access all databases although it doesn't have the privilges (even after implmenting the revoke command).
    on the other hand, any user can access the database "db1"
    after login, although I make (revoke all on database db1 from public ).

    I need to restrict role "user1" to access only db1 and db2's sch_a and shc_f, and also don't show the other schemas in the same database. When listing databases, just two schemas should be shown (sch_a , sch_f).
  • Mariostg
    Contributor
    • Sep 2010
    • 332

    #2
    It could be a problem in your pg_hba.conf file
    http://developer.postgresql.org/pgdo...-hba-conf.html. See the database paragraph.

    Comment

    • rski
      Recognized Expert Contributor
      • Dec 2006
      • 700

      #3
      For database you can use
      Code:
      revoke connect on <database> from <username>;
      revoke connect on <database> from public;
      for schemas revoke USAGE and CREATE privilege.

      See here http://www.postgresql.org/docs/curre...ql-revoke.html

      Comment

      Working...