Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/.env
/target/
/config.json
10 changes: 8 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ axum = { version = "0.8.4", features = ["macros", "original-uri"] }
case_insensitive_string = { version = "0.2.10", features = ["serde"] }
chrono = "0.4.41"
chrono-tz = "0.10.3"
dotenv = "0.15.0"
# Until https://github.com/johnstonskj/rust-email_address/pull/43 is merged and released.
email_address = { git = "https://github.com/illicitonion/rust-email_address.git", rev = "12cd9762a166b79a227beaa90b2f60a768d7c55c" }
futures = "0.3.31"
Expand All @@ -37,7 +38,8 @@ regex = "1.11.1"
reqwest = { version = "0.12.20", default-features = false, features = ["json", "rustls-tls"] }
secrecy = "0.10"
serde = { version = "1", features = ["derive"] }
serde-env-field = "0.3.2"
# Until https://github.com/mrshiposha/serde-env-field/pull/2 is merged and released.
serde-env-field = { git = "https://github.com/illicitonion/serde-env-field.git", rev = "aa455e090a2de89c2bdc53b20e3ce010e6e79d02" }
serde_json = "1"
serde_urlencoded = "0.7.1"
sheets = "0.7.0"
Expand Down
6 changes: 3 additions & 3 deletions config.prod.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"github_org": "CodeYourFuture",
"github_client_id": "Ov23liyZuouqyi9L3ZpM",
"github_client_id": "$CYF_TRAINEE_TRACKER_GITHUB_CLIENT_ID",
"github_client_secret": "$CYF_TRAINEE_TRACKER_GITHUB_CLIENT_SECRET",
"addr": "0.0.0.0",
"port": 3000,
"public_base_url": "https://trainee-tracker.hosting.codeyourfuture.io",
"google_apis_client_id": "403459539948-q1psg497mlfk9u6cgf0eea5qum4gp92n.apps.googleusercontent.com",
"public_base_url": "$CYF_TRAINEE_TRACKER_PUBLIC_BASE_URL",
"google_apis_client_id": "$CYF_TRAINEE_TRACKER_GOOGLE_APIS_CLIENT_ID",
"google_apis_client_secret": "$CYF_TRAINEE_TRACKER_GOOGLE_APIS_CLIENT_SECRET",
"github_email_mapping_sheet_id": "1ahDEnO8odD9oLtO_EBcvcmEaF0qsX-I4iLCIY0XLjt0",
"reviewer_staff_info_sheet_id": "1CKDrXtx5lkgfZ8E2mjvsDup2K8UyBsq99CIV0qOxrP0",
Expand Down
2 changes: 1 addition & 1 deletion src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ async fn exchange_github_oauth_code_for_access_token(
let client = reqwest::Client::new();

let response: GitHubOauthExchangeResponse = client
.get(format!("https://github.com/login/oauth/access_token?client_id={client_id}&client_secret={client_secret}&code={code}", client_id = config.github_client_id, client_secret = *config.github_client_secret, code = code))
.get(format!("https://github.com/login/oauth/access_token?client_id={client_id}&client_secret={client_secret}&code={code}", client_id = config.github_client_id, client_secret = config.github_client_secret, code = code))
.header(reqwest::header::ACCEPT, "application/json")
.send()
.await?
Expand Down
7 changes: 7 additions & 0 deletions src/bin/trainee-tracker.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use axum::routing::get;
use dotenv::dotenv;
use tower_sessions::{Expiry, MemoryStore, SessionManagerLayer};
use tracing::info;
use tracing_subscriber::prelude::*;
Expand Down Expand Up @@ -26,6 +27,12 @@ async fn main() {
.try_init()
.expect("Failed to configure logging");

if let Err(err) = dotenv() {
if !err.not_found() {
panic!("Error loading .env file: {}", err);
}
}

let config_bytes = std::fs::read(&args[0]).expect("Failed to read config file");
let config: Config =
serde_json::from_slice(&config_bytes).expect("Failed to parse config file");
Expand Down
6 changes: 3 additions & 3 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ use crate::{
#[derive(Clone, Deserialize)]
pub struct Config {
pub github_org: String,
pub github_client_id: String,
pub github_client_id: EnvField<String>,
pub github_client_secret: EnvField<String>,
pub addr: Option<IpAddr>,
pub port: u16,
pub public_base_url: String,
pub public_base_url: EnvField<String>,
/// Courses being tracked. Keys are things like "itp" or "sdc".
/// Ideally this would be less hard-coded.
/// Possible sources of truth for this are:
Expand All @@ -31,7 +31,7 @@ pub struct Config {
/// e.g. for itp, we'd expect itp-trainees/2025-05 and itp-mentors to exist.
pub courses: IndexMap<String, CourseInfo>,

pub google_apis_client_id: String,
pub google_apis_client_id: EnvField<String>,
pub google_apis_client_secret: EnvField<String>,

pub slack_client_id: String,
Expand Down