Fix linting errors

This commit is contained in:
Tobie Morgan Hitchcock 2022-09-10 06:11:56 +01:00
parent fde0c55d34
commit 498b0a4530

View file

@ -2,6 +2,7 @@ use crate::cli::CF;
use crate::dbs::DB; use crate::dbs::DB;
use crate::err::Error; use crate::err::Error;
use crate::iam::token::Claims; use crate::iam::token::Claims;
use crate::iam::LOG;
use argon2::password_hash::{PasswordHash, PasswordVerifier}; use argon2::password_hash::{PasswordHash, PasswordVerifier};
use argon2::Argon2; use argon2::Argon2;
use jsonwebtoken::{decode, DecodingKey, Validation}; use jsonwebtoken::{decode, DecodingKey, Validation};
@ -11,7 +12,6 @@ use surrealdb::sql::Algorithm;
use surrealdb::sql::Value; use surrealdb::sql::Value;
use surrealdb::Auth; use surrealdb::Auth;
use surrealdb::Session; use surrealdb::Session;
use crate::iam::LOG;
fn config(algo: Algorithm, code: String) -> Result<(DecodingKey, Validation), Error> { fn config(algo: Algorithm, code: String) -> Result<(DecodingKey, Validation), Error> {
match algo { match algo {
@ -168,7 +168,7 @@ pub async fn token(session: &mut Session, auth: String) -> Result<(), Error> {
.. ..
} => { } => {
// Log the decoded authentication claims // Log the decoded authentication claims
trace!(target: LOG, "Attempting authentication for scope `{}` with token `{}`", sc, tk); trace!(target: LOG, "Authenticating to scope `{}` with token `{}`", sc, tk);
// Create a new readonly transaction // Create a new readonly transaction
let mut tx = kvs.transaction(false, false).await?; let mut tx = kvs.transaction(false, false).await?;
// Parse the record id // Parse the record id
@ -179,7 +179,7 @@ pub async fn token(session: &mut Session, auth: String) -> Result<(), Error> {
// Verify the token // Verify the token
decode::<Claims>(auth, &cf.0, &cf.1)?; decode::<Claims>(auth, &cf.0, &cf.1)?;
// Log the success // Log the success
debug!(target: LOG, "Authenticated to scope `{}` with token `{}` as `{}`", sc, tk, id); debug!(target: LOG, "Authenticated to scope `{}` with token `{}`", sc, tk);
// Set the session // Set the session
session.ns = Some(ns.to_owned()); session.ns = Some(ns.to_owned());
session.db = Some(db.to_owned()); session.db = Some(db.to_owned());
@ -197,7 +197,7 @@ pub async fn token(session: &mut Session, auth: String) -> Result<(), Error> {
.. ..
} => { } => {
// Log the decoded authentication claims // Log the decoded authentication claims
trace!(target: LOG, "Attempting authentication for scope `{}`", sc); trace!(target: LOG, "Authenticating to scope `{}`", sc);
// Create a new readonly transaction // Create a new readonly transaction
let mut tx = kvs.transaction(false, false).await?; let mut tx = kvs.transaction(false, false).await?;
// Parse the record id // Parse the record id
@ -208,7 +208,7 @@ pub async fn token(session: &mut Session, auth: String) -> Result<(), Error> {
// Verify the token // Verify the token
decode::<Claims>(auth, &cf.0, &cf.1)?; decode::<Claims>(auth, &cf.0, &cf.1)?;
// Log the success // Log the success
debug!(target: LOG, "Authenticated to scope `{}` as `{}`", sc, id); debug!(target: LOG, "Authenticated to scope `{}`", sc);
// Set the session // Set the session
session.ns = Some(ns.to_owned()); session.ns = Some(ns.to_owned());
session.db = Some(db.to_owned()); session.db = Some(db.to_owned());
@ -225,7 +225,7 @@ pub async fn token(session: &mut Session, auth: String) -> Result<(), Error> {
.. ..
} => { } => {
// Log the decoded authentication claims // Log the decoded authentication claims
trace!(target: LOG, "Attempting authentication for database `{}` with token `{}`", db, tk); trace!(target: LOG, "Authenticating to database `{}` with token `{}`", db, tk);
// Create a new readonly transaction // Create a new readonly transaction
let mut tx = kvs.transaction(false, false).await?; let mut tx = kvs.transaction(false, false).await?;
// Get the database token // Get the database token
@ -249,7 +249,7 @@ pub async fn token(session: &mut Session, auth: String) -> Result<(), Error> {
.. ..
} => { } => {
// Log the decoded authentication claims // Log the decoded authentication claims
trace!(target: LOG, "Attempting authentication for database `{}` with login `{}`", db, id); trace!(target: LOG, "Authenticating to database `{}` with login `{}`", db, id);
// Create a new readonly transaction // Create a new readonly transaction
let mut tx = kvs.transaction(false, false).await?; let mut tx = kvs.transaction(false, false).await?;
// Get the database login // Get the database login
@ -272,7 +272,7 @@ pub async fn token(session: &mut Session, auth: String) -> Result<(), Error> {
.. ..
} => { } => {
// Log the decoded authentication claims // Log the decoded authentication claims
trace!(target: LOG, "Attempting authentication for namespace `{}` with token `{}`", ns, tk); trace!(target: LOG, "Authenticating to namespace `{}` with token `{}`", ns, tk);
// Create a new readonly transaction // Create a new readonly transaction
let mut tx = kvs.transaction(false, false).await?; let mut tx = kvs.transaction(false, false).await?;
// Get the namespace token // Get the namespace token
@ -294,7 +294,7 @@ pub async fn token(session: &mut Session, auth: String) -> Result<(), Error> {
.. ..
} => { } => {
// Log the decoded authentication claims // Log the decoded authentication claims
trace!(target: LOG, "Attempting authentication for namespace `{}` with login `{}`", ns, id); trace!(target: LOG, "Authenticating to namespace `{}` with login `{}`", ns, id);
// Create a new readonly transaction // Create a new readonly transaction
let mut tx = kvs.transaction(false, false).await?; let mut tx = kvs.transaction(false, false).await?;
// Get the namespace login // Get the namespace login