diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..f26119f --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +target +/target +**/.idea +.idea \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index fe3f1ae..1f42577 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -584,7 +584,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "778e2ac28f6c47af28e4907f13ffd1e1ddbd400980a9abd7c8df189bf578a5ad" dependencies = [ "libc", - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] @@ -2080,7 +2080,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys", - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] @@ -2652,7 +2652,7 @@ dependencies = [ "getrandom 0.3.3", "once_cell", "rustix", - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3140df1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM rust:1.89.0-bookworm AS builder +RUN apt-get update +RUN apt-get install -y pkg-config \ + libssl-dev +WORKDIR /app +COPY ../ /app +RUN cargo build --release +# +FROM rust:1.89-bookworm AS api +RUN apt-get update +RUN apt-get install -y libssl3 \ + ca-certificates +COPY --from=builder /app/target/release/pds_gatekeeper /usr/local/bin/pds_gatekeeper +CMD ["pds_gatekeeper"] \ No newline at end of file diff --git a/justfile b/justfile new file mode 100644 index 0000000..380266e --- /dev/null +++ b/justfile @@ -0,0 +1,9 @@ +release: + docker buildx build \ + --platform linux/arm64 \ + --tag fatfingers23/pds_gatekeeper:arm-latest \ + --push . +# docker buildx build \ +# --platform linux/amd64 \ +# --tag fatfingers23/pds_gatekeeper:latest \ +# --push . \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index a95eef1..44700a5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -88,8 +88,10 @@ ______________| | || / \ / \||/ \ / \ || | |______________ #[tokio::main] async fn main() -> Result<(), Box> { setup_tracing(); - //TODO may need to change where this reads from? Like an env variable for it's location? Or arg? - dotenvy::from_path(Path::new("./pds.env"))?; + let pds_env_location = + env::var("PDS_ENV_LOCATION").unwrap_or_else(|_| "/pds/pds.env".to_string()); + + dotenvy::from_path(Path::new(&pds_env_location))?; let pds_root = env::var("PDS_DATA_DIRECTORY")?; let account_db_url = format!("{pds_root}/account.sqlite"); @@ -129,6 +131,10 @@ async fn main() -> Result<(), Box> { env::var("PDS_EMAIL_SMTP_URL").expect("PDS_EMAIL_SMTP_URL is not set in your pds.env file"); let sent_from = env::var("PDS_EMAIL_FROM_ADDRESS") .expect("PDS_EMAIL_FROM_ADDRESS is not set in your pds.env file"); + + //TODO current bug running in docker + // https://github.com/lettre/lettre/issues/349#issuecomment-510155500 + let mailer: AsyncSmtpTransport = AsyncSmtpTransport::::from_url(smtp_url.as_str())?.build(); //Email templates setup diff --git a/src/oauth_provider.rs b/src/oauth_provider.rs index ae3caad..5a545bf 100644 --- a/src/oauth_provider.rs +++ b/src/oauth_provider.rs @@ -36,9 +36,6 @@ pub async fn sign_in( "Invalid identifier or password", ), AuthResult::TwoFactorRequired(masked_email) => { - // Email sending step can be handled here if needed in the future. - - // {"error":"second_authentication_factor_required","error_description":"emailOtp authentication factor required (hint: 2***0@p***m)","type":"emailOtp","hint":"2***0@p***m"} let body_str = match serde_json::to_string(&serde_json::json!({ "error": "second_authentication_factor_required", "error_description": format!("emailOtp authentication factor required (hint: {})", masked_email), @@ -97,7 +94,7 @@ pub async fn sign_in( }, Err(err) => { log::error!( - "Error during pre-auth check. This happens on the create_session endpoint when trying to decide if the user has access:\n {err}" + "Error during pre-auth check. This happens on the oauth signin endpoint when trying to decide if the user has access:\n {err}" ); oauth_json_error_response( StatusCode::BAD_REQUEST,