on 2012 Feb 17 4:58 PM
What's the best way to implement a row-level security type of setup for an already existing structure in SQL Anywhere 12+ ?
We would have 2 use cases for such a setup:
1) Customer A wants to let their Client X into the database to run generic reports but only be able to see the information that matches up to Client X, not any other data for other clients.
2) Customer B wants to segregate within their own organization that if you are responsible for a client's records you can change/update them, but you cannot change/update them for clients assigned to others.
Request clarification before answering.
Views are the traditional solution to providing secure selection criteria:
the end user can't SELECT on the base table, only the view,
the view FROM WHERE clause joins the base table to a user security table, and
the user security table provides the WHERE lookup value(s) required to identify visible base table rows.
PERFORMANCE ALERT: Some shops go crazy with security views; every base table is accessible only through a view which joins the table to a multi-layer (multi-table) security schema, so that a query involving ten base tables suddenly has a join involving twenty, thirty, forty or more tables.
I feel a blog coming on... 🙂
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I surely agree on the need to use a WHERE EXISTS part for updatable views - but IMHO this usually leads to a clear way to define them, so that need not be a disadvantage by itself.
For performance reason, it would be nice to know whether the usual "subquery flattening" (i.e. turning them into joins) would be done here by the query optimizer, too, or whether the "updatable" property will prevent such optimizations - Glenn, what do you say?
FWIW, here's the blog article Breck has announced:)
As to Breck's suggestion with views and a security table:
The following answer contains some detailed samples.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
close access to all critical tables all insert/update/delete made only via special stored procedure, where you realize security checks. for reporting purposes try to use views or stored procedures that realize security filters within.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I use in some views the SysGroups View to limit the rows.
WHERE "TABLE"."GROUP_NAME" in ( select SG.group_name from sys.sysgroups as SG where SG.group_name like '<GroupSelectionCriteria>' and SG.member_name = current user )
Due to the in clause the user can see rows from all groups he is a member.
Only to give a additional idea.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
33 | |
21 | |
16 | |
8 | |
7 | |
6 | |
5 | |
4 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.