Merge pull request #975 from gwenn/authorizer

Fix AuthContext / Authorization visibility
This commit is contained in:
gwenn 2021-06-14 19:54:22 +02:00 committed by GitHub
commit 781d5b9fdd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 9 deletions

View File

@ -42,14 +42,14 @@ impl From<i32> for Action {
/// See <https://sqlite.org/c3ref/set_authorizer.html> for more info.
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct AuthContext<'c> {
// The action to be authorized.
/// The action to be authorized.
pub action: AuthAction<'c>,
/// The database name, if applicable.
pub database_name: Option<&'c str>,
// The inner-most trigger or view responsible for the access attempt.
// `None` if the access attempt was made by top-level SQL code.
/// The inner-most trigger or view responsible for the access attempt.
/// `None` if the access attempt was made by top-level SQL code.
pub accessor: Option<&'c str>,
}
@ -254,7 +254,7 @@ impl<'c> AuthAction<'c> {
table_name,
column_name,
},
(ffi::SQLITE_SELECT, _, _) => Self::Select,
(ffi::SQLITE_SELECT, ..) => Self::Select,
(ffi::SQLITE_TRANSACTION, Some(operation_str), _) => Self::Transaction {
operation: TransactionOperation::from_str(operation_str),
},
@ -286,7 +286,7 @@ impl<'c> AuthAction<'c> {
savepoint_name,
},
#[cfg(feature = "modern_sqlite")]
(ffi::SQLITE_RECURSIVE, _, _) => Self::Recursive,
(ffi::SQLITE_RECURSIVE, ..) => Self::Recursive,
(code, arg1, arg2) => Self::Unknown { code, arg1, arg2 },
}
}
@ -298,6 +298,7 @@ pub(crate) type BoxedAuthorizer =
/// `feature = "hooks"` A transaction operation.
#[derive(Clone, Copy, Debug, PartialEq)]
#[non_exhaustive]
#[allow(missing_docs)]
pub enum TransactionOperation {
Unknown,
Begin,
@ -316,6 +317,7 @@ impl TransactionOperation {
}
}
/// [`authorizer`](Connection::authorizer) return code
#[derive(Clone, Copy, Debug, PartialEq)]
#[non_exhaustive]
pub enum Authorization {
@ -597,7 +599,7 @@ impl InnerConnection {
};
}
pub fn authorizer<'c, F>(&'c mut self, authorizer: Option<F>)
fn authorizer<'c, F>(&'c mut self, authorizer: Option<F>)
where
F: for<'r> FnMut(AuthContext<'r>) -> Authorization + Send + RefUnwindSafe + 'static,
{

View File

@ -73,8 +73,6 @@ pub use crate::cache::CachedStatement;
pub use crate::column::Column;
pub use crate::error::Error;
pub use crate::ffi::ErrorCode;
#[cfg(feature = "hooks")]
pub use crate::hooks::Action;
#[cfg(feature = "load_extension")]
pub use crate::load_extension_guard::LoadExtensionGuard;
pub use crate::params::{params_from_iter, Params, ParamsFromIter};
@ -102,7 +100,7 @@ mod context;
#[cfg(feature = "functions")]
pub mod functions;
#[cfg(feature = "hooks")]
mod hooks;
pub mod hooks;
mod inner_connection;
#[cfg(feature = "limits")]
pub mod limits;