PHP Web Database Auditing, Authorization and Monitoring

Oracle Database "client identifiers" are cool because they let Oracle Database trace and monitor DB resource usage for individual web users, not just for the username that connected to the DB. You know how your web app files all connect using the same DB username like $c = oci_connect('phpuser', 'secret', 'mydb'), and so as a consequence how all your DB monitoring scripts show PHPUSER as the main (or only) resource consumer? Well by adding a simple oci_set_client_identifier($c, 'chris') call to your PHP files you can get a DB audit trail of the operations that 'chris' does, and can do real-time monitoring of the statements executed and see what his DB personal resource usage is. This can be used to track data access and highlight suspicious activity. It can identify heavy consumers or pinpoint the cause of a runaway situation. It could also be used during development to isolate the impact of a particular set of code changes from the load that other developers are putting on the dev database.

Client identifiers can also be used to automatically restrict data access. How? You create a PL/SQL function that simply returns the text string of WHERE clause and tell Oracle to automatically apply that clause whenever a particular table is accessed. The function logic and/or returned string can reference the client id. Just like a normal WHERE clause, if the clause returns true for a particular row, then the user sees that data, otherwise not. The application doesn't need any changes or recoding - the clause is automatically and consistently applied by Oracle.

There is a lot more detail on the topic in a brand new OTN article at PHP Web Auditing, Authorization and Monitoring with Oracle Database.

Thanks to everyone who reviewed and gave technical input to the article. It is much better as a result.

Comments:

Post a Comment:
Comments are closed for this entry.
About

Tourists looking out over an Opal mine
I'm a Product Manager in Server Technologies, working on scripting languages and developer-access.
Email: christopher.jones@oracle.com
Twitter: http://twitter.com/ghrd
Book: Free PHP Oracle book
Download: PHP Linux RPMs with the OCI8 extension
Links: OTN PHP Developer Center

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today