-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Column privileges for different database users?
PostPosted: Mon Dec 14, 2009 1:11 am 
Beginner
Beginner

Joined: Mon Dec 14, 2009 12:26 am
Posts: 23
Hi

I have a PostgreSQL 8.4 database that makes heavy use of column privileges to limit what columns particular user roles may modify. Column access control enforcement is done using different user logins at the database level, via groups (roles in Pg speak) assigned different column privileges.

I'm building a J2SE app that uses Hibernate (3.5 via JPA2 and Annotations-style mapping) as its DB access layer, and having excellent results with it in general. A JPA2 Persistence Unit is created with the username and password the user supplies when they log in to the app, so all database work is done as that user. Database-level and table-level privileges are generally entirely fuss free, and Hibernate doesn't even need to care about them. Ditto tables where column privileges prohibit any user from setting explicit values on insert or update - Hibernate works fine with a table where all users have the same rights, as columns may be mapped as updatable= and insertable= as appropriate.

The problem is with tables where different users have different column privileges. There doesn't seem to be any way to set insertable= or updatable= on a column dynamically based on the privileges of the current database user, so I have issues with tables where different users have different column permissions. If I map a column as updatable=true and some users don't have the appropriate rights then Hibernate-generated UPDATEs may fail even if that particular column's value hasn't been changed, just because the column is in the UPDATE's column list. Ditto for INSERTs. If I map it as updatable=false, there's no way to use Hibernate to update the column even if the current user has the appropriate rights.

I can always map such columns as updatable=false / insertable=false as appropriate and fall back to JDBC to change them where necessary, but that's _ugly_ and makes the use of Hibernate much less beneficial. The alternative is modifying the DB to rip out most of the column privilege use and replace it with reams of error-prone hand-coded trigger cruft to do the same checks more slowly and less safely, which I don't find attractive. That might also confuse existing apps that expect permission errors not some random trigger failure if the user doesn't have required rights to do something.

Does anybody have any experience with issues like this - with PostgreSQL or another database?

Is there any way to dynamically alter the `insertable=' and `updatable=' values in a mapping for a given PU instance? Or otherwise achieve the same ends?


Top
 Profile  
 
 Post subject: Re: Column privileges for different database users?
PostPosted: Tue Jan 05, 2010 10:06 pm 
Beginner
Beginner

Joined: Mon Dec 14, 2009 12:26 am
Posts: 23
See follow-on: https://forum.hibernate.org/viewtopic.php?f=1&t=1001854&p=2423111#p2423111


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.