Add setAuthorizer method to SQLite3 (implement userland authorizer)#4797
Add setAuthorizer method to SQLite3 (implement userland authorizer)#4797bohwaz wants to merge 3 commits into
Conversation
7fb63b7 to
3991d9e
Compare
|
Seems that I have a memory leak somewhere, will try to understand where it comes from on tomorrow. |
… userland callback that will be used to authorize or not an action on the database
3991d9e to
51b524b
Compare
|
OK I checked and added some stuff, but I can't find where the leak is coming from :( anyone can help me? |
|
Thanks for the PR! Looks like very useful functionality; I'll try to find some time for a thorough review. :) Regarding the memory leak: it seems to me that you have to release |
Ah yes of course, I didn't think about that, I was sure it was coming from something I missed in using the params inside the fci! Thanks! |
cmb69
left a comment
There was a problem hiding this comment.
Thanks a lot! I'm generally fine with this, but I think some minor issues should be addressed (see below).
|
Thanks for the review @cmb69 all very good and valid points, I'll fix that ASAP :) |
|
@cmb69 everything should be fixed, thank you. |
Adds the possibility to define a userland callback that will be used to authorize or not an action on the database.
This allows to effectively implement access restrictions to a SQLite database.
See https://www.sqlite.org/c3ref/set_authorizer.html for details and https://www.sqlite.org/c3ref/c_alter_table.html for action codes and parameters passed to the callback.
The callback will receive 1 to 5 parameters:
The callback must return either SQLite3::OK, SQLite3::IGNORE or SQLite3::DENY. Anything else will trigger an error and will be treated as DENY.
It is possible to disable a previously-set authorizer by passing NULL to the
setAuthorizermethod.This patch is also available against the PHP 7.4 branch, if needed.