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 std::sync::Arc;
|
||||||
|
|
||||||
use tokio::sync::Mutex;
|
use tokio::sync::Mutex;
|
||||||
use tracing::instrument;
|
use tracing::instrument;
|
||||||
|
|
||||||
use crate::db::{Database, SqliteDatabase};
|
use crate::{
|
||||||
#[derive(Debug, Clone, Deserialize)]
|
db::{Database, SqliteDatabase},
|
||||||
pub struct Password(pub SecretString);
|
secrets::{Password, UserToken},
|
||||||
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))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Authenticator<DB: Database> {
|
pub struct Authenticator<DB: Database> {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
use secrecy::SecretString;
|
|
||||||
use sqlx::{query, query_as, Connection, SqliteConnection};
|
use sqlx::{query, query_as, Connection, SqliteConnection};
|
||||||
|
|
||||||
use crate::auth::UserToken;
|
use crate::secrets::UserToken;
|
||||||
|
|
||||||
// TODO: allow configuring this via envar
|
// TODO: allow configuring this via envar
|
||||||
const DB_URI_DEFAULT: &str = "sqlite://sqlite.db";
|
const DB_URI_DEFAULT: &str = "sqlite://sqlite.db";
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
mod auth;
|
mod auth;
|
||||||
mod db;
|
mod db;
|
||||||
|
mod secrets;
|
||||||
mod server;
|
mod server;
|
||||||
|
|
||||||
use color_eyre::Result;
|
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 serde::{Deserialize, Serialize};
|
||||||
use tracing::{event, instrument, Level};
|
use tracing::{event, instrument, Level};
|
||||||
|
|
||||||
use crate::auth::Password;
|
use crate::secrets::Password;
|
||||||
|
|
||||||
#[instrument]
|
#[instrument]
|
||||||
pub async fn run() -> color_eyre::Result<()> {
|
pub async fn run() -> color_eyre::Result<()> {
|
||||||
|
|
Loading…
Reference in a new issue