cargo-fix
This commit is contained in:
parent
8d4bd51b4e
commit
359f5be936
|
@ -1,6 +1,6 @@
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use actix_web::HttpRequest;
|
use actix_web::HttpRequest;
|
||||||
use log::debug;
|
|
||||||
use sea_orm::{ColumnTrait, Condition, DatabaseConnection, EntityTrait, QueryFilter};
|
use sea_orm::{ColumnTrait, Condition, DatabaseConnection, EntityTrait, QueryFilter};
|
||||||
use crate::tokens::get_token_type;
|
use crate::tokens::get_token_type;
|
||||||
use trifid_api_entities::entity::{auth_token, session_token};
|
use trifid_api_entities::entity::{auth_token, session_token};
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use actix_request_identifier::RequestIdentifier;
|
use actix_request_identifier::RequestIdentifier;
|
||||||
use actix_web::{App, HttpResponse, HttpServer, post, web::{Data, Json, JsonConfig}};
|
use actix_web::{App, HttpResponse, HttpServer, web::{Data, JsonConfig}};
|
||||||
use log::{error, info, Level};
|
use log::{info, Level};
|
||||||
use sea_orm::{ConnectOptions, Database, DatabaseConnection};
|
use sea_orm::{ConnectOptions, Database, DatabaseConnection};
|
||||||
use serde::{Serialize, Deserialize};
|
|
||||||
use trifid_api_migration::{Migrator, MigratorTrait};
|
use trifid_api_migration::{Migrator, MigratorTrait};
|
||||||
use crate::config::CONFIG;
|
use crate::config::CONFIG;
|
||||||
use crate::error::{APIError, APIErrorsResponse};
|
use crate::error::{APIError, APIErrorsResponse};
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use actix_web::{HttpResponse, post};
|
use actix_web::{HttpResponse, post};
|
||||||
use actix_web::web::{Data, Json};
|
use actix_web::web::{Data, Json};
|
||||||
use log::error;
|
use log::error;
|
||||||
use sea_orm::{ActiveModelTrait, ColumnTrait, DatabaseConnection, EntityTrait, IntoActiveModel, QueryFilter};
|
use sea_orm::{ActiveModelTrait, ColumnTrait, EntityTrait, IntoActiveModel, QueryFilter};
|
||||||
use serde::{Serialize, Deserialize};
|
use serde::{Serialize, Deserialize};
|
||||||
use trifid_api_entities::entity::user::Entity as UserEntity;
|
use trifid_api_entities::entity::user::Entity as UserEntity;
|
||||||
use trifid_api_entities::entity::user;
|
use trifid_api_entities::entity::user;
|
||||||
|
|
|
@ -7,8 +7,8 @@ use crate::AppState;
|
||||||
use crate::auth_tokens::{enforce_session, TokenInfo};
|
use crate::auth_tokens::{enforce_session, TokenInfo};
|
||||||
use crate::error::{APIError, APIErrorsResponse};
|
use crate::error::{APIError, APIErrorsResponse};
|
||||||
use sea_orm::{EntityTrait, QueryFilter, ColumnTrait, IntoActiveModel, ActiveModelTrait};
|
use sea_orm::{EntityTrait, QueryFilter, ColumnTrait, IntoActiveModel, ActiveModelTrait};
|
||||||
use sea_orm::ActiveValue::Set;
|
|
||||||
use totp_rs::{Algorithm, Secret, TOTP};
|
use totp_rs::{Secret, TOTP};
|
||||||
use trifid_api_entities::entity::auth_token;
|
use trifid_api_entities::entity::auth_token;
|
||||||
use crate::config::CONFIG;
|
use crate::config::CONFIG;
|
||||||
use crate::timers::expires_in_seconds;
|
use crate::timers::expires_in_seconds;
|
||||||
|
@ -91,7 +91,7 @@ pub async fn totp_request(req: Json<TotpRequest>, req_data: HttpRequest, db: Dat
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let secret = Secret::Encoded(auther.secret.clone());
|
let _secret = Secret::Encoded(auther.secret.clone());
|
||||||
let totpmachine = match TOTP::from_url(auther.url.clone()) {
|
let totpmachine = match TOTP::from_url(auther.url.clone()) {
|
||||||
Ok(m) => m,
|
Ok(m) => m,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
|
|
@ -5,7 +5,7 @@ use chrono::{TimeZone, Utc};
|
||||||
use log::error;
|
use log::error;
|
||||||
use sea_orm::{ColumnTrait, EntityTrait, PaginatorTrait, QueryFilter, QueryOrder};
|
use sea_orm::{ColumnTrait, EntityTrait, PaginatorTrait, QueryFilter, QueryOrder};
|
||||||
use crate::AppState;
|
use crate::AppState;
|
||||||
use crate::auth_tokens::{enforce_2fa, enforce_api_token, enforce_session, TokenInfo};
|
use crate::auth_tokens::{enforce_2fa, enforce_api_token, TokenInfo};
|
||||||
use crate::error::{APIError, APIErrorsResponse};
|
use crate::error::{APIError, APIErrorsResponse};
|
||||||
use trifid_api_entities::entity::organization;
|
use trifid_api_entities::entity::organization;
|
||||||
use trifid_api_entities::entity::network;
|
use trifid_api_entities::entity::network;
|
||||||
|
|
|
@ -16,7 +16,7 @@ use trifid_pki::cert::{NebulaCertificate, NebulaCertificateDetails, serialize_x2
|
||||||
use trifid_pki::ed25519_dalek::SigningKey;
|
use trifid_pki::ed25519_dalek::SigningKey;
|
||||||
use trifid_pki::rand_core::OsRng;
|
use trifid_pki::rand_core::OsRng;
|
||||||
use trifid_api_entities::entity::{network, organization, signing_ca};
|
use trifid_api_entities::entity::{network, organization, signing_ca};
|
||||||
use crate::auth_tokens::{enforce_2fa, enforce_api_token, TokenInfo};
|
use crate::auth_tokens::{enforce_2fa, TokenInfo};
|
||||||
use crate::config::CONFIG;
|
use crate::config::CONFIG;
|
||||||
use crate::crypto::{encrypt_with_nonce, generate_random_iv, get_cipher_from_config};
|
use crate::crypto::{encrypt_with_nonce, generate_random_iv, get_cipher_from_config};
|
||||||
use crate::error::{APIError, APIErrorsResponse};
|
use crate::error::{APIError, APIErrorsResponse};
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use actix_web::{HttpResponse, post};
|
use actix_web::{HttpResponse, post};
|
||||||
use actix_web::web::{Data, Json};
|
use actix_web::web::{Data, Json};
|
||||||
use log::error;
|
use log::error;
|
||||||
use sea_orm::{ActiveModelTrait, ColumnTrait, DatabaseConnection, EntityTrait, IntoActiveModel, QueryFilter};
|
use sea_orm::{ActiveModelTrait, ColumnTrait, EntityTrait, IntoActiveModel, QueryFilter};
|
||||||
use serde::{Serialize, Deserialize};
|
use serde::{Serialize, Deserialize};
|
||||||
use trifid_api_entities::entity::user::Entity as UserEntity;
|
use trifid_api_entities::entity::user::Entity as UserEntity;
|
||||||
use trifid_api_entities::entity::user;
|
use trifid_api_entities::entity::user;
|
||||||
|
|
|
@ -5,12 +5,12 @@ use log::error;
|
||||||
use sea_orm::{ActiveModelTrait, ColumnTrait, EntityTrait, IntoActiveModel, ModelTrait, QueryFilter};
|
use sea_orm::{ActiveModelTrait, ColumnTrait, EntityTrait, IntoActiveModel, ModelTrait, QueryFilter};
|
||||||
use totp_rs::{Algorithm, Secret, TOTP};
|
use totp_rs::{Algorithm, Secret, TOTP};
|
||||||
use crate::AppState;
|
use crate::AppState;
|
||||||
use crate::auth_tokens::{enforce_2fa, enforce_session, TokenInfo};
|
use crate::auth_tokens::{enforce_session, TokenInfo};
|
||||||
use crate::error::{APIError, APIErrorsResponse};
|
use crate::error::{APIError, APIErrorsResponse};
|
||||||
use trifid_api_entities::entity::totp_authenticator;
|
use trifid_api_entities::entity::totp_authenticator;
|
||||||
use crate::config::CONFIG;
|
use crate::config::CONFIG;
|
||||||
use crate::timers::expires_in_seconds;
|
use crate::timers::expires_in_seconds;
|
||||||
use crate::tokens::{random_id, random_token};
|
use crate::tokens::{random_token};
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
pub struct TotpAuthenticatorsRequest {}
|
pub struct TotpAuthenticatorsRequest {}
|
||||||
|
@ -33,7 +33,7 @@ pub struct TotpAuthenticatorsResponse {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[post("/v1/totp-authenticators")]
|
#[post("/v1/totp-authenticators")]
|
||||||
pub async fn totp_authenticators_request(db: Data<AppState>, req_data: HttpRequest, req: Json<TotpAuthenticatorsRequest>) -> HttpResponse {
|
pub async fn totp_authenticators_request(db: Data<AppState>, req_data: HttpRequest, _req: Json<TotpAuthenticatorsRequest>) -> HttpResponse {
|
||||||
// require a user session
|
// require a user session
|
||||||
let session_token = match enforce_session(&req_data, &db.conn).await {
|
let session_token = match enforce_session(&req_data, &db.conn).await {
|
||||||
Ok(r) => {
|
Ok(r) => {
|
||||||
|
|
|
@ -8,7 +8,7 @@ use crate::auth_tokens::{enforce_session, TokenInfo};
|
||||||
use crate::error::{APIError, APIErrorsResponse};
|
use crate::error::{APIError, APIErrorsResponse};
|
||||||
use sea_orm::{EntityTrait, QueryFilter, ColumnTrait, IntoActiveModel, ActiveModelTrait};
|
use sea_orm::{EntityTrait, QueryFilter, ColumnTrait, IntoActiveModel, ActiveModelTrait};
|
||||||
use sea_orm::ActiveValue::Set;
|
use sea_orm::ActiveValue::Set;
|
||||||
use totp_rs::{Algorithm, Secret, TOTP};
|
use totp_rs::{Secret, TOTP};
|
||||||
use trifid_api_entities::entity::auth_token;
|
use trifid_api_entities::entity::auth_token;
|
||||||
use crate::config::CONFIG;
|
use crate::config::CONFIG;
|
||||||
use crate::timers::expires_in_seconds;
|
use crate::timers::expires_in_seconds;
|
||||||
|
@ -104,7 +104,7 @@ pub async fn verify_totp_authenticators_request(req: Json<VerifyTotpAuthenticato
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let secret = Secret::Encoded(auther.secret.clone());
|
let _secret = Secret::Encoded(auther.secret.clone());
|
||||||
let totpmachine = match TOTP::from_url(auther.url.clone()) {
|
let totpmachine = match TOTP::from_url(auther.url.clone()) {
|
||||||
Ok(m) => m,
|
Ok(m) => m,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
|
Loading…
Reference in New Issue