From c4dddc20562e2d0a8ddf66cdf87b4b905ebd8d5e Mon Sep 17 00:00:00 2001 From: NathanFlurry Date: Wed, 30 Oct 2024 06:55:22 +0000 Subject: [PATCH] chore: automatically print admin access token url (#1285) ## Changes --- Cargo.lock | 21 +++ Cargo.toml | 1 + packages/cli/Cargo.toml | 1 + packages/cli/src/run_config.rs | 8 +- packages/common/config/src/config/rivet.rs | 3 + .../migrations/20200101000000_init.down.sql | 0 .../migrations/20200101000000_init.up.sql | 11 -- ...20210610125957_enable_domain_auth.down.sql | 0 .../20210610125957_enable_domain_auth.up.sql | 1 - ...618204613_drop_enable_domain_auth.down.sql | 0 ...10618204613_drop_enable_domain_auth.up.sql | 1 - ...20210811032551_game_token_session.down.sql | 0 .../20210811032551_game_token_session.up.sql | 5 - .../20210811033143_dev_and_ns_tokens.down.sql | 0 .../20210811033143_dev_and_ns_tokens.up.sql | 11 -- ...4022033_version_name_reservations.down.sql | 0 ...224022033_version_name_reservations.up.sql | 8 -- ...20240708222624_game_service_token.down.sql | 0 .../20240708222624_game_service_token.up.sql | 5 - .../admin/ops/device-link-create/Cargo.toml | 17 --- .../admin/ops/device-link-create/README.md | 1 - .../admin/ops/device-link-create/src/lib.rs | 40 ------ .../device-link-create/tests/integration.rs | 13 -- .../admin/ops/game-config-create/Cargo.toml | 19 --- .../admin/ops/game-config-create/src/lib.rs | 18 --- .../game-config-create/tests/integration.rs | 18 --- .../admin/ops/game-config-get/Cargo.toml | 21 --- .../admin/ops/game-config-get/README.md | 1 - .../admin/ops/game-config-get/src/lib.rs | 43 ------ .../ops/game-config-get/tests/integration.rs | 28 ---- .../admin/ops/game-token-create/Cargo.toml | 23 --- .../admin/ops/game-token-create/README.md | 1 - .../admin/ops/game-token-create/src/lib.rs | 47 ------- .../game-token-create/tests/integration.rs | 16 --- .../admin/ops/namespace-create/Cargo.toml | 28 ---- .../admin/ops/namespace-create/README.md | 1 - .../admin/ops/namespace-create/src/lib.rs | 73 ---------- .../ops/namespace-create/tests/integration.rs | 40 ------ .../admin/ops/namespace-get/Cargo.toml | 27 ---- .../admin/ops/namespace-get/README.md | 1 - .../admin/ops/namespace-get/src/lib.rs | 86 ------------ .../ops/namespace-get/tests/integration.rs | 42 ------ .../Cargo.toml | 25 ---- .../README.md | 1 - .../src/lib.rs | 77 ---------- .../tests/integration.rs | 26 ---- .../namespace-token-public-create/Cargo.toml | 25 ---- .../namespace-token-public-create/README.md | 1 - .../namespace-token-public-create/src/lib.rs | 58 -------- .../tests/integration.rs | 17 --- .../services/admin/ops/version-get/Cargo.toml | 28 ---- .../services/admin/ops/version-get/README.md | 1 - .../services/admin/ops/version-get/src/lib.rs | 76 ---------- .../ops/version-get/tests/integration.rs | 89 ------------ .../admin/ops/version-publish/Cargo.toml | 32 ----- .../admin/ops/version-publish/README.md | 20 --- .../admin/ops/version-publish/src/lib.rs | 131 ------------------ .../ops/version-publish/tests/integration.rs | 84 ----------- .../admin/proto/device-link-create.proto | 14 -- .../admin/proto/game-config-create.proto | 13 -- .../admin/proto/game-config-get.proto | 14 -- .../admin/proto/game-token-create.proto | 13 -- .../msg/device-link-complete-complete.proto | 17 --- .../proto/msg/device-link-complete.proto | 16 --- .../msg/version-name-reserve-complete.proto | 17 --- .../proto/msg/version-name-reserve.proto | 16 --- .../admin/proto/namespace-create.proto | 14 -- .../services/admin/proto/namespace-get.proto | 14 -- .../namespace-token-development-create.proto | 17 --- .../proto/namespace-token-public-create.proto | 13 -- .../services/admin/proto/version-get.proto | 14 -- .../admin/proto/version-publish.proto | 17 --- .../admin/standalone/default-login/Cargo.toml | 28 ++++ .../admin/standalone/default-login/src/lib.rs | 63 +++++++++ 74 files changed, 122 insertions(+), 1549 deletions(-) delete mode 100644 packages/services/admin/db/cloud/migrations/20200101000000_init.down.sql delete mode 100644 packages/services/admin/db/cloud/migrations/20200101000000_init.up.sql delete mode 100644 packages/services/admin/db/cloud/migrations/20210610125957_enable_domain_auth.down.sql delete mode 100644 packages/services/admin/db/cloud/migrations/20210610125957_enable_domain_auth.up.sql delete mode 100644 packages/services/admin/db/cloud/migrations/20210618204613_drop_enable_domain_auth.down.sql delete mode 100644 packages/services/admin/db/cloud/migrations/20210618204613_drop_enable_domain_auth.up.sql delete mode 100644 packages/services/admin/db/cloud/migrations/20210811032551_game_token_session.down.sql delete mode 100644 packages/services/admin/db/cloud/migrations/20210811032551_game_token_session.up.sql delete mode 100644 packages/services/admin/db/cloud/migrations/20210811033143_dev_and_ns_tokens.down.sql delete mode 100644 packages/services/admin/db/cloud/migrations/20210811033143_dev_and_ns_tokens.up.sql delete mode 100644 packages/services/admin/db/cloud/migrations/20231224022033_version_name_reservations.down.sql delete mode 100644 packages/services/admin/db/cloud/migrations/20231224022033_version_name_reservations.up.sql delete mode 100644 packages/services/admin/db/cloud/migrations/20240708222624_game_service_token.down.sql delete mode 100644 packages/services/admin/db/cloud/migrations/20240708222624_game_service_token.up.sql delete mode 100644 packages/services/admin/ops/device-link-create/Cargo.toml delete mode 100644 packages/services/admin/ops/device-link-create/README.md delete mode 100644 packages/services/admin/ops/device-link-create/src/lib.rs delete mode 100644 packages/services/admin/ops/device-link-create/tests/integration.rs delete mode 100644 packages/services/admin/ops/game-config-create/Cargo.toml delete mode 100644 packages/services/admin/ops/game-config-create/src/lib.rs delete mode 100644 packages/services/admin/ops/game-config-create/tests/integration.rs delete mode 100644 packages/services/admin/ops/game-config-get/Cargo.toml delete mode 100644 packages/services/admin/ops/game-config-get/README.md delete mode 100644 packages/services/admin/ops/game-config-get/src/lib.rs delete mode 100644 packages/services/admin/ops/game-config-get/tests/integration.rs delete mode 100644 packages/services/admin/ops/game-token-create/Cargo.toml delete mode 100644 packages/services/admin/ops/game-token-create/README.md delete mode 100644 packages/services/admin/ops/game-token-create/src/lib.rs delete mode 100644 packages/services/admin/ops/game-token-create/tests/integration.rs delete mode 100644 packages/services/admin/ops/namespace-create/Cargo.toml delete mode 100644 packages/services/admin/ops/namespace-create/README.md delete mode 100644 packages/services/admin/ops/namespace-create/src/lib.rs delete mode 100644 packages/services/admin/ops/namespace-create/tests/integration.rs delete mode 100644 packages/services/admin/ops/namespace-get/Cargo.toml delete mode 100644 packages/services/admin/ops/namespace-get/README.md delete mode 100644 packages/services/admin/ops/namespace-get/src/lib.rs delete mode 100644 packages/services/admin/ops/namespace-get/tests/integration.rs delete mode 100644 packages/services/admin/ops/namespace-token-development-create/Cargo.toml delete mode 100644 packages/services/admin/ops/namespace-token-development-create/README.md delete mode 100644 packages/services/admin/ops/namespace-token-development-create/src/lib.rs delete mode 100644 packages/services/admin/ops/namespace-token-development-create/tests/integration.rs delete mode 100644 packages/services/admin/ops/namespace-token-public-create/Cargo.toml delete mode 100644 packages/services/admin/ops/namespace-token-public-create/README.md delete mode 100644 packages/services/admin/ops/namespace-token-public-create/src/lib.rs delete mode 100644 packages/services/admin/ops/namespace-token-public-create/tests/integration.rs delete mode 100644 packages/services/admin/ops/version-get/Cargo.toml delete mode 100644 packages/services/admin/ops/version-get/README.md delete mode 100644 packages/services/admin/ops/version-get/src/lib.rs delete mode 100644 packages/services/admin/ops/version-get/tests/integration.rs delete mode 100644 packages/services/admin/ops/version-publish/Cargo.toml delete mode 100644 packages/services/admin/ops/version-publish/README.md delete mode 100644 packages/services/admin/ops/version-publish/src/lib.rs delete mode 100644 packages/services/admin/ops/version-publish/tests/integration.rs delete mode 100644 packages/services/admin/proto/device-link-create.proto delete mode 100644 packages/services/admin/proto/game-config-create.proto delete mode 100644 packages/services/admin/proto/game-config-get.proto delete mode 100644 packages/services/admin/proto/game-token-create.proto delete mode 100644 packages/services/admin/proto/msg/device-link-complete-complete.proto delete mode 100644 packages/services/admin/proto/msg/device-link-complete.proto delete mode 100644 packages/services/admin/proto/msg/version-name-reserve-complete.proto delete mode 100644 packages/services/admin/proto/msg/version-name-reserve.proto delete mode 100644 packages/services/admin/proto/namespace-create.proto delete mode 100644 packages/services/admin/proto/namespace-get.proto delete mode 100644 packages/services/admin/proto/namespace-token-development-create.proto delete mode 100644 packages/services/admin/proto/namespace-token-public-create.proto delete mode 100644 packages/services/admin/proto/version-get.proto delete mode 100644 packages/services/admin/proto/version-publish.proto create mode 100644 packages/services/admin/standalone/default-login/Cargo.toml create mode 100644 packages/services/admin/standalone/default-login/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 7e6224cb6f..f024a45277 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -33,6 +33,26 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" +[[package]] +name = "admin-default-login" +version = "0.0.1" +dependencies = [ + "chirp-client", + "chirp-workflow", + "rivet-config", + "rivet-connection", + "rivet-health-checks", + "rivet-metrics", + "rivet-operation", + "rivet-runtime", + "sqlx", + "token-create", + "tokio", + "tracing", + "tracing-logfmt", + "tracing-subscriber", +] + [[package]] name = "aes" version = "0.8.4" @@ -7947,6 +7967,7 @@ dependencies = [ name = "rivet-cli" version = "0.1.0" dependencies = [ + "admin-default-login", "anyhow", "api-monolith-edge", "api-monolith-private", diff --git a/Cargo.toml b/Cargo.toml index 7c796003c4..58bd6e8c93 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -85,6 +85,7 @@ members = [ "packages/api/games/", "packages/api/actor/", "packages/api/monolith-public/", +"packages/services/admin/standalone/default-login", "packages/services/token/ops/exchange/", "packages/services/token/ops/revoke/", "packages/services/token/ops/get/", diff --git a/packages/cli/Cargo.toml b/packages/cli/Cargo.toml index 8108cc5849..26bef9bfd8 100644 --- a/packages/cli/Cargo.toml +++ b/packages/cli/Cargo.toml @@ -69,6 +69,7 @@ cluster-default-update = { path = "../services/cluster/standalone/default-update pegboard-dc-init = { path = "../services/pegboard/standalone/dc-init" } rivet-config = { version = "0.1.0", path = "../common/config" } reqwest = "0.12.9" +admin-default-login = { version = "0.0.1", path = "../services/admin/standalone/default-login" } [dependencies.sqlx] diff --git a/packages/cli/src/run_config.rs b/packages/cli/src/run_config.rs index 9fee1c2ed5..ce0537418f 100644 --- a/packages/cli/src/run_config.rs +++ b/packages/cli/src/run_config.rs @@ -103,9 +103,11 @@ pub fn config(_rivet_config: rivet_config::Config) -> Result { |config, pools| Box::pin(user_delete_pending::start(config, pools)), ), // Oneshot - // Service::new("admin_login", ServiceKind::Oneshot, |config, pools| { - // Box::pin(TODO) - // }), + Service::new( + "admin_default_login", + ServiceKind::Oneshot, + |config, pools| Box::pin(admin_default_login::start(config, pools)), + ), Service::new( "build_default_create", ServiceKind::Oneshot, diff --git a/packages/common/config/src/config/rivet.rs b/packages/common/config/src/config/rivet.rs index 5270dc2712..242396d1dc 100644 --- a/packages/common/config/src/config/rivet.rs +++ b/packages/common/config/src/config/rivet.rs @@ -388,6 +388,8 @@ pub struct Auth { pub access_kind: RivetAccessKind, /// Flag to enable access token login. pub access_token_login: bool, + /// Automatically print a URL to log in to Rivet as admin. + pub print_login_url: bool, } impl Default for Auth { @@ -395,6 +397,7 @@ impl Default for Auth { Self { access_kind: RivetAccessKind::Private, access_token_login: true, + print_login_url: true, } } } diff --git a/packages/services/admin/db/cloud/migrations/20200101000000_init.down.sql b/packages/services/admin/db/cloud/migrations/20200101000000_init.down.sql deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/packages/services/admin/db/cloud/migrations/20200101000000_init.up.sql b/packages/services/admin/db/cloud/migrations/20200101000000_init.up.sql deleted file mode 100644 index c0b6ba98b4..0000000000 --- a/packages/services/admin/db/cloud/migrations/20200101000000_init.up.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE game_configs ( - game_id UUID PRIMARY KEY -- References db-game.games -); - -CREATE TABLE game_namespaces ( - namespace_id UUID PRIMARY KEY -- References db-game.game_namespaces -); - -CREATE TABLE game_versions ( - version_id UUID PRIMARY KEY -- References db-game.game_versions -); diff --git a/packages/services/admin/db/cloud/migrations/20210610125957_enable_domain_auth.down.sql b/packages/services/admin/db/cloud/migrations/20210610125957_enable_domain_auth.down.sql deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/packages/services/admin/db/cloud/migrations/20210610125957_enable_domain_auth.up.sql b/packages/services/admin/db/cloud/migrations/20210610125957_enable_domain_auth.up.sql deleted file mode 100644 index ebe75d0335..0000000000 --- a/packages/services/admin/db/cloud/migrations/20210610125957_enable_domain_auth.up.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE game_namespaces ADD COLUMN enable_domain_public_auth BOOLEAN DEFAULT true; diff --git a/packages/services/admin/db/cloud/migrations/20210618204613_drop_enable_domain_auth.down.sql b/packages/services/admin/db/cloud/migrations/20210618204613_drop_enable_domain_auth.down.sql deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/packages/services/admin/db/cloud/migrations/20210618204613_drop_enable_domain_auth.up.sql b/packages/services/admin/db/cloud/migrations/20210618204613_drop_enable_domain_auth.up.sql deleted file mode 100644 index c815c9fc50..0000000000 --- a/packages/services/admin/db/cloud/migrations/20210618204613_drop_enable_domain_auth.up.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE game_namespaces DROP COLUMN enable_domain_public_auth; diff --git a/packages/services/admin/db/cloud/migrations/20210811032551_game_token_session.down.sql b/packages/services/admin/db/cloud/migrations/20210811032551_game_token_session.down.sql deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/packages/services/admin/db/cloud/migrations/20210811032551_game_token_session.up.sql b/packages/services/admin/db/cloud/migrations/20210811032551_game_token_session.up.sql deleted file mode 100644 index 9e40f13f26..0000000000 --- a/packages/services/admin/db/cloud/migrations/20210811032551_game_token_session.up.sql +++ /dev/null @@ -1,5 +0,0 @@ -CREATE TABLE game_cloud_tokens ( - game_id UUID NOT NULL REFERENCES game_configs (game_id), - token_session_id UUID NOT NULL, -- References db-tokens.sessions - PRIMARY KEY (game_id, token_session_id) -) \ No newline at end of file diff --git a/packages/services/admin/db/cloud/migrations/20210811033143_dev_and_ns_tokens.down.sql b/packages/services/admin/db/cloud/migrations/20210811033143_dev_and_ns_tokens.down.sql deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/packages/services/admin/db/cloud/migrations/20210811033143_dev_and_ns_tokens.up.sql b/packages/services/admin/db/cloud/migrations/20210811033143_dev_and_ns_tokens.up.sql deleted file mode 100644 index 142fdd1b1b..0000000000 --- a/packages/services/admin/db/cloud/migrations/20210811033143_dev_and_ns_tokens.up.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE game_namespace_public_tokens ( - namespace_id UUID NOT NULL REFERENCES game_namespaces (namespace_id), - token_session_id UUID NOT NULL, -- References db-tokens.sessions - PRIMARY KEY (namespace_id, token_session_id) -); - -CREATE TABLE game_namespace_development_tokens ( - namespace_id UUID NOT NULL REFERENCES game_namespaces (namespace_id), - token_session_id UUID NOT NULL, -- References db-tokens.sessions - PRIMARY KEY (namespace_id, token_session_id) -); diff --git a/packages/services/admin/db/cloud/migrations/20231224022033_version_name_reservations.down.sql b/packages/services/admin/db/cloud/migrations/20231224022033_version_name_reservations.down.sql deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/packages/services/admin/db/cloud/migrations/20231224022033_version_name_reservations.up.sql b/packages/services/admin/db/cloud/migrations/20231224022033_version_name_reservations.up.sql deleted file mode 100644 index abde1a4a0a..0000000000 --- a/packages/services/admin/db/cloud/migrations/20231224022033_version_name_reservations.up.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE TABLE game_version_name_reservations ( - game_id UUID NOT NULL, - version_display_name TEXT NOT NULL, - create_ts INT NOT NULL, - PRIMARY KEY (game_id, version_display_name), - INDEX (game_id, version_display_name, create_ts DESC) -); - diff --git a/packages/services/admin/db/cloud/migrations/20240708222624_game_service_token.down.sql b/packages/services/admin/db/cloud/migrations/20240708222624_game_service_token.down.sql deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/packages/services/admin/db/cloud/migrations/20240708222624_game_service_token.up.sql b/packages/services/admin/db/cloud/migrations/20240708222624_game_service_token.up.sql deleted file mode 100644 index 5dbc294999..0000000000 --- a/packages/services/admin/db/cloud/migrations/20240708222624_game_service_token.up.sql +++ /dev/null @@ -1,5 +0,0 @@ -CREATE TABLE service_cloud_tokens ( - game_id UUID NOT NULL REFERENCES game_configs (game_id), - token_session_id UUID NOT NULL, -- References db-tokens.sessions - PRIMARY KEY (game_id, token_session_id) -) \ No newline at end of file diff --git a/packages/services/admin/ops/device-link-create/Cargo.toml b/packages/services/admin/ops/device-link-create/Cargo.toml deleted file mode 100644 index fdbefd2dc5..0000000000 --- a/packages/services/admin/ops/device-link-create/Cargo.toml +++ /dev/null @@ -1,17 +0,0 @@ -[package] -name = "cloud-device-link-create" -version = "0.0.1" -edition = "2021" -authors = ["Rivet Gaming, LLC "] -license = "Apache-2.0" - -[dependencies] -rivet-operation = { path = "../../../../common/operation/core" } -chirp-client = { path = "../../../../common/chirp/client" } -prost = "0.10" - -token-create = { path = "../../../token/ops/create" } - -[dev-dependencies] -chirp-worker = { path = "../../../../common/chirp/worker" } -rivet-claims = { path = "../../../../common/claims" } diff --git a/packages/services/admin/ops/device-link-create/README.md b/packages/services/admin/ops/device-link-create/README.md deleted file mode 100644 index 51b85406cb..0000000000 --- a/packages/services/admin/ops/device-link-create/README.md +++ /dev/null @@ -1 +0,0 @@ -# cloud-device-link-create diff --git a/packages/services/admin/ops/device-link-create/src/lib.rs b/packages/services/admin/ops/device-link-create/src/lib.rs deleted file mode 100644 index e4a410b3ce..0000000000 --- a/packages/services/admin/ops/device-link-create/src/lib.rs +++ /dev/null @@ -1,40 +0,0 @@ -use proto::backend::pkg::*; -use rivet_operation::prelude::*; - -pub const TOKEN_TTL: i64 = util::duration::hours(1); - -#[operation(name = "cloud-device-link-create")] -async fn handle( - ctx: OperationContext, -) -> GlobalResult { - let link_id = Uuid::new_v4(); - - let token_res = op!([ctx] token_create { - issuer: Self::NAME.into(), - token_config: Some(token::create::request::TokenConfig { - ttl: TOKEN_TTL, - }), - refresh_token_config: None, - client: None, - kind: Some(token::create::request::Kind::New(token::create::request::KindNew { - entitlements: vec![ - proto::claims::Entitlement { - kind: Some( - proto::claims::entitlement::Kind::CloudDeviceLink(proto::claims::entitlement::CloudDeviceLink { - device_link_id: Some(link_id.into()), - }) - ) - } - ], - })), - label: Some("device".into()), - ..Default::default() - }) - .await?; - let token = unwrap!(token_res.token); - - Ok(cloud::device_link_create::Response { - device_link_id: Some(link_id.into()), - token: token.token, - }) -} diff --git a/packages/services/admin/ops/device-link-create/tests/integration.rs b/packages/services/admin/ops/device-link-create/tests/integration.rs deleted file mode 100644 index 8be196f4a8..0000000000 --- a/packages/services/admin/ops/device-link-create/tests/integration.rs +++ /dev/null @@ -1,13 +0,0 @@ -use chirp_worker::prelude::*; -use rivet_claims::ClaimsDecode; - -#[worker_test] -async fn basic(ctx: TestCtx) { - let link_res = op!([ctx] cloud_device_link_create {}).await.unwrap(); - let claims = rivet_claims::decode(&ctx.config().server()?.jwt.public, &link_res.token) - .unwrap() - .unwrap(); - tracing::info!(?claims, "claims"); - let ent = claims.as_cloud_device_link().unwrap(); - tracing::info!(?ent, "ent"); -} diff --git a/packages/services/admin/ops/game-config-create/Cargo.toml b/packages/services/admin/ops/game-config-create/Cargo.toml deleted file mode 100644 index 51d8163788..0000000000 --- a/packages/services/admin/ops/game-config-create/Cargo.toml +++ /dev/null @@ -1,19 +0,0 @@ -[package] -name = "cloud-game-config-create" -version = "0.0.1" -edition = "2021" -authors = ["Rivet Gaming, LLC "] -license = "Apache-2.0" - -[dependencies] -rivet-operation = { path = "../../../../common/operation/core" } -chirp-client = { path = "../../../../common/chirp/client" } -prost = "0.10" - -[dependencies.sqlx] -git = "https://github.com/rivet-gg/sqlx" -rev = "e7120f59b74fb6d83ac9b1d899b166bab31ba1d6" -default-features = false - -[dev-dependencies] -chirp-worker = { path = "../../../../common/chirp/worker" } diff --git a/packages/services/admin/ops/game-config-create/src/lib.rs b/packages/services/admin/ops/game-config-create/src/lib.rs deleted file mode 100644 index 06802330c6..0000000000 --- a/packages/services/admin/ops/game-config-create/src/lib.rs +++ /dev/null @@ -1,18 +0,0 @@ -use proto::backend::pkg::*; -use rivet_operation::prelude::*; - -#[operation(name = "cloud-game-config-create")] -async fn handle( - ctx: OperationContext, -) -> GlobalResult { - let game_id = unwrap_ref!(ctx.game_id).as_uuid(); - - sql_execute!( - [ctx] - "INSERT INTO db_cloud.game_configs (game_id) VALUES ($1)", - game_id, - ) - .await?; - - Ok(cloud::game_config_create::Response {}) -} diff --git a/packages/services/admin/ops/game-config-create/tests/integration.rs b/packages/services/admin/ops/game-config-create/tests/integration.rs deleted file mode 100644 index d25f25ea19..0000000000 --- a/packages/services/admin/ops/game-config-create/tests/integration.rs +++ /dev/null @@ -1,18 +0,0 @@ -use chirp_worker::prelude::*; - -#[worker_test] -async fn empty(ctx: TestCtx) { - let game_id = Uuid::new_v4(); - - op!([ctx] cloud_game_config_create { - game_id: Some(game_id.into()), - }) - .await - .unwrap(); - - let (_,): (i64,) = sqlx::query_as("SELECT 1 FROM db_cloud.game_configs WHERE game_id = $1") - .bind(game_id) - .fetch_one(&ctx.crdb().await.unwrap()) - .await - .unwrap(); -} diff --git a/packages/services/admin/ops/game-config-get/Cargo.toml b/packages/services/admin/ops/game-config-get/Cargo.toml deleted file mode 100644 index 70549637d2..0000000000 --- a/packages/services/admin/ops/game-config-get/Cargo.toml +++ /dev/null @@ -1,21 +0,0 @@ -[package] -name = "cloud-game-config-get" -version = "0.0.1" -edition = "2021" -authors = ["Rivet Gaming, LLC "] -license = "Apache-2.0" - -[dependencies] -rivet-operation = { path = "../../../../common/operation/core" } -chirp-client = { path = "../../../../common/chirp/client" } -prost = "0.10" - -[dependencies.sqlx] -git = "https://github.com/rivet-gg/sqlx" -rev = "e7120f59b74fb6d83ac9b1d899b166bab31ba1d6" -default-features = false - -[dev-dependencies] -chirp-worker = { path = "../../../../common/chirp/worker" } - -cloud-game-config-create = { path = "../game-config-create" } diff --git a/packages/services/admin/ops/game-config-get/README.md b/packages/services/admin/ops/game-config-get/README.md deleted file mode 100644 index 22b0cd295c..0000000000 --- a/packages/services/admin/ops/game-config-get/README.md +++ /dev/null @@ -1 +0,0 @@ -# cloud-game-config-get diff --git a/packages/services/admin/ops/game-config-get/src/lib.rs b/packages/services/admin/ops/game-config-get/src/lib.rs deleted file mode 100644 index bf37c3cc04..0000000000 --- a/packages/services/admin/ops/game-config-get/src/lib.rs +++ /dev/null @@ -1,43 +0,0 @@ -use proto::backend::{self, pkg::*}; -use rivet_operation::prelude::*; - -#[derive(sqlx::FromRow)] -struct Game { - game_id: Uuid, - // No important data here, this is a placeholder for things to come -} - -impl From for backend::cloud::Game { - fn from(value: Game) -> Self { - backend::cloud::Game { - game_id: Some(value.game_id.into()), - } - } -} - -#[operation(name = "cloud-game-config-get")] -async fn handle( - ctx: OperationContext, -) -> GlobalResult { - let game_ids = ctx - .game_ids - .iter() - .map(common::Uuid::as_uuid) - .collect::>(); - - let game_configs = sql_fetch_all!( - [ctx, Game] - " - SELECT game_id - FROM db_cloud.game_configs - WHERE game_id = ANY($1) - ", - game_ids, - ) - .await? - .into_iter() - .map(Into::::into) - .collect::>(); - - Ok(cloud::game_config_get::Response { game_configs }) -} diff --git a/packages/services/admin/ops/game-config-get/tests/integration.rs b/packages/services/admin/ops/game-config-get/tests/integration.rs deleted file mode 100644 index 5c87e59604..0000000000 --- a/packages/services/admin/ops/game-config-get/tests/integration.rs +++ /dev/null @@ -1,28 +0,0 @@ -use chirp_worker::prelude::*; - -#[worker_test] -async fn empty(ctx: TestCtx) { - let game_ids = std::iter::repeat_with(Uuid::new_v4) - .take(8) - .collect::>(); - let game_ids_proto = game_ids - .iter() - .cloned() - .map(Into::::into) - .collect::>(); - - for game_id in &game_ids_proto { - op!([ctx] cloud_game_config_create { - game_id: Some(*game_id), - }) - .await - .unwrap(); - } - - let res = op!([ctx] cloud_game_config_get { - game_ids: game_ids_proto.clone(), - }) - .await - .unwrap(); - assert_eq!(8, res.game_configs.len()); -} diff --git a/packages/services/admin/ops/game-token-create/Cargo.toml b/packages/services/admin/ops/game-token-create/Cargo.toml deleted file mode 100644 index 5ed6a8f7e0..0000000000 --- a/packages/services/admin/ops/game-token-create/Cargo.toml +++ /dev/null @@ -1,23 +0,0 @@ -[package] -name = "cloud-game-token-create" -version = "0.0.1" -edition = "2021" -authors = ["Rivet Gaming, LLC "] -license = "Apache-2.0" - -[dependencies] -rivet-operation = { path = "../../../../common/operation/core" } -chirp-client = { path = "../../../../common/chirp/client" } -prost = "0.10" - -token-create = { path = "../../../token/ops/create" } - -[dependencies.sqlx] -git = "https://github.com/rivet-gg/sqlx" -rev = "e7120f59b74fb6d83ac9b1d899b166bab31ba1d6" -default-features = false - -[dev-dependencies] -chirp-worker = { path = "../../../../common/chirp/worker" } - -faker-game = { path = "../../../faker/ops/game" } diff --git a/packages/services/admin/ops/game-token-create/README.md b/packages/services/admin/ops/game-token-create/README.md deleted file mode 100644 index 45fefbb2c7..0000000000 --- a/packages/services/admin/ops/game-token-create/README.md +++ /dev/null @@ -1 +0,0 @@ -# cloud-game-token-create diff --git a/packages/services/admin/ops/game-token-create/src/lib.rs b/packages/services/admin/ops/game-token-create/src/lib.rs deleted file mode 100644 index 0968c03906..0000000000 --- a/packages/services/admin/ops/game-token-create/src/lib.rs +++ /dev/null @@ -1,47 +0,0 @@ -use proto::backend::pkg::*; -use rivet_operation::prelude::*; - -#[operation(name = "cloud-game-token-create")] -async fn handle( - ctx: OperationContext, -) -> GlobalResult { - let game_id = unwrap_ref!(ctx.game_id).as_uuid(); - - let token_res = op!([ctx] token_create { - issuer: Self::NAME.into(), - token_config: Some(token::create::request::TokenConfig { - ttl: util::duration::days(365), - }), - refresh_token_config: None, - client: None, - kind: Some(token::create::request::Kind::New(token::create::request::KindNew { - entitlements: vec![ - proto::claims::Entitlement { - kind: Some( - proto::claims::entitlement::Kind::GameCloud(proto::claims::entitlement::GameCloud { - game_id: Some(game_id.into()) - }) - ) - } - ], - })), - label: Some("cloud".into()), - ..Default::default() - }) - .await?; - - let token = unwrap_ref!(token_res.token); - let token_session_id = unwrap_ref!(token_res.session_id).as_uuid(); - - sql_execute!( - [ctx] - "INSERT INTO db_cloud.game_cloud_tokens (game_id, token_session_id) VALUES ($1, $2)", - game_id, - token_session_id, - ) - .await?; - - Ok(cloud::game_token_create::Response { - token: token.token.clone(), - }) -} diff --git a/packages/services/admin/ops/game-token-create/tests/integration.rs b/packages/services/admin/ops/game-token-create/tests/integration.rs deleted file mode 100644 index 59daa4577a..0000000000 --- a/packages/services/admin/ops/game-token-create/tests/integration.rs +++ /dev/null @@ -1,16 +0,0 @@ -use chirp_worker::prelude::*; - -#[worker_test] -async fn empty(ctx: TestCtx) { - let game_res = op!([ctx] faker_game { - ..Default::default() - }) - .await - .unwrap(); - - op!([ctx] cloud_game_token_create { - game_id: game_res.game_id, - }) - .await - .unwrap(); -} diff --git a/packages/services/admin/ops/namespace-create/Cargo.toml b/packages/services/admin/ops/namespace-create/Cargo.toml deleted file mode 100644 index 7939ffa6a5..0000000000 --- a/packages/services/admin/ops/namespace-create/Cargo.toml +++ /dev/null @@ -1,28 +0,0 @@ -[package] -name = "cloud-namespace-create" -version = "0.0.1" -edition = "2021" -authors = ["Rivet Gaming, LLC "] -license = "Apache-2.0" - -[dependencies] -rivet-operation = { path = "../../../../common/operation/core" } -chirp-client = { path = "../../../../common/chirp/client" } -prost = "0.10" - -game-namespace-get = { path = "../../../game/ops/namespace-get" } -game-get = { path = "../../../game/ops/get" } -cdn-namespace-create = { path = "../../../cdn/ops/namespace-create" } -mm-config-namespace-create = { path = "../../../mm-config/ops/namespace-create" } - -[dependencies.sqlx] -git = "https://github.com/rivet-gg/sqlx" -rev = "e7120f59b74fb6d83ac9b1d899b166bab31ba1d6" -default-features = false - -[dev-dependencies] -chirp-worker = { path = "../../../../common/chirp/worker" } - -faker-game = { path = "../../../faker/ops/game" } -game-namespace-create = { path = "../../../game/ops/namespace-create" } -game-version-create = { path = "../../../game/ops/version-create" } diff --git a/packages/services/admin/ops/namespace-create/README.md b/packages/services/admin/ops/namespace-create/README.md deleted file mode 100644 index 6d46cde3c8..0000000000 --- a/packages/services/admin/ops/namespace-create/README.md +++ /dev/null @@ -1 +0,0 @@ -# cloud-namespace-create diff --git a/packages/services/admin/ops/namespace-create/src/lib.rs b/packages/services/admin/ops/namespace-create/src/lib.rs deleted file mode 100644 index 1626e614ad..0000000000 --- a/packages/services/admin/ops/namespace-create/src/lib.rs +++ /dev/null @@ -1,73 +0,0 @@ -use proto::backend::pkg::*; -use rivet_operation::prelude::*; -use serde_json::json; - -#[operation(name = "cloud-namespace-create")] -async fn handle( - ctx: OperationContext, -) -> GlobalResult { - let namespace_id = unwrap_ref!(ctx.namespace_id).as_uuid(); - - let ns_res = op!([ctx] game_namespace_get { - namespace_ids: vec![namespace_id.into()], - }) - .await?; - let ns = unwrap!( - ns_res.namespaces.first(), - "game namespace not found for cloud namespace" - ); - let game_id = unwrap_ref!(ns.game_id).as_uuid(); - - let game_res = op!([ctx] game_get { - game_ids: vec![game_id.into()], - }) - .await?; - let game = unwrap!(game_res.games.first()); - let developer_team_id = unwrap_ref!(game.developer_team_id).as_uuid(); - - tokio::try_join!( - op!([ctx] cdn_namespace_create { - namespace_id: Some(namespace_id.into()), - }), - op!([ctx] mm_config_namespace_create { - namespace_id: Some(namespace_id.into()), - }), - )?; - - sql_execute!( - [ctx] - " - INSERT INTO db_cloud.game_namespaces (namespace_id) - VALUES ($1) - ", - namespace_id, - ) - .await?; - - // Send game update - msg!([ctx] game::msg::update(game_id) { - game_id: Some(game_id.into()), - }) - .await?; - - msg!([ctx] analytics::msg::event_create() { - events: vec![ - analytics::msg::event_create::Event { - event_id: Some(Uuid::new_v4().into()), - name: "game.namespace.create".into(), - user_id: ctx.creator_user_id, - properties_json: Some(serde_json::to_string(&json!({ - "developer_team_id": developer_team_id, - "game_id": game_id, - "namespace_id": namespace_id, - "display_name": ns.display_name, - "name_id": ns.name_id, - }))?), - ..Default::default() - } - ], - }) - .await?; - - Ok(cloud::namespace_create::Response {}) -} diff --git a/packages/services/admin/ops/namespace-create/tests/integration.rs b/packages/services/admin/ops/namespace-create/tests/integration.rs deleted file mode 100644 index 839dc92016..0000000000 --- a/packages/services/admin/ops/namespace-create/tests/integration.rs +++ /dev/null @@ -1,40 +0,0 @@ -use chirp_worker::prelude::*; - -#[worker_test] -async fn empty(ctx: TestCtx) { - let game_create_res = op!([ctx] faker_game { - ..Default::default() - }) - .await - .unwrap(); - - let version_create_res = op!([ctx] game_version_create { - game_id: game_create_res.game_id, - display_name: util::faker::ident(), - }) - .await - .unwrap(); - - let res = op!([ctx] game_namespace_create { - game_id: game_create_res.game_id, - display_name: util::faker::display_name(), - version_id: version_create_res.version_id, - name_id: util::faker::ident(), - }) - .await - .unwrap(); - let namespace_id = res.namespace_id.unwrap().as_uuid(); - - op!([ctx] cloud_namespace_create { - namespace_id: Some(namespace_id.into()), - }) - .await - .unwrap(); - - let (_,): (i64,) = - sqlx::query_as("SELECT 1 FROM db_cloud.game_namespaces WHERE namespace_id = $1") - .bind(namespace_id) - .fetch_one(&ctx.crdb().await.unwrap()) - .await - .unwrap(); -} diff --git a/packages/services/admin/ops/namespace-get/Cargo.toml b/packages/services/admin/ops/namespace-get/Cargo.toml deleted file mode 100644 index 706542889f..0000000000 --- a/packages/services/admin/ops/namespace-get/Cargo.toml +++ /dev/null @@ -1,27 +0,0 @@ -[package] -name = "cloud-namespace-get" -version = "0.0.1" -edition = "2021" -authors = ["Rivet Gaming, LLC "] -license = "Apache-2.0" - -[dependencies] -rivet-operation = { path = "../../../../common/operation/core" } -chirp-client = { path = "../../../../common/chirp/client" } -prost = "0.10" - -cdn-namespace-get = { path = "../../../cdn/ops/namespace-get" } -mm-config-namespace-get = { path = "../../../mm-config/ops/namespace-get" } - -[dependencies.sqlx] -git = "https://github.com/rivet-gg/sqlx" -rev = "e7120f59b74fb6d83ac9b1d899b166bab31ba1d6" -default-features = false - -[dev-dependencies] -chirp-worker = { path = "../../../../common/chirp/worker" } - -cloud-namespace-create = { path = "../namespace-create" } -faker-game = { path = "../../../faker/ops/game" } -game-namespace-create = { path = "../../../game/ops/namespace-create" } -game-version-create = { path = "../../../game/ops/version-create" } diff --git a/packages/services/admin/ops/namespace-get/README.md b/packages/services/admin/ops/namespace-get/README.md deleted file mode 100644 index ec18956c8a..0000000000 --- a/packages/services/admin/ops/namespace-get/README.md +++ /dev/null @@ -1 +0,0 @@ -# cloud-namespace-get diff --git a/packages/services/admin/ops/namespace-get/src/lib.rs b/packages/services/admin/ops/namespace-get/src/lib.rs deleted file mode 100644 index 6ef4d38296..0000000000 --- a/packages/services/admin/ops/namespace-get/src/lib.rs +++ /dev/null @@ -1,86 +0,0 @@ -use proto::backend::{self, pkg::*}; -use rivet_operation::prelude::*; - -#[derive(sqlx::FromRow)] -struct GameNamespace { - namespace_id: Uuid, - // No important data here, this is a placeholder for things to come -} - -#[operation(name = "cloud-namespace-get")] -async fn handle( - ctx: OperationContext, -) -> GlobalResult { - let namespace_ids = ctx - .namespace_ids - .iter() - .map(common::Uuid::as_uuid) - .collect::>(); - - let cloud_namespaces = sql_fetch_all!( - [ctx, GameNamespace] - " - SELECT namespace_id - FROM db_cloud.game_namespaces - WHERE namespace_id = ANY($1) - ", - namespace_ids, - ) - .await?; - - let all_namespace_ids_proto = cloud_namespaces - .iter() - .map(|c| c.namespace_id) - .map(common::Uuid::from) - .collect::>(); - - // Fetch all dependent configs - let (cdn_configs_res, mm_configs_res) = tokio::try_join!( - op!([ctx] cdn_namespace_get { - namespace_ids: all_namespace_ids_proto.clone(), - }), - op!([ctx] mm_config_namespace_get { - namespace_ids: all_namespace_ids_proto.clone(), - }), - )?; - - let namespaces = cloud_namespaces - .iter() - .filter_map(|cloud_namespace| { - let namespace_id_proto = common::Uuid::from(cloud_namespace.namespace_id); - Some(backend::cloud::GameNamespace { - namespace_id: Some(namespace_id_proto), - config: Some(backend::cloud::NamespaceConfig { - cdn: if let Some(x) = cdn_configs_res - .namespaces - .iter() - .find(|cdn_namespace| { - cdn_namespace.namespace_id.as_ref() == Some(&namespace_id_proto) - }) - .map(|v| v.config.clone().unwrap()) - { - Some(x) - } else { - tracing::warn!(namespace_id = %cloud_namespace.namespace_id, "missing cdn for ns"); - return None; - }, - matchmaker: if let Some(x) = mm_configs_res - .namespaces - .iter() - .find(|mm_namespace| { - mm_namespace.namespace_id.as_ref() == Some(&namespace_id_proto) - }) - .map(|v| v.config.clone().unwrap()) - { - Some(x) - } else { - tracing::warn!(namespace_id = %cloud_namespace.namespace_id, "missing mm for ns"); - return None; - }, - }), - }) - }) - .collect::>(); - - Ok(cloud::namespace_get::Response { namespaces }) -} diff --git a/packages/services/admin/ops/namespace-get/tests/integration.rs b/packages/services/admin/ops/namespace-get/tests/integration.rs deleted file mode 100644 index 381464be20..0000000000 --- a/packages/services/admin/ops/namespace-get/tests/integration.rs +++ /dev/null @@ -1,42 +0,0 @@ -use chirp_worker::prelude::*; - -#[worker_test] -async fn empty(ctx: TestCtx) { - let game_create_res = op!([ctx] faker_game { - ..Default::default() - }) - .await - .unwrap(); - - let version_create_res = op!([ctx] game_version_create { - game_id: game_create_res.game_id, - display_name: util::faker::ident(), - }) - .await - .unwrap(); - - let res = op!([ctx] game_namespace_create { - game_id: game_create_res.game_id, - display_name: util::faker::display_name(), - version_id: version_create_res.version_id, - name_id: util::faker::ident(), - }) - .await - .unwrap(); - let namespace_id = res.namespace_id.unwrap().as_uuid(); - - op!([ctx] cloud_namespace_create { - namespace_id: Some(namespace_id.into()), - }) - .await - .unwrap(); - - let res = op!([ctx] cloud_namespace_get { - namespace_ids: vec![namespace_id.into(), Uuid::new_v4().into()], - }) - .await - .unwrap(); - - assert_eq!(1, res.namespaces.len()); - let _namespace_res = res.namespaces.first().expect("namespace not returned"); -} diff --git a/packages/services/admin/ops/namespace-token-development-create/Cargo.toml b/packages/services/admin/ops/namespace-token-development-create/Cargo.toml deleted file mode 100644 index 0de0ac2475..0000000000 --- a/packages/services/admin/ops/namespace-token-development-create/Cargo.toml +++ /dev/null @@ -1,25 +0,0 @@ -[package] -name = "cloud-namespace-token-development-create" -version = "0.0.1" -edition = "2021" -authors = ["Rivet Gaming, LLC "] -license = "Apache-2.0" - -[dependencies] -rivet-operation = { path = "../../../../common/operation/core" } -chirp-client = { path = "../../../../common/chirp/client" } -prost = "0.10" - -game-namespace-get = { path = "../../../game/ops/namespace-get" } -game-token-development-validate = { path = "../../../game/ops/token-development-validate" } -token-create = { path = "../../../token/ops/create" } - -[dependencies.sqlx] -git = "https://github.com/rivet-gg/sqlx" -rev = "e7120f59b74fb6d83ac9b1d899b166bab31ba1d6" -default-features = false - -[dev-dependencies] -chirp-worker = { path = "../../../../common/chirp/worker" } - -faker-game = { path = "../../../faker/ops/game" } diff --git a/packages/services/admin/ops/namespace-token-development-create/README.md b/packages/services/admin/ops/namespace-token-development-create/README.md deleted file mode 100644 index 271e3b041f..0000000000 --- a/packages/services/admin/ops/namespace-token-development-create/README.md +++ /dev/null @@ -1 +0,0 @@ -# cloud-namespace-token-development-create diff --git a/packages/services/admin/ops/namespace-token-development-create/src/lib.rs b/packages/services/admin/ops/namespace-token-development-create/src/lib.rs deleted file mode 100644 index 7d8493a0c1..0000000000 --- a/packages/services/admin/ops/namespace-token-development-create/src/lib.rs +++ /dev/null @@ -1,77 +0,0 @@ -use proto::backend::pkg::*; -use rivet_operation::prelude::*; - -#[operation(name = "cloud-namespace-token-development-create")] -async fn handle( - ctx: OperationContext, -) -> GlobalResult { - let namespace_id = unwrap_ref!(ctx.namespace_id).as_uuid(); - - // Validate token - let validation_res = op!([ctx] game_token_development_validate { - hostname: ctx.hostname.to_owned(), - lobby_ports: ctx.lobby_ports.clone() - }) - .await?; - if !validation_res.errors.is_empty() { - tracing::warn!(errors = ?validation_res.errors, "validation errors"); - - let readable_errors = validation_res - .errors - .iter() - .map(|err| err.path.join(".")) - .collect::>() - .join(", "); - bail_with!(VALIDATION_ERROR, error = readable_errors); - } - - let ns_res = op!([ctx] game_namespace_get { - namespace_ids: vec![namespace_id.into()], - }) - .await?; - let ns_data = ns_res.namespaces.first(); - let ns_data = unwrap_ref!(ns_data, "namespace not found"); - - let token_res = op!([ctx] token_create { - issuer: Self::NAME.into(), - token_config: Some(token::create::request::TokenConfig { - ttl: util::duration::days(365), - }), - refresh_token_config: None, - client: None, - kind: Some(token::create::request::Kind::New(token::create::request::KindNew { - entitlements: vec![ - proto::claims::Entitlement { - kind: Some( - proto::claims::entitlement::Kind::GameNamespaceDevelopment(proto::claims::entitlement::GameNamespaceDevelopment { - namespace_id: Some(namespace_id.into()), - hostname: ctx.hostname.to_owned(), - lobby_ports: ctx.lobby_ports.clone(), - }) - ) - } - ], - })), - label: Some(format!("dev_{}", ns_data.name_id.replace('-', "_"))), - ..Default::default() - }) - .await?; - - let token = unwrap_ref!(token_res.token); - let token_session_id = unwrap_ref!(token_res.session_id).as_uuid(); - - sql_execute!( - [ctx] - " - INSERT INTO db_cloud.game_namespace_development_tokens (namespace_id, token_session_id) - VALUES ($1, $2) - ", - namespace_id, - token_session_id, - ) - .await?; - - Ok(cloud::namespace_token_development_create::Response { - token: token.token.clone(), - }) -} diff --git a/packages/services/admin/ops/namespace-token-development-create/tests/integration.rs b/packages/services/admin/ops/namespace-token-development-create/tests/integration.rs deleted file mode 100644 index a795dd1724..0000000000 --- a/packages/services/admin/ops/namespace-token-development-create/tests/integration.rs +++ /dev/null @@ -1,26 +0,0 @@ -use chirp_worker::prelude::*; -use proto::backend; - -#[worker_test] -async fn empty(ctx: TestCtx) { - let game_res = op!([ctx] faker_game { - ..Default::default() - }) - .await - .unwrap(); - let namespace_id = game_res.namespace_ids.first().unwrap(); - - op!([ctx] cloud_namespace_token_development_create { - namespace_id: Some(*namespace_id), - hostname: "hostname".to_owned(), - lobby_ports: vec![backend::matchmaker::lobby_runtime::Port { - label: "test".into(), - target_port: Some(80), - port_range: None, - proxy_protocol: backend::matchmaker::lobby_runtime::ProxyProtocol::Https as i32, - proxy_kind: backend::matchmaker::lobby_runtime::ProxyKind::GameGuard as i32, - }], - }) - .await - .unwrap(); -} diff --git a/packages/services/admin/ops/namespace-token-public-create/Cargo.toml b/packages/services/admin/ops/namespace-token-public-create/Cargo.toml deleted file mode 100644 index f239ce64e3..0000000000 --- a/packages/services/admin/ops/namespace-token-public-create/Cargo.toml +++ /dev/null @@ -1,25 +0,0 @@ -[package] -name = "cloud-namespace-token-public-create" -version = "0.0.1" -edition = "2021" -authors = ["Rivet Gaming, LLC "] -license = "Apache-2.0" - -[dependencies] -rivet-operation = { path = "../../../../common/operation/core" } -chirp-client = { path = "../../../../common/chirp/client" } -rivet-claims = { path = "../../../../common/claims" } -prost = "0.10" - -game-namespace-get = { path = "../../../game/ops/namespace-get" } -token-create = { path = "../../../token/ops/create" } - -[dependencies.sqlx] -git = "https://github.com/rivet-gg/sqlx" -rev = "e7120f59b74fb6d83ac9b1d899b166bab31ba1d6" -default-features = false - -[dev-dependencies] -chirp-worker = { path = "../../../../common/chirp/worker" } - -faker-game = { path = "../../../faker/ops/game" } diff --git a/packages/services/admin/ops/namespace-token-public-create/README.md b/packages/services/admin/ops/namespace-token-public-create/README.md deleted file mode 100644 index 565388e04d..0000000000 --- a/packages/services/admin/ops/namespace-token-public-create/README.md +++ /dev/null @@ -1 +0,0 @@ -# cloud-namespace-token-public-create diff --git a/packages/services/admin/ops/namespace-token-public-create/src/lib.rs b/packages/services/admin/ops/namespace-token-public-create/src/lib.rs deleted file mode 100644 index 97c425a27c..0000000000 --- a/packages/services/admin/ops/namespace-token-public-create/src/lib.rs +++ /dev/null @@ -1,58 +0,0 @@ -use proto::backend::pkg::*; -use rivet_operation::prelude::*; - -#[operation(name = "cloud-namespace-token-public-create")] -async fn handle( - ctx: OperationContext, -) -> GlobalResult { - let namespace_id = unwrap_ref!(ctx.namespace_id).as_uuid(); - - let ns_res = op!([ctx] game_namespace_get { - namespace_ids: vec![namespace_id.into()], - }) - .await?; - let ns_data = ns_res.namespaces.first(); - let ns_data = unwrap_ref!(ns_data, "namespace not found"); - - let token_res = op!([ctx] token_create { - issuer: Self::NAME.into(), - token_config: Some(token::create::request::TokenConfig { - // Make these tokens not expire - ttl: util::duration::days(365 * 15), - }), - refresh_token_config: None, - client: None, - kind: Some(token::create::request::Kind::New(token::create::request::KindNew { - entitlements: vec![ - proto::claims::Entitlement { - kind: Some( - proto::claims::entitlement::Kind::GameNamespacePublic(proto::claims::entitlement::GameNamespacePublic { - namespace_id: Some(namespace_id.into()) - }) - ) - } - ], - })), - label: Some(format!("pub_{}", ns_data.name_id.replace('-', "_"))), - ..Default::default() - }) - .await?; - - let token = unwrap_ref!(token_res.token); - let token_session_id = unwrap_ref!(token_res.session_id).as_uuid(); - - sql_execute!( - [ctx] - " - INSERT INTO db_cloud.game_namespace_public_tokens (namespace_id, token_session_id) - VALUES ($1, $2) - ", - namespace_id, - token_session_id, - ) - .await?; - - Ok(cloud::namespace_token_public_create::Response { - token: token.token.clone(), - }) -} diff --git a/packages/services/admin/ops/namespace-token-public-create/tests/integration.rs b/packages/services/admin/ops/namespace-token-public-create/tests/integration.rs deleted file mode 100644 index 8df9ab6a92..0000000000 --- a/packages/services/admin/ops/namespace-token-public-create/tests/integration.rs +++ /dev/null @@ -1,17 +0,0 @@ -use chirp_worker::prelude::*; - -#[worker_test] -async fn empty(ctx: TestCtx) { - let game_res = op!([ctx] faker_game { - ..Default::default() - }) - .await - .unwrap(); - let namespace_id = game_res.namespace_ids.first().unwrap(); - - op!([ctx] cloud_namespace_token_public_create { - namespace_id: Some(*namespace_id), - }) - .await - .unwrap(); -} diff --git a/packages/services/admin/ops/version-get/Cargo.toml b/packages/services/admin/ops/version-get/Cargo.toml deleted file mode 100644 index a2403ffc25..0000000000 --- a/packages/services/admin/ops/version-get/Cargo.toml +++ /dev/null @@ -1,28 +0,0 @@ -[package] -name = "cloud-version-get" -version = "0.0.1" -edition = "2021" -authors = ["Rivet Gaming, LLC "] -license = "Apache-2.0" - -[dependencies] -rivet-operation = { path = "../../../../common/operation/core" } -chirp-client = { path = "../../../../common/chirp/client" } -prost = "0.10" -util-mm = { package = "rivet-util-mm", path = "../../../mm/util" } - -cdn-version-get = { path = "../../../cdn/ops/version-get" } -mm-config-version-get = { path = "../../../mm-config/ops/version-get" } - -[dependencies.sqlx] -git = "https://github.com/rivet-gg/sqlx" -rev = "e7120f59b74fb6d83ac9b1d899b166bab31ba1d6" -default-features = false - -[dev-dependencies] -chirp-worker = { path = "../../../../common/chirp/worker" } - -faker-build = { path = "../../../faker/ops/build" } -faker-game = { path = "../../../faker/ops/game" } -faker-region = { path = "../../../faker/ops/region" } -cloud-version-publish = { path = "../version-publish" } diff --git a/packages/services/admin/ops/version-get/README.md b/packages/services/admin/ops/version-get/README.md deleted file mode 100644 index e09ca72ee1..0000000000 --- a/packages/services/admin/ops/version-get/README.md +++ /dev/null @@ -1 +0,0 @@ -# cloud-version-get diff --git a/packages/services/admin/ops/version-get/src/lib.rs b/packages/services/admin/ops/version-get/src/lib.rs deleted file mode 100644 index ee3825d195..0000000000 --- a/packages/services/admin/ops/version-get/src/lib.rs +++ /dev/null @@ -1,76 +0,0 @@ -use proto::backend::{self, pkg::*}; -use rivet_operation::prelude::*; - -#[derive(sqlx::FromRow)] -struct GameVersion { - version_id: Uuid, - // No important data here, this is a placeholder for things to come -} - -#[operation(name = "cloud-version-get")] -async fn handle( - ctx: OperationContext, -) -> GlobalResult { - let req_version_ids = ctx - .version_ids - .iter() - .map(common::Uuid::as_uuid) - .collect::>(); - - let cloud_versions = sql_fetch_all!( - [ctx, GameVersion] - " - SELECT version_id - FROM db_cloud.game_versions - WHERE version_id = ANY($1) - ", - req_version_ids, - ) - .await?; - - // Get all version IDs that exist. If a row doesn't exist in `game_configs`, then this version - // is ignored. - let all_version_ids_proto = cloud_versions - .iter() - .map(|c| c.version_id) - .map(common::Uuid::from) - .collect::>(); - - // Fetch all dependent configs - let (cdn_configs_res, mm_configs_res) = tokio::try_join!( - op!([ctx] cdn_version_get { - version_ids: all_version_ids_proto.clone(), - }), - op!([ctx] mm_config_version_get { - version_ids: all_version_ids_proto.clone(), - }), - )?; - - let versions = cloud_versions - .iter() - .map(|cloud_version| { - let version_id_proto = common::Uuid::from(cloud_version.version_id); - backend::cloud::GameVersion { - version_id: Some(version_id_proto), - config: Some(backend::cloud::VersionConfig { - cdn: cdn_configs_res - .versions - .iter() - .find(|cdn_version| { - cdn_version.version_id.as_ref() == Some(&version_id_proto) - }) - .map(|v| v.config.clone().unwrap()), - matchmaker: mm_configs_res - .versions - .iter() - .find(|mm_version| { - mm_version.version_id.as_ref() == Some(&version_id_proto) - }) - .map(|v| v.config.clone().unwrap()), - }), - } - }) - .collect::>(); - - Ok(cloud::version_get::Response { versions }) -} diff --git a/packages/services/admin/ops/version-get/tests/integration.rs b/packages/services/admin/ops/version-get/tests/integration.rs deleted file mode 100644 index 6886541bea..0000000000 --- a/packages/services/admin/ops/version-get/tests/integration.rs +++ /dev/null @@ -1,89 +0,0 @@ -use chirp_worker::prelude::*; -use proto::backend::{self}; - -#[worker_test] -async fn empty(ctx: TestCtx) { - let region_res = op!([ctx] faker_region {}).await.unwrap(); - - let game_res = op!([ctx] faker_game { - ..Default::default() - }) - .await - .unwrap(); - - let build_res = op!([ctx] faker_build { - game_id: game_res.game_id, - image: backend::faker::Image::MmLobbyAutoReady as i32, - }) - .await - .unwrap(); - - let version_publish_res = op!([ctx] cloud_version_publish { - game_id: game_res.game_id, - display_name: "0.0.1".into(), - config: Some(backend::cloud::VersionConfig { - cdn: None, - matchmaker: Some(backend::matchmaker::VersionConfig { - lobby_groups: vec![ - backend::matchmaker::LobbyGroup { - name_id: "test".into(), - - regions: vec![ - backend::matchmaker::lobby_group::Region { - region_id: region_res.region_id, - tier_name_id: util_mm::test::TIER_NAME_ID.to_owned(), - idle_lobbies: None, - }, - ], - max_players_normal: 8, - max_players_direct: 10, - max_players_party: 12, - listable: true, - taggable: false, - allow_dynamic_max_players: false, - - runtime: Some(backend::matchmaker::lobby_runtime::Docker { - build_id: build_res.build_id, - args: Vec::new(), - env_vars: vec![ - backend::matchmaker::lobby_runtime::EnvVar { - key: "HELLO".into(), - value: "world".into(), - }, - ], - network_mode: backend::matchmaker::lobby_runtime::NetworkMode::Bridge as i32, - ports: vec![ - backend::matchmaker::lobby_runtime::Port { - label: "1234".into(), - target_port: Some(1234), - port_range: None, - proxy_protocol: backend::matchmaker::lobby_runtime::ProxyProtocol::Https as i32, - proxy_kind: backend::matchmaker::lobby_runtime::ProxyKind::GameGuard as i32, - }, - ], - }.into()), - - actions: None, - }, - ], - captcha: None, - }), - }) - }) - .await - .unwrap(); - let version_id = version_publish_res.version_id.as_ref().unwrap().as_uuid(); - - let res = op!([ctx] cloud_version_get { - version_ids: vec![version_id.into()], - }) - .await - .unwrap(); - - let version_res = res.versions.first().expect("version not returned"); - let version_res_config = version_res.config.as_ref().unwrap(); - version_res_config - .matchmaker - .as_ref() - .expect("mm config not set"); -} diff --git a/packages/services/admin/ops/version-publish/Cargo.toml b/packages/services/admin/ops/version-publish/Cargo.toml deleted file mode 100644 index 93a56b8021..0000000000 --- a/packages/services/admin/ops/version-publish/Cargo.toml +++ /dev/null @@ -1,32 +0,0 @@ -[package] -name = "cloud-version-publish" -version = "0.0.1" -edition = "2021" -authors = ["Rivet Gaming, LLC "] -license = "Apache-2.0" - -[dependencies] -rivet-operation = { path = "../../../../common/operation/core" } -chirp-client = { path = "../../../../common/chirp/client" } -prost = "0.10" - -cdn-version-prepare = { path = "../../../cdn/ops/version-prepare" } -cdn-version-publish = { path = "../../../cdn/ops/version-publish" } -game-get = { path = "../../../game/ops/get" } -game-version-create = { path = "../../../game/ops/version-create" } -game-version-validate = { path = "../../../game/ops/version-validate" } -mm-config-version-prepare = { path = "../../../mm-config/ops/version-prepare" } -mm-config-version-publish = { path = "../../../mm-config/ops/version-publish" } - -[dependencies.sqlx] -git = "https://github.com/rivet-gg/sqlx" -rev = "e7120f59b74fb6d83ac9b1d899b166bab31ba1d6" -default-features = false - -[dev-dependencies] -chirp-worker = { path = "../../../../common/chirp/worker" } -util-mm = { package = "rivet-util-mm", path = "../../../mm/util" } - -faker-build = { path = "../../../faker/ops/build" } -faker-game = { path = "../../../faker/ops/game" } -region-list = { path = "../../../region/ops/list" } diff --git a/packages/services/admin/ops/version-publish/README.md b/packages/services/admin/ops/version-publish/README.md deleted file mode 100644 index 0afc1c98b2..0000000000 --- a/packages/services/admin/ops/version-publish/README.md +++ /dev/null @@ -1,20 +0,0 @@ -# cloud-version-publish - -This service does three main things: - -1. Produce the metadata for the given config for each cloud service. This will also validate that the config - is valid and return an error if something is wrong. - - It is the responsibility of the client to manually validate configs at the moment. Invalid configs should - be considered internal errors that the client did not catch before sending the request. -2. Create a new game version. -3. Publish each cloud service's config corresponding with the game version. - -## Prepare step - -This should not write anything to the database pertaining to this version. This should only allocate the -appropriate resources in order to create the version. This should function as if the public function may never -be called. - -## Publish step - -- This should write the new version configs to the database. diff --git a/packages/services/admin/ops/version-publish/src/lib.rs b/packages/services/admin/ops/version-publish/src/lib.rs deleted file mode 100644 index 91a425ac5a..0000000000 --- a/packages/services/admin/ops/version-publish/src/lib.rs +++ /dev/null @@ -1,131 +0,0 @@ -use proto::backend::pkg::*; -use rivet_operation::prelude::*; -use serde_json::json; - -#[operation(name = "cloud-version-publish")] -async fn handle( - ctx: OperationContext, -) -> GlobalResult { - let req_game_id = unwrap_ref!(ctx.game_id); - let game_id = req_game_id.as_uuid(); - let config = unwrap_ref!(ctx.config); - - let game_res = op!([ctx] game_get { - game_ids: vec![game_id.into()], - }) - .await?; - let game = unwrap!(game_res.games.first()); - let developer_team_id = unwrap_ref!(game.developer_team_id).as_uuid(); - - // Validate version - let validation_res = op!([ctx] game_version_validate { - game_id: Some(*req_game_id), - display_name: ctx.display_name.to_owned(), - config: Some(config.clone()) - }) - .await?; - if !validation_res.errors.is_empty() { - tracing::warn!(errors = ?validation_res.errors, "validation errors"); - - let readable_errors = validation_res - .errors - .iter() - .map(|err| err.path.join(".")) - .collect::>() - .join(", "); - bail_with!(VALIDATION_ERROR, error = readable_errors); - } - - // Prepare the version - let cdn_config_ctx = if let Some(cdn_config) = &config.cdn { - let prepare_res = op!([ctx] cdn_version_prepare { - game_id: Some(game_id.into()), - config: Some(cdn_config.clone()), - }) - .await?; - - Some(unwrap_ref!(prepare_res.config_ctx).clone()) - } else { - None - }; - let mm_config_ctx = if let Some(mm_config) = &config.matchmaker { - let prepare_res = op!([ctx] mm_config_version_prepare { - game_id: Some(game_id.into()), - config: Some(mm_config.clone()), - }) - .await?; - - Some(unwrap_ref!(prepare_res.config_ctx).clone()) - } else { - None - }; - - // Create the game version - let version_create_res = op!([ctx] game_version_create { - game_id: Some(game_id.into()), - display_name: ctx.display_name.clone(), - }) - .await?; - let version_id = unwrap_ref!(version_create_res.version_id).as_uuid(); - - // Create the cloud version - sql_execute!( - [ctx] - " - INSERT INTO db_cloud.game_versions (version_id) - VALUES ($1) - ", - version_id, - ) - .await?; - - // Create the cloud versions - if let (Some(cdn_config), Some(cdn_config_ctx)) = (&config.cdn, &cdn_config_ctx) { - op!([ctx] cdn_version_publish { - version_id: Some(version_id.into()), - config: Some(cdn_config.clone()), - config_ctx: Some((*cdn_config_ctx).clone()), - }) - .await?; - } - if let (Some(mm_config), Some(mm_config_ctx)) = (&config.matchmaker, &mm_config_ctx) { - op!([ctx] mm_config_version_publish { - version_id: Some(version_id.into()), - config: Some(mm_config.clone()), - config_ctx: Some((*mm_config_ctx).clone()), - }) - .await?; - } - - // Send game update - { - msg!([ctx] game::msg::update(game_id) { - game_id: ctx.game_id, - }) - .await?; - } - - msg!([ctx] analytics::msg::event_create() { - events: vec![ - analytics::msg::event_create::Event { - event_id: Some(Uuid::new_v4().into()), - name: "game.version.publish".into(), - user_id: ctx.creator_user_id, - properties_json: Some(serde_json::to_string(&json!({ - "developer_team_id": developer_team_id, - "game_id": game_id, - "version_id": version_id, - "game_id": game_id, - "developer_team_id": developer_team_id, - "display_name": ctx.display_name, - }))?), - ..Default::default() - } - ], - }) - .await?; - - Ok(cloud::version_publish::Response { - version_id: Some(version_id.into()), - }) -} diff --git a/packages/services/admin/ops/version-publish/tests/integration.rs b/packages/services/admin/ops/version-publish/tests/integration.rs deleted file mode 100644 index 90773fb185..0000000000 --- a/packages/services/admin/ops/version-publish/tests/integration.rs +++ /dev/null @@ -1,84 +0,0 @@ -use chirp_worker::prelude::*; -use proto::backend::{self}; - -#[worker_test] -async fn empty(ctx: TestCtx) { - let region_list_res = op!([ctx] region_list { - ..Default::default() - }) - .await - .unwrap(); - - let game_res = op!([ctx] faker_game { - ..Default::default() - }) - .await - .unwrap(); - - let build_res = op!([ctx] faker_build { - game_id: game_res.game_id, - image: backend::faker::Image::MmLobbyAutoReady as i32, - }) - .await - .unwrap(); - - let _res = op!([ctx] cloud_version_publish { - game_id: game_res.game_id, - display_name: "0.0.1".into(), - config: Some(backend::cloud::VersionConfig { - cdn: None, - matchmaker: Some(backend::matchmaker::VersionConfig { - lobby_groups: vec![ - backend::matchmaker::LobbyGroup { - name_id: "test".into(), - - regions: region_list_res - .region_ids - .iter() - .cloned() - .map(|region_id| backend::matchmaker::lobby_group::Region { - region_id: Some(region_id), - tier_name_id: util_mm::test::TIER_NAME_ID.to_owned(), - idle_lobbies: None, - }) - .collect(), - max_players_normal: 8, - max_players_direct: 10, - max_players_party: 12, - listable: true, - taggable: false, - allow_dynamic_max_players: false, - - runtime: Some(backend::matchmaker::lobby_runtime::Docker { - build_id: build_res.build_id, - args: Vec::new(), - env_vars: vec![ - backend::matchmaker::lobby_runtime::EnvVar { - key: "HELLo".into(), - value: "world".into(), - }, - ], - network_mode: backend::matchmaker::lobby_runtime::NetworkMode::Bridge as i32, - ports: vec![ - backend::matchmaker::lobby_runtime::Port { - label: "1234".into(), - target_port: Some(1234), - port_range: None, - proxy_protocol: backend::matchmaker::lobby_runtime::ProxyProtocol::Https as i32, - proxy_kind: backend::matchmaker::lobby_runtime::ProxyKind::GameGuard as i32, - }, - ], - }.into()), - - actions: None, - }, - ], - captcha: None, - }), - }) - }) - .await - .unwrap(); - - // TODO: Validate state -} diff --git a/packages/services/admin/proto/device-link-create.proto b/packages/services/admin/proto/device-link-create.proto deleted file mode 100644 index b0c6c472c8..0000000000 --- a/packages/services/admin/proto/device-link-create.proto +++ /dev/null @@ -1,14 +0,0 @@ -syntax = "proto3"; - -package rivet.backend.pkg.cloud.device_link_create; - -import "resources/legacy/proto/common.proto"; - -message Request { - -} - -message Response { - rivet.common.Uuid device_link_id = 1; - string token = 2; -} diff --git a/packages/services/admin/proto/game-config-create.proto b/packages/services/admin/proto/game-config-create.proto deleted file mode 100644 index 85589fbf60..0000000000 --- a/packages/services/admin/proto/game-config-create.proto +++ /dev/null @@ -1,13 +0,0 @@ -syntax = "proto3"; - -package rivet.backend.pkg.cloud.game_config_create; - -import "resources/legacy/proto/common.proto"; - -message Request { - rivet.common.Uuid game_id = 1; -} - -message Response { - -} diff --git a/packages/services/admin/proto/game-config-get.proto b/packages/services/admin/proto/game-config-get.proto deleted file mode 100644 index 8db37984e2..0000000000 --- a/packages/services/admin/proto/game-config-get.proto +++ /dev/null @@ -1,14 +0,0 @@ -syntax = "proto3"; - -package rivet.backend.pkg.cloud.game_config_get; - -import "resources/legacy/proto/common.proto"; -import "resources/legacy/proto/backend/cloud.proto"; - -message Request { - repeated rivet.common.Uuid game_ids = 1; -} - -message Response { - repeated rivet.backend.cloud.Game game_configs = 1; -} diff --git a/packages/services/admin/proto/game-token-create.proto b/packages/services/admin/proto/game-token-create.proto deleted file mode 100644 index 461c7197c1..0000000000 --- a/packages/services/admin/proto/game-token-create.proto +++ /dev/null @@ -1,13 +0,0 @@ -syntax = "proto3"; - -package rivet.backend.pkg.cloud.game_token_create; - -import "resources/legacy/proto/common.proto"; - -message Request { - rivet.common.Uuid game_id = 1; -} - -message Response { - string token = 1; -} diff --git a/packages/services/admin/proto/msg/device-link-complete-complete.proto b/packages/services/admin/proto/msg/device-link-complete-complete.proto deleted file mode 100644 index ebf5343e50..0000000000 --- a/packages/services/admin/proto/msg/device-link-complete-complete.proto +++ /dev/null @@ -1,17 +0,0 @@ -syntax = "proto3"; - -package rivet.backend.pkg.cloud.msg.device_link_complete_complete; - -import "resources/legacy/proto/common.proto"; - -/// name = "msg-cloud-device-link-complete-complete" -/// tail-ttl = 3600 -/// parameters = [ -/// { name = "device_link_id" }, -/// ] -message Message { - rivet.common.Uuid device_link_id = 1; - rivet.common.Uuid game_id = 2; - string cloud_token = 3; -} - diff --git a/packages/services/admin/proto/msg/device-link-complete.proto b/packages/services/admin/proto/msg/device-link-complete.proto deleted file mode 100644 index 45af601577..0000000000 --- a/packages/services/admin/proto/msg/device-link-complete.proto +++ /dev/null @@ -1,16 +0,0 @@ -syntax = "proto3"; - -package rivet.backend.pkg.cloud.msg.device_link_complete; - -import "resources/legacy/proto/common.proto"; - -/// name = "msg-cloud-device-link-complete" -/// tail-ttl = 3600 -/// parameters = [ -/// { name = "device_link_id" }, -/// ] -message Message { - rivet.common.Uuid device_link_id = 1; - rivet.common.Uuid game_id = 2; -} - diff --git a/packages/services/admin/proto/msg/version-name-reserve-complete.proto b/packages/services/admin/proto/msg/version-name-reserve-complete.proto deleted file mode 100644 index 08f315c754..0000000000 --- a/packages/services/admin/proto/msg/version-name-reserve-complete.proto +++ /dev/null @@ -1,17 +0,0 @@ -syntax = "proto3"; - -package rivet.backend.pkg.cloud.msg.version_name_reserve_complete; - -import "resources/legacy/proto/common.proto"; - -/// name = "msg-version-name-reserve-complete" -/// parameters = [ -/// { name = "game_id" }, -/// { name = "request_id" }, -/// ] -message Message { - rivet.common.Uuid game_id = 1; - rivet.common.Uuid request_id = 2; - string version_display_name = 3; -} - diff --git a/packages/services/admin/proto/msg/version-name-reserve.proto b/packages/services/admin/proto/msg/version-name-reserve.proto deleted file mode 100644 index 37ba9de644..0000000000 --- a/packages/services/admin/proto/msg/version-name-reserve.proto +++ /dev/null @@ -1,16 +0,0 @@ -syntax = "proto3"; - -package rivet.backend.pkg.cloud.msg.version_name_reserve; - -import "resources/legacy/proto/common.proto"; - -/// name = "msg-version-name-reserve" -/// parameters = [ -/// { name = "game_id" }, -/// { name = "request_id" }, -/// ] -message Message { - rivet.common.Uuid game_id = 1; - rivet.common.Uuid request_id = 2; -} - diff --git a/packages/services/admin/proto/namespace-create.proto b/packages/services/admin/proto/namespace-create.proto deleted file mode 100644 index 69755bef12..0000000000 --- a/packages/services/admin/proto/namespace-create.proto +++ /dev/null @@ -1,14 +0,0 @@ -syntax = "proto3"; - -package rivet.backend.pkg.cloud.namespace_create; - -import "resources/legacy/proto/common.proto"; - -message Request { - rivet.common.Uuid namespace_id = 1; - optional rivet.common.Uuid creator_user_id = 2; -} - -message Response { - -} diff --git a/packages/services/admin/proto/namespace-get.proto b/packages/services/admin/proto/namespace-get.proto deleted file mode 100644 index beaad3a114..0000000000 --- a/packages/services/admin/proto/namespace-get.proto +++ /dev/null @@ -1,14 +0,0 @@ -syntax = "proto3"; - -package rivet.backend.pkg.cloud.namespace_get; - -import "resources/legacy/proto/common.proto"; -import "resources/legacy/proto/backend/cloud.proto"; - -message Request { - repeated rivet.common.Uuid namespace_ids = 1; -} - -message Response { - repeated rivet.backend.cloud.GameNamespace namespaces = 1; -} diff --git a/packages/services/admin/proto/namespace-token-development-create.proto b/packages/services/admin/proto/namespace-token-development-create.proto deleted file mode 100644 index ef3ebabb23..0000000000 --- a/packages/services/admin/proto/namespace-token-development-create.proto +++ /dev/null @@ -1,17 +0,0 @@ -syntax = "proto3"; - -package rivet.backend.pkg.cloud.namespace_token_development_create; - -import "resources/legacy/proto/common.proto"; -import "resources/legacy/proto/backend/matchmaker.proto"; - -message Request { - reserved 2; - rivet.common.Uuid namespace_id = 1; - string hostname = 3; - repeated rivet.backend.matchmaker.LobbyRuntime.Port lobby_ports = 4; -} - -message Response { - string token = 1; -} diff --git a/packages/services/admin/proto/namespace-token-public-create.proto b/packages/services/admin/proto/namespace-token-public-create.proto deleted file mode 100644 index 4e93644941..0000000000 --- a/packages/services/admin/proto/namespace-token-public-create.proto +++ /dev/null @@ -1,13 +0,0 @@ -syntax = "proto3"; - -package rivet.backend.pkg.cloud.namespace_token_public_create; - -import "resources/legacy/proto/common.proto"; - -message Request { - rivet.common.Uuid namespace_id = 1; -} - -message Response { - string token = 1; -} diff --git a/packages/services/admin/proto/version-get.proto b/packages/services/admin/proto/version-get.proto deleted file mode 100644 index fd0bbb2c79..0000000000 --- a/packages/services/admin/proto/version-get.proto +++ /dev/null @@ -1,14 +0,0 @@ -syntax = "proto3"; - -package rivet.backend.pkg.cloud.version_get; - -import "resources/legacy/proto/common.proto"; -import "resources/legacy/proto/backend/cloud.proto"; - -message Request { - repeated rivet.common.Uuid version_ids = 1; -} - -message Response { - repeated rivet.backend.cloud.GameVersion versions = 1; -} diff --git a/packages/services/admin/proto/version-publish.proto b/packages/services/admin/proto/version-publish.proto deleted file mode 100644 index d1ba5ae502..0000000000 --- a/packages/services/admin/proto/version-publish.proto +++ /dev/null @@ -1,17 +0,0 @@ -syntax = "proto3"; - -package rivet.backend.pkg.cloud.version_publish; - -import "resources/legacy/proto/common.proto"; -import "resources/legacy/proto/backend/cloud.proto"; - -message Request { - rivet.common.Uuid game_id = 1; - string display_name = 2; - rivet.backend.cloud.VersionConfig config = 3; - optional rivet.common.Uuid creator_user_id = 4; -} - -message Response { - rivet.common.Uuid version_id = 1; -} diff --git a/packages/services/admin/standalone/default-login/Cargo.toml b/packages/services/admin/standalone/default-login/Cargo.toml new file mode 100644 index 0000000000..cc770e8953 --- /dev/null +++ b/packages/services/admin/standalone/default-login/Cargo.toml @@ -0,0 +1,28 @@ +[package] +name = "admin-default-login" +version = "0.0.1" +edition = "2018" +authors = ["Rivet Gaming, LLC "] +license = "Apache-2.0" + +[dependencies] +chirp-client = { path = "../../../../common/chirp/client" } +chirp-workflow = { path = "../../../../common/chirp-workflow/core" } +rivet-connection = { path = "../../../../common/connection" } +rivet-health-checks = { path = "../../../../common/health-checks" } +rivet-metrics = { path = "../../../../common/metrics" } +rivet-runtime = { path = "../../../../common/runtime" } +tokio = { version = "1.40", features = ["full"] } +tracing = "0.1" +tracing-subscriber = { version = "0.3", default-features = false, features = ["fmt", "json", "ansi"] } +tracing-logfmt = "0.3" +rivet-config = { version = "0.1.0", path = "../../../../common/config" } +token-create = { version = "0.0.1", path = "../../../token/ops/create" } +rivet-operation = { version = "0.1.0", path = "../../../../common/operation/core" } + +[dependencies.sqlx] +git = "https://github.com/rivet-gg/sqlx" +rev = "e7120f59b74fb6d83ac9b1d899b166bab31ba1d6" +default-features = false + +[dev-dependencies] diff --git a/packages/services/admin/standalone/default-login/src/lib.rs b/packages/services/admin/standalone/default-login/src/lib.rs new file mode 100644 index 0000000000..0ce1395ad7 --- /dev/null +++ b/packages/services/admin/standalone/default-login/src/lib.rs @@ -0,0 +1,63 @@ +use proto::backend::pkg::*; +use rivet_operation::prelude::*; + +// TODO: Should this token live forever or a shorter period of time? +// This token is printed on startup. It should be accessible if a dev checks the logs much later. +const TOKEN_TTL: i64 = util::duration::hours(24 * 7); + +const DEFAULT_USERNAME: &'static str = "admin"; + +#[tracing::instrument(skip_all)] +pub async fn start(config: rivet_config::Config, pools: rivet_pools::Pools) -> GlobalResult<()> { + // Check if enabled + let auth_config = &config.server()?.rivet.auth; + if !auth_config.access_token_login || !auth_config.print_login_url { + tracing::debug!("skipping print admin login url"); + return Ok(()); + } + + let client = + chirp_client::SharedClient::from_env(pools.clone())?.wrap_new("admin-default-login-url"); + let cache = rivet_cache::CacheInner::from_env(pools.clone())?; + let ctx = OperationContext::new( + "admin-default-login-url".into(), + std::time::Duration::from_secs(60), + config, + rivet_connection::Connection::new(client, pools, cache), + Uuid::new_v4(), + Uuid::new_v4(), + util::timestamp::now(), + util::timestamp::now(), + (), + ); + + let token_res = op!([ctx] token_create { + issuer: "admin-default-login-url".to_string(), + token_config: Some(token::create::request::TokenConfig { + ttl: TOKEN_TTL, + }), + refresh_token_config: None, + client: None, + kind: Some(token::create::request::Kind::New(token::create::request::KindNew { + entitlements: vec![ + proto::claims::Entitlement { + kind: Some( + proto::claims::entitlement::Kind::AccessToken(proto::claims::entitlement::AccessToken { + name: DEFAULT_USERNAME.to_string(), + }) + ) + } + ], + })), + label: Some("access".to_string()), + ..Default::default() + }) + .await?; + + let access_token_token = unwrap!(token_res.token).token; + let access_token_link_url = util::route::access_token_link(ctx.config(), &access_token_token); + + tracing::info!(url = ?access_token_link_url, "admin login url"); + + Ok(()) +}