feat: adds base mod suport, including jot mod activity command #125
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/mod"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Adds mod support.
Ref #112
jot mod activitycommandcargo checkfor mod feature@ -738,0 +803,4 @@signature: &str,) -> Result<AuditLog, JotApiError> {let uri = self.base_url.pathjoin("mod/activity");let since_unix: u32 = match since.duration_since(UNIX_EPOCH) {maybe combine this logic into a func since it's used in multiple places
@ -738,0 +822,4 @@query.push(("mod_short_id", mod_short_id));query.push(("since", since_unix.to_string()));if let Some(kid) = short_id_filter {kid?
@ -738,0 +834,4 @@.header(AUTHORIZATION, format!("basic {}", signature)).send(){Ok(resp) => {Can we somehow reuse this whole match body with other API funcs?
@ -43,3 +43,3 @@pub log_level: Level,/// The key's content to serve at the server root/// The key's to grant admin rights, and to serve its content at the server*key
@ -81,0 +96,4 @@.collect::<Vec<String>>();for act in actions {acts.push_bind(act);}*/cleanup
@ -0,0 +18,4 @@context.req.query::<String>("mod_short_id").ok_or_else(|| {warn!("Unauthorized: mod_short_id");ResponseError::Unauthorized})?;Does this make more sense if we use the nonce from the slip? It's already give to the user, and doesn't have a chance to cause a collision.
@ -735,0 +508,4 @@warn!(status_code = resp.status().to_string(),"Unhandled status");redundant warning, when the error is output to the user anyway
@ -735,0 +523,4 @@limit: u32,since: &Timestamp,short_id_filter: &Option<String>,mod_short_id: String,mod_short_idis no longer used by the server@ -735,0 +533,4 @@let mut query = Vec::new();query.push(("limit", limit.to_string()));query.push(("mod_short_id", mod_short_id));query.push(("since", since_unix.to_string()));vec![("limit", limit.to_string()), ("mod_short_id", mod_short_id), ("since", since_unix.to_string()]@ -44,1 +47,3 @@let slip = match client.admin_auth_audit_log() {let slip = match client.slip_auth(&key.keyid(),Authorization::LIST,This should fail? The op is clearly not audit log cleaning related.
@ -0,0 +46,4 @@error!(error = err, "Failed to open keyfile");out::exit("Unable to open keyfile", 1);}};maybe do
map_errfor these?@ -0,0 +117,4 @@}// make sure the key isn't expiredif key_meta.config.expire > 0confirm that expire == 0 is unlimited
Confirmed. The std
Defaulttrait implements this to be0for uints.@ -0,0 +19,4 @@let short_id_filter = context.req.query::<String>("short_id");let key_meta = slip_auth::authorize(context, Authorization::MOD).await?;if !context.is_mod(&key_meta.key_id) {this check is redundant now?
@ -0,0 +28,4 @@Some(sss) => UNIX_EPOCH + Duration::from_secs(sss.into()),None => SystemTime::now() - Duration::from_hours(24),};let action_filters = vec![add a note saying these are the actions the mods are allowed to see
@ -0,0 +51,4 @@.audit_log_insert(key_meta.key_id.to_short_hexstring(),request_address(&context),AuditAction::AuditLogList,consider if this should be a mod action, even though it's effectively the same thing
@ -0,0 +1,33 @@use std::collections::HashMap;I believe this file is now garbage. Look for other orphans from auth.
@ -102,0 +135,4 @@ResponseError::Forbidden}AuthError::Unexpected(msg) => {error!(msg = msg, "Unexpected slip auth failure");"Unexpected auth failure"
@ -138,9 +142,45 @@ pub enum Authorization {pub struct Slip {pub nonce: String,pub op: Authorization,pub params: HashMap<String, String>,Use
AuthParams@ -144,0 +166,4 @@}}impl Hash for AuthorizationRequest {Didn't end up using hashing here. Delete?
@ -168,6 +214,7 @@ pub struct AllowDenyList {pub root_key: Option<String>,pub allow: HashSet<String>,pub deny: HashSet<String>,pub moderator: HashSet<String>,mods?mod_short_idis no longer used 382e957c2f