summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--rust/src/api_wrappers.rs11
-rw-r--r--rust/src/auth.rs46
-rw-r--r--rust/tests/test_auth.rs3
3 files changed, 33 insertions, 27 deletions
diff --git a/rust/src/api_wrappers.rs b/rust/src/api_wrappers.rs
index 22b5f857..f03d4041 100644
--- a/rust/src/api_wrappers.rs
+++ b/rust/src/api_wrappers.rs
@@ -1256,7 +1256,8 @@ impl Api for Server {
Ok(())
}) {
Ok(()) => AuthCheckResponse::Success(Success {
- message: "auth check successful!".to_string() }),
+ message: "auth check successful!".to_string(),
+ }),
Err(Error(ErrorKind::Diesel(e), _)) => AuthCheckResponse::BadRequest(ErrorResponse {
message: e.to_string(),
}),
@@ -1269,23 +1270,23 @@ impl Api for Server {
AuthCheckResponse::Forbidden(ErrorResponse {
message: e.to_string(),
})
- },
+ }
Err(Error(ErrorKind::InsufficientPrivileges(e), _)) => {
AuthCheckResponse::Forbidden(ErrorResponse {
message: e.to_string(),
})
- },
+ }
Err(Error(ErrorKind::OtherBadRequest(e), _)) => {
AuthCheckResponse::BadRequest(ErrorResponse {
message: e.to_string(),
})
- },
+ }
Err(e) => {
error!("{}", e);
AuthCheckResponse::GenericError(ErrorResponse {
message: e.to_string(),
})
- },
+ }
};
Box::new(futures::done(Ok(ret)))
}
diff --git a/rust/src/auth.rs b/rust/src/auth.rs
index acee147e..d4e03ecf 100644
--- a/rust/src/auth.rs
+++ b/rust/src/auth.rs
@@ -243,20 +243,22 @@ impl AuthConfectionary {
Ok(m) => m,
Err(e) => {
// TODO: should be "chaining" here
- return Err(
- ErrorKind::InvalidCredentials(
- format!("macaroon deserialize error: {:?}", e)).into(),
- );
+ return Err(ErrorKind::InvalidCredentials(format!(
+ "macaroon deserialize error: {:?}",
+ e
+ ))
+ .into());
}
};
let mac = match mac.validate() {
Ok(m) => m,
Err(e) => {
// TODO: should be "chaining" here
- return Err(
- ErrorKind::InvalidCredentials(
- format!("macaroon validate error: {:?}", e)).into(),
- );
+ return Err(ErrorKind::InvalidCredentials(format!(
+ "macaroon validate error: {:?}",
+ e
+ ))
+ .into());
}
};
let mut verifier = Verifier::new();
@@ -270,10 +272,11 @@ impl AuthConfectionary {
let editor_id = match editor_id {
Some(id) => id,
None => {
- return Err(
- ErrorKind::InvalidCredentials("expected an editor_id caveat".to_string()).into(),
- );
- },
+ return Err(ErrorKind::InvalidCredentials(
+ "expected an editor_id caveat".to_string(),
+ )
+ .into());
+ }
};
verifier.satisfy_exact(&format!("editor_id = {}", editor_id.to_string()));
if let Some(endpoint) = endpoint {
@@ -294,10 +297,11 @@ impl AuthConfectionary {
let created = match created {
Some(c) => c,
None => {
- return Err(
- ErrorKind::InvalidCredentials("expected a 'created' (time >) caveat".to_string()).into(),
- );
- },
+ return Err(ErrorKind::InvalidCredentials(
+ "expected a 'created' (time >) caveat".to_string(),
+ )
+ .into());
+ }
};
verifier.satisfy_exact(&format!(
"time > {}",
@@ -327,9 +331,10 @@ impl AuthConfectionary {
let verify_key = match self.root_keys.get(mac.identifier()) {
Some(key) => key,
None => {
- return Err(ErrorKind::InvalidCredentials(
- format!("no valid auth signing key for identifier: {}", mac.identifier())
- )
+ return Err(ErrorKind::InvalidCredentials(format!(
+ "no valid auth signing key for identifier: {}",
+ mac.identifier()
+ ))
.into());
}
};
@@ -344,8 +349,7 @@ impl AuthConfectionary {
Err(e) => {
// TODO: chain
return Err(
- ErrorKind::InvalidCredentials(
- format!("token parsing failed: {:?}", e)).into(),
+ ErrorKind::InvalidCredentials(format!("token parsing failed: {:?}", e)).into(),
);
}
}
diff --git a/rust/tests/test_auth.rs b/rust/tests/test_auth.rs
index 412b67e8..1509bab4 100644
--- a/rust/tests/test_auth.rs
+++ b/rust/tests/test_auth.rs
@@ -18,7 +18,8 @@ fn test_macaroons() {
c.create_token(editor_id, None).unwrap();
// create token w/ expiration
- c.create_token(editor_id, Some(chrono::Duration::days(1))).unwrap();
+ c.create_token(editor_id, Some(chrono::Duration::days(1)))
+ .unwrap();
}
#[test]