ceres: a small planet in a giant solar system
33
fork

Configure Feed

Select the types of activity you want to include in your feed.

service auth setup

+225 -15
+171 -3
Cargo.lock
··· 389 389 "jacquard-api", 390 390 "jacquard-axum", 391 391 "log", 392 + "reqwest", 392 393 "serde", 393 394 "serde_json", 394 395 "tokio", ··· 1023 1024 checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" 1024 1025 1025 1026 [[package]] 1027 + name = "foreign-types" 1028 + version = "0.3.2" 1029 + source = "registry+https://github.com/rust-lang/crates.io-index" 1030 + checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" 1031 + dependencies = [ 1032 + "foreign-types-shared", 1033 + ] 1034 + 1035 + [[package]] 1036 + name = "foreign-types-shared" 1037 + version = "0.1.1" 1038 + source = "registry+https://github.com/rust-lang/crates.io-index" 1039 + checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" 1040 + 1041 + [[package]] 1026 1042 name = "form_urlencoded" 1027 1043 version = "1.2.2" 1028 1044 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 1118 1134 checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6" 1119 1135 dependencies = [ 1120 1136 "futures-core", 1137 + "futures-io", 1121 1138 "futures-macro", 1122 1139 "futures-sink", 1123 1140 "futures-task", 1141 + "memchr", 1124 1142 "pin-project-lite", 1125 1143 "slab", 1126 1144 ] ··· 1487 1505 ] 1488 1506 1489 1507 [[package]] 1508 + name = "hyper-tls" 1509 + version = "0.6.0" 1510 + source = "registry+https://github.com/rust-lang/crates.io-index" 1511 + checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" 1512 + dependencies = [ 1513 + "bytes", 1514 + "http-body-util", 1515 + "hyper", 1516 + "hyper-util", 1517 + "native-tls", 1518 + "tokio", 1519 + "tokio-native-tls", 1520 + "tower-service", 1521 + ] 1522 + 1523 + [[package]] 1490 1524 name = "hyper-util" 1491 1525 version = "0.1.20" 1492 1526 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 2352 2386 ] 2353 2387 2354 2388 [[package]] 2389 + name = "native-tls" 2390 + version = "0.2.18" 2391 + source = "registry+https://github.com/rust-lang/crates.io-index" 2392 + checksum = "465500e14ea162429d264d44189adc38b199b62b1c21eea9f69e4b73cb03bbf2" 2393 + dependencies = [ 2394 + "libc", 2395 + "log", 2396 + "openssl", 2397 + "openssl-probe", 2398 + "openssl-sys", 2399 + "schannel", 2400 + "security-framework", 2401 + "security-framework-sys", 2402 + "tempfile", 2403 + ] 2404 + 2405 + [[package]] 2355 2406 name = "ndk-context" 2356 2407 version = "0.1.1" 2357 2408 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 2490 2541 checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" 2491 2542 2492 2543 [[package]] 2544 + name = "openssl" 2545 + version = "0.10.76" 2546 + source = "registry+https://github.com/rust-lang/crates.io-index" 2547 + checksum = "951c002c75e16ea2c65b8c7e4d3d51d5530d8dfa7d060b4776828c88cfb18ecf" 2548 + dependencies = [ 2549 + "bitflags", 2550 + "cfg-if", 2551 + "foreign-types", 2552 + "libc", 2553 + "once_cell", 2554 + "openssl-macros", 2555 + "openssl-sys", 2556 + ] 2557 + 2558 + [[package]] 2559 + name = "openssl-macros" 2560 + version = "0.1.1" 2561 + source = "registry+https://github.com/rust-lang/crates.io-index" 2562 + checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" 2563 + dependencies = [ 2564 + "proc-macro2", 2565 + "quote", 2566 + "syn", 2567 + ] 2568 + 2569 + [[package]] 2570 + name = "openssl-probe" 2571 + version = "0.2.1" 2572 + source = "registry+https://github.com/rust-lang/crates.io-index" 2573 + checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe" 2574 + 2575 + [[package]] 2576 + name = "openssl-sys" 2577 + version = "0.9.112" 2578 + source = "registry+https://github.com/rust-lang/crates.io-index" 2579 + checksum = "57d55af3b3e226502be1526dfdba67ab0e9c96fc293004e79576b2b9edb0dbdb" 2580 + dependencies = [ 2581 + "cc", 2582 + "libc", 2583 + "pkg-config", 2584 + "vcpkg", 2585 + ] 2586 + 2587 + [[package]] 2493 2588 name = "ouroboros" 2494 2589 version = "0.18.5" 2495 2590 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 2690 2785 ] 2691 2786 2692 2787 [[package]] 2788 + name = "pkg-config" 2789 + version = "0.3.32" 2790 + source = "registry+https://github.com/rust-lang/crates.io-index" 2791 + checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" 2792 + 2793 + [[package]] 2693 2794 name = "plain" 2694 2795 version = "0.2.3" 2695 2796 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 3012 3113 "bytes", 3013 3114 "encoding_rs", 3014 3115 "futures-core", 3116 + "futures-util", 3015 3117 "h2", 3016 3118 "http", 3017 3119 "http-body", 3018 3120 "http-body-util", 3019 3121 "hyper", 3020 3122 "hyper-rustls", 3123 + "hyper-tls", 3021 3124 "hyper-util", 3022 3125 "js-sys", 3023 3126 "log", 3024 3127 "mime", 3128 + "native-tls", 3025 3129 "percent-encoding", 3026 3130 "pin-project-lite", 3027 3131 "quinn", ··· 3032 3136 "serde_urlencoded", 3033 3137 "sync_wrapper", 3034 3138 "tokio", 3139 + "tokio-native-tls", 3035 3140 "tokio-rustls", 3141 + "tokio-util", 3036 3142 "tower", 3037 3143 "tower-http", 3038 3144 "tower-service", 3039 3145 "url", 3040 3146 "wasm-bindgen", 3041 3147 "wasm-bindgen-futures", 3148 + "wasm-streams", 3042 3149 "web-sys", 3043 3150 "webpki-roots", 3044 3151 ] ··· 3142 3249 "errno", 3143 3250 "libc", 3144 3251 "linux-raw-sys", 3145 - "windows-sys 0.52.0", 3252 + "windows-sys 0.61.2", 3146 3253 ] 3147 3254 3148 3255 [[package]] ··· 3208 3315 ] 3209 3316 3210 3317 [[package]] 3318 + name = "schannel" 3319 + version = "0.1.29" 3320 + source = "registry+https://github.com/rust-lang/crates.io-index" 3321 + checksum = "91c1b7e4904c873ef0710c1f407dde2e6287de2bebc1bbbf7d430bb7cbffd939" 3322 + dependencies = [ 3323 + "windows-sys 0.61.2", 3324 + ] 3325 + 3326 + [[package]] 3211 3327 name = "scoped-tls" 3212 3328 version = "1.0.1" 3213 3329 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 3234 3350 ] 3235 3351 3236 3352 [[package]] 3353 + name = "security-framework" 3354 + version = "3.7.0" 3355 + source = "registry+https://github.com/rust-lang/crates.io-index" 3356 + checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d" 3357 + dependencies = [ 3358 + "bitflags", 3359 + "core-foundation 0.10.1", 3360 + "core-foundation-sys", 3361 + "libc", 3362 + "security-framework-sys", 3363 + ] 3364 + 3365 + [[package]] 3366 + name = "security-framework-sys" 3367 + version = "2.17.0" 3368 + source = "registry+https://github.com/rust-lang/crates.io-index" 3369 + checksum = "6ce2691df843ecc5d231c0b14ece2acc3efb62c0a398c7e1d875f3983ce020e3" 3370 + dependencies = [ 3371 + "core-foundation-sys", 3372 + "libc", 3373 + ] 3374 + 3375 + [[package]] 3237 3376 name = "semver" 3238 3377 version = "1.0.28" 3239 3378 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 3631 3770 "getrandom 0.3.4", 3632 3771 "once_cell", 3633 3772 "rustix", 3634 - "windows-sys 0.52.0", 3773 + "windows-sys 0.61.2", 3635 3774 ] 3636 3775 3637 3776 [[package]] ··· 3786 3925 "proc-macro2", 3787 3926 "quote", 3788 3927 "syn", 3928 + ] 3929 + 3930 + [[package]] 3931 + name = "tokio-native-tls" 3932 + version = "0.3.1" 3933 + source = "registry+https://github.com/rust-lang/crates.io-index" 3934 + checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" 3935 + dependencies = [ 3936 + "native-tls", 3937 + "tokio", 3789 3938 ] 3790 3939 3791 3940 [[package]] ··· 4043 4192 checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" 4044 4193 4045 4194 [[package]] 4195 + name = "vcpkg" 4196 + version = "0.2.15" 4197 + source = "registry+https://github.com/rust-lang/crates.io-index" 4198 + checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" 4199 + 4200 + [[package]] 4046 4201 name = "version_check" 4047 4202 version = "0.9.5" 4048 4203 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 4138 4293 ] 4139 4294 4140 4295 [[package]] 4296 + name = "wasm-streams" 4297 + version = "0.4.2" 4298 + source = "registry+https://github.com/rust-lang/crates.io-index" 4299 + checksum = "15053d8d85c7eccdbefef60f06769760a563c7f0a9d6902a13d35c7800b0ad65" 4300 + dependencies = [ 4301 + "futures-util", 4302 + "js-sys", 4303 + "wasm-bindgen", 4304 + "wasm-bindgen-futures", 4305 + "web-sys", 4306 + ] 4307 + 4308 + [[package]] 4141 4309 name = "web-sys" 4142 4310 version = "0.3.95" 4143 4311 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 4206 4374 source = "registry+https://github.com/rust-lang/crates.io-index" 4207 4375 checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" 4208 4376 dependencies = [ 4209 - "windows-sys 0.52.0", 4377 + "windows-sys 0.61.2", 4210 4378 ] 4211 4379 4212 4380 [[package]]
+1
Cargo.toml
··· 11 11 jacquard-api = { version = "0.11.1", features = ["default", "app_bsky"] } 12 12 jacquard-axum = "0.11.0" 13 13 log = "0.4.29" 14 + reqwest = { version = "0.12.23", features = ["stream", "json"] } 14 15 serde = { version = "1.0.228", features = ["derive"] } 15 16 serde_json = "1.0.149" 16 17 tokio = { version = "1.52.1", features = ["macros", "rt-multi-thread", "net", "signal"] }
+5
README.md
··· 1 1 # ceres 2 + 3 + Ceres is a Bluesky AppView that aims to be easy on resources, does most of what Bluesky's AppView does, and hopefully works. Aka low storage requirments, and can still make posts, reply, and comment. But search and notifications are not fully in scope yet 4 + 5 + # Work done currently 6 + - 'app.bsky.actor.getProfile` - Just started
+11 -3
src/handlers/xrpc/app_bsky_actor.rs
··· 1 1 use crate::handlers::xrpc::XrpcErrorResponse; 2 + use crate::state::AppState; 2 3 use axum::{ 3 - Json, 4 + Json, Router, 4 5 response::{IntoResponse, Response}, 5 6 }; 6 7 use jacquard::types::{datetime::Datetime, did::Did, handle::Handle, uri::UriValue}; ··· 8 9 ProfileViewDetailed, 9 10 get_profile::{GetProfileOutput, GetProfileRequest}, 10 11 }; 11 - use jacquard_axum::ExtractXrpc; 12 + use jacquard_axum::{ExtractXrpc, IntoRouter, service_auth::ExtractOptionalServiceAuth}; 12 13 use log::info; 13 14 14 15 pub async fn get_profile( 16 + ExtractOptionalServiceAuth(auth): ExtractOptionalServiceAuth, 15 17 ExtractXrpc(req): ExtractXrpc<GetProfileRequest>, 16 18 ) -> Result<Response, XrpcErrorResponse> { 17 19 info!("get_profile actor={}", req.actor.as_ref()); 18 - 20 + info!("{:?}", auth); 19 21 let profile = GetProfileOutput { 20 22 value: ProfileViewDetailed { 21 23 associated: None, ··· 63 65 64 66 Ok(Json(profile).into_response()) 65 67 } 68 + 69 + pub fn routes(state: AppState) -> Router { 70 + Router::<AppState>::new() 71 + .merge(GetProfileRequest::into_router::<_, AppState, _>(get_profile)) 72 + .with_state(state) 73 + }
+14 -9
src/main.rs
··· 1 1 mod handlers; 2 + mod state; 2 3 3 4 use axum::{ 4 5 Json, Router, body, ··· 7 8 routing::get, 8 9 }; 9 10 use env_logger::Env; 10 - use handlers::{well_known::did_document, xrpc::app_bsky_actor::get_profile}; 11 - use jacquard_api::app_bsky::actor::get_profile::GetProfileRequest; 12 - use jacquard_axum::IntoRouter; 11 + use handlers::{well_known::did_document, xrpc::app_bsky_actor}; 12 + use jacquard::{identity::resolver::ResolverOptions, prelude::JacquardResolver, types::did::Did}; 13 + use jacquard_axum::service_auth::ServiceAuthConfig; 13 14 use log::info; 14 15 use serde_json::{Value, json}; 16 + use state::AppState; 15 17 use std::env; 16 18 use tokio::net::TcpListener; 17 19 use tower_http::cors::CorsLayer; ··· 22 24 env_logger::Builder::from_env(Env::default().default_filter_or("info")).init(); 23 25 24 26 let bind_addr = env::var("BIND_ADDR").unwrap_or_else(|_| "127.0.0.1:3000".to_string()); 27 + let resolver = JacquardResolver::new(reqwest::Client::new(), ResolverOptions::default()); 28 + 29 + let app_view_domain = env::var("APP_VIEW_DOMAIN").expect("APP_VIEW_DOMAIN is not set"); 30 + let service_did = Did::new_owned(format!("did:web:{app_view_domain}")) 31 + .expect("APP_VIEW_DOMAIN produced an invalid did:web"); 32 + let service_auth = ServiceAuthConfig::new(service_did, resolver); 33 + 34 + let state = AppState { service_auth }; 25 35 26 36 let app = Router::new() 27 37 .route("/.well-known/did.json", get(did_document)) 28 - .merge(GetProfileRequest::into_router(get_profile)) 38 + .merge(app_bsky_actor::routes(state.clone())) 29 39 .fallback(log_request) 30 40 .layer(CorsLayer::permissive()); 31 41 ··· 43 53 let path = parts.uri.path().to_string(); 44 54 45 55 info!("{method} {path}"); 46 - 47 - // for (name, value) in parts.headers.iter() { 48 - // let display = value.to_str().unwrap_or("<non-utf8>"); 49 - // info!(" header {name}: {display}"); 50 - // } 51 56 52 57 if method == Method::GET { 53 58 match parts.uri.query() {
+23
src/state.rs
··· 1 + use jacquard::{prelude::JacquardResolver, types::did::Did}; 2 + use jacquard_axum::service_auth::{ServiceAuth, ServiceAuthConfig}; 3 + 4 + #[derive(Clone)] 5 + pub struct AppState { 6 + pub service_auth: ServiceAuthConfig<JacquardResolver>, 7 + } 8 + 9 + impl ServiceAuth for AppState { 10 + type Resolver = JacquardResolver; 11 + 12 + fn service_did(&self) -> &Did<'_> { 13 + ServiceAuth::service_did(&self.service_auth) 14 + } 15 + 16 + fn resolver(&self) -> &Self::Resolver { 17 + ServiceAuth::resolver(&self.service_auth) 18 + } 19 + 20 + fn require_lxm(&self) -> bool { 21 + ServiceAuth::require_lxm(&self.service_auth) 22 + } 23 + }