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

chore: rename api-internal -> api-edge, add api-private, move admin to api-private #1284

Closed
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
105 changes: 55 additions & 50 deletions Cargo.lock

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

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
[workspace]
resolver = "2"
# Find all packages with: find . -name Cargo.toml | grep -v "sdks/runtime" | grep -v "sdks/full/rust-cli" | grep -v "infra/" | sed -E 's|^./(.*)Cargo\.toml$|"\1",|'
# Find all packages with: find . -name Cargo.toml | grep -v resources | grep -v "sdks/runtime" | grep -v "sdks/full/rust-cli" | grep -v "infra/" | sed -E 's|^./(.*)Cargo\.toml$|"\1",|'
members = [
"sdks/full/rust/",
"resources/default-builds/dockerfiles/test-ds-echo/",
"resources/default-builds/dockerfiles/test-mm-lobby-echo/",
"packages/cli/",
"packages/common/operation/core/",
"packages/common/operation/macros/",
Expand All @@ -16,6 +14,7 @@ members = [
"packages/common/test/",
"packages/common/connection/",
"packages/common/util/core/",
"packages/common/util/search/",
"packages/common/util/macros/",
"packages/common/config/",
"packages/common/nomad-util/",
Expand Down Expand Up @@ -72,19 +71,20 @@ members = [
"packages/api/ui/",
"packages/api/matchmaker/",
"packages/api/portal/",
"packages/api/monolith/",
"packages/api/traefik-provider/",
"packages/api/identity/",
"packages/api/auth/",
"packages/api/group/",
"packages/api/monolith-edge/",
"packages/api/cf-verification/",
"packages/api/admin/",
"packages/api/status/",
"packages/api/internal-monolith/",
"packages/api/cloud/",
"packages/api/job/",
"packages/api/monolith-private/",
"packages/api/games/",
"packages/api/actor/",
"packages/api/monolith-public/",
"packages/services/token/ops/exchange/",
"packages/services/token/ops/revoke/",
"packages/services/token/ops/get/",
Expand Down
7 changes: 2 additions & 5 deletions packages/api/admin/src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,8 @@ impl ApiAuth for Auth {

// TODO: Use JWT
if let Some(api_token) = api_token {
let valid_token = unwrap_ref!(
config.server()?.rivet.token.api_admin,
"missing admin token"
)
.read();
let valid_token =
unwrap_ref!(config.server()?.rivet.token.admin, "missing admin token").read();
ensure_eq_with!(
api_token,
*valid_token,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "api-internal-monolith"
name = "api-monolith-edge"
version = "0.0.1"
authors = ["Rivet Gaming, LLC <developer@rivet.gg>"]
edition = "2021"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ pub async fn start(config: rivet_config::Config, pools: rivet_pools::Pools) -> G
api_helper::start(
config.clone(),
pools,
config.server()?.rivet.api.host(),
config.server()?.rivet.api.port(),
config.server()?.rivet.api_edge.host(),
config.server()?.rivet.api_edge.port(),
route::handle,
)
.await
Expand Down
26 changes: 26 additions & 0 deletions packages/api/monolith-private/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[package]
name = "api-monolith-private"
version = "0.0.1"
authors = ["Rivet Gaming, LLC <developer@rivet.gg>"]
edition = "2021"
license = "Apache-2.0"

[dependencies]
api-helper = { path = "../../common/api-helper/build" }
async-trait = "0.1"
chirp-client = { path = "../../common/chirp/client" }
http = "0.2"
hyper = { version = "0.14", features = ["server", "http1", "tcp"] }
rivet-operation = { path = "../../common/operation/core" }
tokio = { version = "1.40" }
tracing = "0.1"
tracing-subscriber = { version = "0.3", default-features = false, features = [
"fmt",
"json",
"ansi",
] }
url = "2.2.2"

api-admin = { path = "../admin" }
rivet-config = { version = "0.1.0", path = "../../common/config" }
rivet-env = { version = "0.1.0", path = "../../common/env" }
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ pub async fn start(config: rivet_config::Config, pools: rivet_pools::Pools) -> G
api_helper::start(
config.clone(),
pools,
config.server()?.rivet.api_internal.host(),
config.server()?.rivet.api_internal.port(),
config.server()?.rivet.api_private.host(),
config.server()?.rivet.api_private.port(),
route::handle,
)
.await
Expand Down
36 changes: 36 additions & 0 deletions packages/api/monolith-private/src/route/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
use api_helper::define_router;
use hyper::{Body, Request, Response};
use rivet_operation::prelude::*;

pub async fn handle(
shared_client: chirp_client::SharedClientHandle,
config: rivet_config::Config,
pools: rivet_pools::Pools,
cache: rivet_cache::Cache,
ray_id: uuid::Uuid,
request: Request<Body>,
) -> Result<Response<Body>, http::Error> {
let response = Response::builder();

// Handle route
Router::handle(
shared_client,
config,
pools,
cache,
ray_id,
request,
response,
)
.await
}

define_router! {
routes: {},
mounts: [
{
path: api_admin::route::Router,
prefix: "admin",
},
],
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "api-monolith"
name = "api-monolith-public"
version = "0.0.1"
authors = ["Rivet Gaming, LLC <developer@rivet.gg>"]
edition = "2021"
Expand All @@ -22,7 +22,6 @@ tracing-subscriber = { version = "0.3", default-features = false, features = [
url = "2.2.2"

api-actor = { path = "../actor" }
api-admin = { path = "../admin" }
api-auth = { path = "../auth" }
api-cf-verification = { path = "../cf-verification" }
api-cloud = { path = "../cloud" }
Expand Down
14 changes: 14 additions & 0 deletions packages/api/monolith-public/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use rivet_operation::prelude::*;

pub mod route;

pub async fn start(config: rivet_config::Config, pools: rivet_pools::Pools) -> GlobalResult<()> {
api_helper::start(
config.clone(),
pools,
config.server()?.rivet.api_public.host(),
config.server()?.rivet.api_public.port(),
route::handle,
)
.await
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ define_router! {
{
path: api_ui::route::Router,
},
{
path: api_admin::route::Router,
prefix: "admin",
},
{
path: api_auth::route::Router,
prefix: "auth",
Expand Down
1 change: 1 addition & 0 deletions packages/api/monolith-public/tests/basic.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// TODO:
2 changes: 1 addition & 1 deletion packages/api/status/src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl ApiAuth for Auth {
ensure_eq_with!(
api_token,
*unwrap_ref!(
config.server()?.rivet.token.api_status,
config.server()?.rivet.token.status,
"no api status token provided"
)
.read(),
Expand Down
4 changes: 1 addition & 3 deletions packages/api/traefik-provider/src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ impl ApiAuth for Auth {

impl Auth {
pub async fn token(&self, token: &Option<String>) -> GlobalResult<()> {
if let Some(traefik_provider_token) =
&self.config.server()?.rivet.token.api_traefik_provider
{
if let Some(traefik_provider_token) = &self.config.server()?.rivet.token.traefik_provider {
let token = unwrap_with_ref!(token, API_FORBIDDEN, reason = "Token not provided");
ensure_eq_with!(
token,
Expand Down
8 changes: 1 addition & 7 deletions packages/api/traefik-provider/tests/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,7 @@ async fn cdn() {
let res = reqwest::Client::new()
.get(&format!(
"{API_TRAEFIK_PROVIDER_URL}/config/core?token={token}",
token = ctx
.config()
.server()?
.rivet
.tokens
.api_traefik_provider
.read()
token = ctx.config().server()?.rivet.tokens.traefik_provider.read()
))
.send()
.await
Expand Down
Loading
Loading