Skip to content
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

Support authorizer to check allowed statements #59

Open
clue opened this issue Jan 18, 2022 · 0 comments
Open

Support authorizer to check allowed statements #59

clue opened this issue Jan 18, 2022 · 0 comments
Labels
help wanted Extra attention is needed new feature New feature or request

Comments

@clue
Copy link
Owner

clue commented Jan 18, 2022

function myguard(int $action, ...$args)
{
    if ($action === SQLite3::READ) {
        list($table, $column) = $args;

        if ($table === 'users') {
            return SQLite3::OK;
        }

        return SQLite3::IGNORE;
    }

    return SQLite3::DENY;
}


$db = new Clue\React\Sqlite\SqliteClient(':memory:');

$db->on('open', function () use ($db) {
    $db->setAuthorizer('myguard');
});

$db->query('SELECT * FROM users')->then('var_dump');

See https://www.php.net/manual/en/sqlite3.setauthorizer.php (PHP 8+) and http://sqlite.org/c3ref/set_authorizer.html
Refs #47, #54, #58

@clue clue added new feature New feature or request help wanted Extra attention is needed labels Jan 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed new feature New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant