Skip to content

Conversation

evrenonur
Copy link

This commit introduces a new method setAuthorizer to the PDO_SQLite extension, allowing users to set a custom authorization callback for SQLite operations. The implementation includes a new structure to handle the callback data and a function to process authorization requests. Additionally, the method can remove the authorizer by passing a NULL callback. This enhancement improves the flexibility and security of database interactions.

Fixes: #17321

$pdo = new PDO('sqlite:/path/to/database.sqlite');
$sqlite = $pdo->sqlite;

// Set an authorizer callback
$sqlite->setAuthorizer(function(int $actionCode, string $param1, string $param2, string $param3) {
    // $actionCode: SQLITE_CREATE_INDEX, SQLITE_CREATE_TABLE, etc.
    // $param1, $param2, $param3: Parameters specific to the action
    
    // Allow the action
    return true; // SQLITE_OK
    
    // Deny the action
    return false; // SQLITE_DENY
});

// Remove the authorizer
$sqlite->setAuthorizer(null);

…lbacks

This commit introduces a new method `setAuthorizer` to the PDO_SQLite extension, allowing users to set a custom authorization callback for SQLite operations. The implementation includes a new structure to handle the callback data and a function to process authorization requests. Additionally, the method can remove the authorizer by passing a NULL callback. This enhancement improves the flexibility and security of database interactions.
@evrenonur evrenonur closed this Jan 3, 2025
@evrenonur evrenonur deleted the fix#17321 branch January 3, 2025 10:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add setAuthorizer to Pdo\Sqlite

1 participant