Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phil/agent jwt secret #1825

Merged
merged 4 commits into from
Dec 13, 2024
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 Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ local_resource(
"DATABASE_URL": DATABASE_URL,
"RUST_LOG": "info",
"SSL_CERT_FILE": CA_CERT_PATH,
"CONTROL_PLANE_JWT_SECRET": "super-secret-jwt-token-with-at-least-32-characters-long",
},
resource_deps=['reactor', 'gazette']
)
Expand Down
16 changes: 9 additions & 7 deletions crates/agent/src/controllers/periodic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,14 @@ pub fn start_periodic_publish_update<C: ControlPlane>(
pending
}

// TODO: periodic publications are temporarily disabled
fn is_spec_disabled(state: &ControllerState) -> bool {
state
.live_spec
.as_ref()
// Collections are never considered disabled, since they can still be
// captured or materialized even if derivation shards are disabled.
.map(|ls| ls.catalog_type() != models::CatalogType::Collection && !ls.is_enabled())
.unwrap_or(true)
true
// state
// .live_spec
// .as_ref()
// // Collections are never considered disabled, since they can still be
// // captured or materialized even if derivation shards are disabled.
// .map(|ls| ls.catalog_type() != models::CatalogType::Collection && !ls.is_enabled())
// .unwrap_or(true)
}
4 changes: 4 additions & 0 deletions crates/agent/src/integration_tests/periodic_publications.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use std::collections::BTreeSet;

// TODO: temporarily disabled
/*
use crate::{
controllers::{ControllerState, Status},
integration_tests::harness::{
Expand Down Expand Up @@ -182,3 +184,5 @@ async fn specs_are_published_periodically() {
disabled_cap_end.last_build_id
);
}

*/
5 changes: 2 additions & 3 deletions crates/agent/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,8 @@ async fn async_main(args: Args) -> Result<(), anyhow::Error> {
let system_user_id = agent_sql::get_user_id_for_email(&args.accounts_email, &pg_pool)
.await
.context("querying for agent user id")?;
let jwt_secret: String = sqlx::query_scalar(r#"show app.settings.jwt_secret;"#)
.fetch_one(&pg_pool)
.await?;
let jwt_secret: String =
std::env::var("CONTROL_PLANE_JWT_SECRET").context("missing CONTROL_PLANE_JWT_SECRET")?;

if args.builds_root.scheme() == "file" {
std::fs::create_dir_all(args.builds_root.path())
Expand Down
15 changes: 15 additions & 0 deletions supabase/migrations/20241212195226_jwt_secret.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

begin;

select vault.create_secret('super-secret-jwt-token-with-at-least-32-characters-long', 'app.jwt_secret', 'The jwt secret');

CREATE OR REPLACE FUNCTION internal.access_token_jwt_secret() RETURNS text
LANGUAGE sql STABLE
AS $$

select decrypted_secret
from vault.decrypted_secrets
where name = 'app.jwt_secret';
$$;

commit;
Loading