pub(crate) mod config;
pub(crate) mod identity;
mod layer;
pub mod rebac;
#[cfg(any(feature = "model-sqlite", feature = "model-postgres", feature = "model-mysql"))]
pub mod sql;
pub use identity::{with_identity, Identity};
pub use layer::{AuthzLayer, ObjectTemplate};
#[cfg(any(feature = "model-sqlite", feature = "model-postgres", feature = "model-mysql"))]
pub use sql::SqlStore;
pub use rebac::{AuthzError, Authorizer, MemoryStore, ObjectRef, Schema, Subject, Tuple, TupleFilter, TupleStore};
#[cfg(feature = "http2")]
pub use identity::scope_identity;
#[cfg(test)]
pub(crate) mod test_support {
use crate::application::Application;
use crate::request::Request;
use crate::response::{Response, STATUS_CODE_REASON_PHRASE};
use crate::server::ConnectionInfo;
pub(crate) struct WhoAmI;
impl Application for WhoAmI {
fn execute(&self, _request: &Request, _connection: &ConnectionInfo) -> Result<Response, String> {
let who = super::Identity::current().map_or("anonymous".to_string(), |i| format!("{} via {}", i.subject(), i.source()));
Ok(Response::text(STATUS_CODE_REASON_PHRASE.n200_ok, &who))
}
}
pub(crate) fn body(response: &Response) -> String {
String::from_utf8_lossy(&response.content_range_list.first().map(|c| c.body.clone()).unwrap_or_default()).to_string()
}
}
#[cfg(test)]
mod tests;