Skip to content

Commit fee438b

Browse files
committed
api
1 parent 19edf4a commit fee438b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+982
-432
lines changed

Cargo.lock

Lines changed: 137 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ bencher_adapter = { path = "lib/bencher_adapter" }
2626
bencher_boundary = { path = "lib/bencher_boundary" }
2727
bencher_client = { path = "lib/bencher_client" }
2828
bencher_comment = { path = "lib/bencher_comment" }
29+
bencher_config = { path = "lib/bencher_config" }
2930
bencher_context = { path = "lib/bencher_context" }
3031
bencher_endpoint = { path = "lib/bencher_endpoint" }
3132
bencher_github = { path = "lib/bencher_github" }
@@ -37,13 +38,22 @@ bencher_rbac = { path = "lib/bencher_rbac" }
3738
bencher_schema = { path = "lib/bencher_schema" }
3839
bencher_token = { path = "lib/bencher_token" }
3940
bencher_valid = { path = "lib/bencher_valid" }
41+
# API endpoints
42+
api_auth = { path = "lib/api_auth" }
43+
api_checkout = { path = "lib/api_checkout" }
44+
api_organizations = { path = "lib/api_organizations" }
45+
api_projects = { path = "lib/api_projects" }
46+
api_run = { path = "lib/api_run" }
47+
api_server = { path = "lib/api_server" }
48+
api_users = { path = "lib/api_users" }
4049
# plus
4150
bencher_billing = { path = "plus/bencher_billing" }
4251
bencher_bing_index = { path = "plus/bencher_bing_index" }
4352
bencher_google_index = { path = "plus/bencher_google_index" }
4453
bencher_license = { path = "plus/bencher_license" }
4554
# crates.io
4655
anyhow = "1.0"
56+
async-compression = "0.4"
4757
async-trait = "0.1"
4858
camino = "1.1"
4959
chrono = { version = "0.4", default-features = false }
@@ -62,6 +72,10 @@ pretty_assertions = "1.4"
6272
rand = "0.9"
6373
reqwest = { version = "0.12", default-features = false }
6474
schemars = { version = "0.8", features = ["uuid1"] }
75+
sentry = { version = "0.36", default-features = false, features = [
76+
"reqwest",
77+
"rustls",
78+
] }
6579
serde = { version = "1.0", features = ["derive"] }
6680
serde_json = "1.0"
6781
serde_urlencoded = "0.7"

lib/api_auth/Cargo.toml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[package]
2+
name = "api_auth"
3+
version.workspace = true
4+
authors.workspace = true
5+
edition.workspace = true
6+
license-file.workspace = true
7+
publish = false
8+
9+
[features]
10+
plus = [
11+
"bencher_endpoint/plus",
12+
"bencher_json/plus",
13+
"bencher_schema/plus",
14+
]
15+
sentry = ["bencher_schema/sentry"]
16+
17+
[dependencies]
18+
bencher_endpoint.workspace = true
19+
bencher_billing = { workspace = true, optional = true }
20+
bencher_json = { workspace = true, features = ["server", "schema", "db"] }
21+
bencher_schema.workspace = true
22+
dropshot.workspace = true
23+
slog.workspace = true
24+
25+
[lints]
26+
workspace = true

