-
Notifications
You must be signed in to change notification settings - Fork 7.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add setAuthorizer method to SQLite3 (implement userland authorizer) #4797
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! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @bohwaz! LGTM now.
If there are no objections, I'll merge this in a week.
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
setAuthorizer
method.This patch is also available against the PHP 7.4 branch, if needed.