check that the user did in the request is the same as the configured user did
+25
-4
Diff
round #0
+5
-2
src/server.rs
+5
-2
src/server.rs
···
49
49
let service_did = Did::new_owned(appview_did).expect("APPVIEW_DID produced an invalid did:web");
50
50
51
51
let resolver = JacquardResolver::new(reqwest::Client::new(), ResolverOptions::default());
52
-
let auth_config = ServiceAuthConfig::new(service_did, resolver);
52
+
let auth_config = ServiceAuthConfig::new(service_did, resolver.clone());
53
53
54
-
let app_state = AppState::new(server_config, auth_config);
54
+
let app_state = AppState::new(server_config, auth_config, resolver.clone());
55
55
56
56
let app = Router::<AppState>::new()
57
57
.route("/", get(say_hello_text))
···
171
171
pub struct AppState {
172
172
server_config: ServerConfig,
173
173
pub service_auth: ServiceAuthConfig<JacquardResolver>,
174
+
pub resolver: JacquardResolver,
174
175
}
175
176
176
177
impl AppState {
177
178
pub fn new(
178
179
server_config: ServerConfig,
179
180
service_auth: ServiceAuthConfig<JacquardResolver>,
181
+
resolver: JacquardResolver,
180
182
) -> Self {
181
183
Self {
182
184
service_auth: service_auth,
183
185
server_config: server_config,
186
+
resolver: resolver,
184
187
}
185
188
}
186
189
}
+20
-2
src/xrpc/routes.rs
+20
-2
src/xrpc/routes.rs
···
1
1
use crate::server::AppState;
2
2
use crate::server::XrpcErrorResponse;
3
3
use axum::{Json, extract::State};
4
+
use jacquard::types::string::AtIdentifier;
4
5
use jacquard::xrpc::atproto::GetRecordOutput;
5
6
use jacquard_api::app_bsky::actor::get_profile::GetProfileOutput;
6
7
use jacquard_api::app_bsky::actor::get_profile::GetProfileRequest;
···
12
13
use jacquard_api::tools_ozone::moderation::get_record::GetRecordRequest;
13
14
use jacquard_axum::ExtractXrpc;
14
15
use jacquard_axum::service_auth::ExtractOptionalServiceAuth;
16
+
use jacquard_common::IntoStatic;
17
+
use jacquard_identity::resolver::IdentityResolver;
15
18
use serde_json::Value;
16
19
use serde_json::json;
17
20
18
21
pub async fn app_bsky_actor_get_profile(
19
-
State(_): State<AppState>,
22
+
State(state): State<AppState>,
20
23
ExtractOptionalServiceAuth(_auth): ExtractOptionalServiceAuth,
21
-
ExtractXrpc(_): ExtractXrpc<GetProfileRequest>,
24
+
ExtractXrpc(req): ExtractXrpc<GetProfileRequest>,
22
25
) -> Result<Json<GetProfileOutput<'static>>, XrpcErrorResponse> {
26
+
let did = match req.actor {
27
+
AtIdentifier::Did(did) => did.into_static(),
28
+
AtIdentifier::Handle(handle) => {
29
+
state
30
+
.resolver
31
+
.resolve_handle(&handle)
32
+
.await
33
+
.map_err(|err| {
34
+
println!("error resolving handle: {err}");
35
+
XrpcErrorResponse::internal_server_error()
36
+
})?
37
+
}
38
+
};
39
+
40
+
println!("did is {did}");
23
41
return Err(XrpcErrorResponse::not_implemented());
24
42
}
25
43
History
2 rounds
0 comments
willdot.net
submitted
#1
1 commit
expand
collapse
print out the did from the request by resolving it
check that the user did in the request is the same as the configured user did
merge conflicts detected
expand
collapse
expand
collapse
- src/server.rs:13
- src/xrpc/routes.rs:2
expand 0 comments
willdot.net
submitted
#0
1 commit
expand
collapse
print out the did from the request by resolving it