lib/api_auth/src/lib.rs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
mod accept;
2+
mod confirm;
3+
mod github;
4+
mod login;
5+
mod signup;
6+
7+
// TODO Custom max TTL
8+
// 30 minutes * 60 seconds / minute
9+
const AUTH_TOKEN_TTL: u32 = 30 * 60;
10+
// TODO Custom max TTL
11+
// 30 days * 24 hours / day * 60 minutes / hour * 60 seconds / minute
12+
const CLIENT_TOKEN_TTL: u32 = 30 * 24 * 60 * 60;
13+
14+
#[cfg(feature = "plus")]
15+
const PLAN_ARG: &str = "plan";
16+
const TOKEN_ARG: &str = "token";
17+
18+
pub struct Api;
19+
20+
impl bencher_endpoint::Registrar for Api {
21+
fn register(
22+
api_description: &mut dropshot::ApiDescription<bencher_schema::ApiContext>,
23+
http_options: bool,
24+
#[cfg(feature = "plus")] _is_bencher_cloud: bool,
25+
) -> Result<(), dropshot::ApiDescriptionRegisterError> {
26+
// Auth
27+
if http_options {
28+
api_description.register(signup::auth_signup_options)?;
29+
api_description.register(login::auth_login_options)?;
30+
api_description.register(confirm::auth_confirm_options)?;
31+
api_description.register(accept::auth_accept_options)?;
32+
}
33+
api_description.register(signup::auth_signup_post)?;
34+
api_description.register(login::auth_login_post)?;
35+
api_description.register(confirm::auth_confirm_post)?;
36+
api_description.register(accept::auth_accept_post)?;
37+
38+
#[cfg(feature = "plus")]
39+
{
40+
// GitHub OAuth
41+
if http_options {
42+
api_description.register(github::auth_github_options)?;
43+
}
44+
api_description.register(github::auth_github_post)?;
45+
}
46+
47+
Ok(())
48+
}
49+
}

lib/api_checkout/Cargo.toml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[package]
2+
name = "api_checkout"
3+
version.workspace = true
4+
authors.workspace = true
5+
edition.workspace = true
6+
license-file.workspace = true
7+
publish = false
8+
9+
[features]
10+
plus = [
11+
"bencher_endpoint/plus",
12+
"bencher_json/plus",
13+
"bencher_schema/plus",
14+
]
15+
sentry = ["bencher_schema/sentry", "dep:sentry"]
16+
17+
[dependencies]
18+
bencher_endpoint.workspace = true
19+
bencher_billing = { workspace = true, optional = true }
20+
bencher_json = { workspace = true, features = ["server", "schema"] }
21+
bencher_rbac.workspace = true
22+
bencher_schema.workspace = true
23+
dropshot.workspace = true
24+
sentry = { workspace = true, optional = true }
25+
26+
[lints]
27+
workspace = true

lib/api_checkout/src/lib.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
mod checkout;
2+
3+
pub struct Api;
4+
5+
#[cfg(feature = "plus")]
6+
impl bencher_endpoint::Registrar for Api {
7+
fn register(
8+
api_description: &mut dropshot::ApiDescription<bencher_schema::ApiContext>,
9+
http_options: bool,
10+
is_bencher_cloud: bool,
11+
) -> Result<(), dropshot::ApiDescriptionRegisterError> {
12+
// Checkout
13+
// Bencher Cloud only
14+
if is_bencher_cloud {
15+
if http_options {
16+
api_description.register(checkout::checkouts_options)?;
17+
}
18+
api_description.register(checkout::checkouts_post)?;
19+
}
20+
21+
Ok(())
22+
}
23+
}

lib/api_organizations/Cargo.toml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
[package]
2+
name = "api_organizations"
3+
version.workspace = true
4+
authors.workspace = true
5+
edition.workspace = true
6+
license-file.workspace = true
7+
publish = false
8+
9+
[features]
10+
plus = [
11+
"bencher_endpoint/plus",
12+
"bencher_json/plus",
13+
"bencher_schema/plus",
14+
"dep:bencher_billing",
15+
]
16+
sentry = ["bencher_schema/sentry", "dep:sentry"]
17+
18+
[dependencies]
19+
bencher_endpoint.workspace = true
20+
bencher_billing = { workspace = true, optional = true }
21+
bencher_json = { workspace = true, features = ["server", "schema", "db"] }
22+
bencher_rbac.workspace = true
23+
bencher_schema.workspace = true
24+
diesel.workspace = true
25+
dropshot.workspace = true
26+
schemars.workspace = true
27+
sentry = { workspace = true, optional = true }
28+
serde.workspace = true
29+
slog.workspace = true
30+
31+
[lints]
32+
workspace = true

0 commit comments

Comments
 (0)