Skip to content

Add set_authorizer/2 to deny specific SQL operations per connection #344

@WhiskeyTuesday

Description

@WhiskeyTuesday

I need the ability to deny specific SQL operations (particularly ATTACH DATABASE) on a per-connection basis

SQLite provides sqlite3_set_authorizer() for this purpose. Other language bindings already expose it:

For the NIF, a full Erlang callback isn't practical since the authorizer is called synchronously during sqlite3_prepare(). Instead, a deny-list approach works well I think. The caller passes a list of action atoms to block, and a static C callback checks the list. This follows the same pattern as set_update_hook (config stored in the connection struct, C callback registered via SQLite API).

A PR implementing this is incoming, please review it carefully as I'm not the most experienced C dev in the world and would hate to be a cause of someone's SQL injection hack.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions