move secrets to secrets.rs
This commit is contained in:
parent
e4aa6c1909
commit
399ed56b74
5 changed files with 25 additions and 21 deletions
22
src/auth.rs
22
src/auth.rs
|
@ -1,26 +1,12 @@
|
|||
use secrecy::SecretString;
|
||||
use serde::Deserialize;
|
||||
use std::sync::Arc;
|
||||
|
||||
use tokio::sync::Mutex;
|
||||
use tracing::instrument;
|
||||
|
||||
use crate::db::{Database, SqliteDatabase};
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct Password(pub SecretString);
|
||||
impl From<String> for Password {
|
||||
fn from(value: String) -> Self {
|
||||
Self(SecretString::new(value))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct UserToken(pub SecretString);
|
||||
impl From<String> for UserToken {
|
||||
fn from(value: String) -> Self {
|
||||
Self(SecretString::new(value))
|
||||
}
|
||||
}
|
||||
use crate::{
|
||||
db::{Database, SqliteDatabase},
|
||||
secrets::{Password, UserToken},
|
||||
};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Authenticator<DB: Database> {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
use secrecy::SecretString;
|
||||
use sqlx::{query, query_as, Connection, SqliteConnection};
|
||||
|
||||
use crate::auth::UserToken;
|
||||
use crate::secrets::UserToken;
|
||||
|
||||
// TODO: allow configuring this via envar
|
||||
const DB_URI_DEFAULT: &str = "sqlite://sqlite.db";
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
mod auth;
|
||||
mod db;
|
||||
mod secrets;
|
||||
mod server;
|
||||
|
||||
use color_eyre::Result;
|
||||
|
|
18
src/secrets.rs
Normal file
18
src/secrets.rs
Normal file
|
@ -0,0 +1,18 @@
|
|||
use secrecy::SecretString;
|
||||
use serde::Deserialize;
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct Password(pub SecretString);
|
||||
impl From<String> for Password {
|
||||
fn from(value: String) -> Self {
|
||||
Self(SecretString::new(value))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct UserToken(pub SecretString);
|
||||
impl From<String> for UserToken {
|
||||
fn from(value: String) -> Self {
|
||||
Self(SecretString::new(value))
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@ use axum::{
|
|||
use serde::{Deserialize, Serialize};
|
||||
use tracing::{event, instrument, Level};
|
||||
|
||||
use crate::auth::Password;
|
||||
use crate::secrets::Password;
|
||||
|
||||
#[instrument]
|
||||
pub async fn run() -> color_eyre::Result<()> {
|
||||
|
|
Loading…
Reference in a new issue