Skip to content

Commit b011bb0

Browse files
committed
config/server: Add gh_token_encryption field
1 parent 0945639 commit b011bb0

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/config/server.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use url::Url;
55

66
use crate::Env;
77
use crate::rate_limiter::{LimitedAction, RateLimiterConfig};
8+
use crate::util::gh_token_encryption::GitHubTokenEncryption;
89

910
use super::base::Base;
1011
use super::database_pools::DatabasePools;
@@ -42,6 +43,7 @@ pub struct Server {
4243
pub session_key: cookie::Key,
4344
pub gh_client_id: ClientId,
4445
pub gh_client_secret: ClientSecret,
46+
pub gh_token_encryption: GitHubTokenEncryption,
4547
pub max_upload_size: u32,
4648
pub max_unpack_size: u64,
4749
pub max_dependencies: usize,
@@ -106,6 +108,7 @@ impl Server {
106108
/// - `SESSION_KEY`: The key used to sign and encrypt session cookies.
107109
/// - `GH_CLIENT_ID`: The client ID of the associated GitHub application.
108110
/// - `GH_CLIENT_SECRET`: The client secret of the associated GitHub application.
111+
/// - `GITHUB_TOKEN_ENCRYPTION_KEY`: Key for encrypting GitHub access tokens (64 hex characters).
109112
/// - `BLOCKED_TRAFFIC`: A list of headers and environment variables to use for blocking
110113
/// traffic. See the `block_traffic` module for more documentation.
111114
/// - `DOWNLOADS_PERSIST_INTERVAL_MS`: how frequent to persist download counts (in ms).
@@ -205,6 +208,7 @@ impl Server {
205208
session_key: cookie::Key::derive_from(required_var("SESSION_KEY")?.as_bytes()),
206209
gh_client_id: ClientId::new(required_var("GH_CLIENT_ID")?),
207210
gh_client_secret: ClientSecret::new(required_var("GH_CLIENT_SECRET")?),
211+
gh_token_encryption: GitHubTokenEncryption::from_environment()?,
208212
max_upload_size: 10 * 1024 * 1024, // 10 MB default file upload size limit
209213
max_unpack_size: 512 * 1024 * 1024, // 512 MB max when decompressed
210214
max_dependencies: DEFAULT_MAX_DEPENDENCIES,

src/tests/util/test_app.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use crate::rate_limiter::{LimitedAction, RateLimiterConfig};
99
use crate::storage::StorageConfig;
1010
use crate::tests::util::chaosproxy::ChaosProxy;
1111
use crate::tests::util::github::MOCK_GITHUB_DATA;
12+
use crate::util::gh_token_encryption::GitHubTokenEncryption;
1213
use crate::worker::{Environment, RunnerExt};
1314
use crate::{App, Emails, Env};
1415
use claims::assert_some;
@@ -489,6 +490,7 @@ fn simple_config() -> config::Server {
489490
session_key: cookie::Key::derive_from("test this has to be over 32 bytes long".as_bytes()),
490491
gh_client_id: ClientId::new(dotenvy::var("GH_CLIENT_ID").unwrap_or_default()),
491492
gh_client_secret: ClientSecret::new(dotenvy::var("GH_CLIENT_SECRET").unwrap_or_default()),
493+
gh_token_encryption: GitHubTokenEncryption::for_testing(),
492494
max_upload_size: 128 * 1024, // 128 kB should be enough for most testing purposes
493495
max_unpack_size: 128 * 1024, // 128 kB should be enough for most testing purposes
494496
max_features: 10,

0 commit comments

Comments
 (0)