diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2018-12-28 14:52:38 -0800 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2018-12-28 15:45:10 -0800 |
commit | f9408344464285870409c2209a8edc8d25fd9bfa (patch) | |
tree | 386e2472c22e9c79f8a58e2f419c9fbaef00dd13 /rust/src/api_wrappers.rs | |
parent | fa1892834a4650bf2e85215a3270e309d3e9f1c9 (diff) | |
download | fatcat-f9408344464285870409c2209a8edc8d25fd9bfa.tar.gz fatcat-f9408344464285870409c2209a8edc8d25fd9bfa.zip |
start refactor of auth code
Pulls auth code (which requires the persistent state of a signing
keyring) into a struct.
Doesn't try verify macaroon in middleware, do it in individual wrappers.
Diffstat (limited to 'rust/src/api_wrappers.rs')
-rw-r--r-- | rust/src/api_wrappers.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/rust/src/api_wrappers.rs b/rust/src/api_wrappers.rs index cf696d15..25b4fab1 100644 --- a/rust/src/api_wrappers.rs +++ b/rust/src/api_wrappers.rs @@ -2,6 +2,7 @@ use api_entity_crud::EntityCrud; use api_helpers::*; +use auth::*; use api_server::Server; use database_models::EntityEditRow; use diesel::Connection; @@ -80,10 +81,12 @@ macro_rules! wrap_entity_handlers { &self, entity: models::$model, editgroup_id: Option<String>, - _context: &Context, + context: &Context, ) -> Box<Future<Item = $post_resp, Error = ApiError> + Send> { let conn = self.db_pool.get().expect("db_pool error"); let ret = match conn.transaction(|| { + let auth_context = self.auth_confectionary.parse_swagger(&conn, &context.auth_data)?; + // XXX: auth_context.expect("not authorized"); let editgroup_id = if let Some(s) = editgroup_id { Some(FatCatId::from_str(&s)?) } else { None }; |