Skip to content

Commit

Permalink
fix: accept any domain cuz bridge
Browse files Browse the repository at this point in the history
  • Loading branch information
CutestNekoAqua committed Aug 3, 2024
1 parent 2910702 commit dde8692
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ dotenv = "0.15.0"
async-recursion = "1.1.1"
base64-url = "3.0.0"
webfinger = "0.5.1"
regex = "1.10.6"
once_cell = "1.19.0"

[dependencies.sea-orm]
version = "0.12.0"
Expand Down
12 changes: 10 additions & 2 deletions src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ use crate::{
use activitypub_federation::{
actix_web::{inbox::receive_activity, signing_actor},
config::{Data, FederationConfig, FederationMiddleware},
fetch::webfinger::{build_webfinger_response, extract_webfinger_name},
fetch::webfinger::{build_webfinger_response, extract_webfinger_name, WebFingerError},
protocol::context::WithContext,
traits::{Actor, Object},
FEDERATION_CONTENT_TYPE,
};
use actix_web::{web, web::Bytes, App, HttpRequest, HttpResponse, HttpServer};
use anyhow::anyhow;
use once_cell::sync::Lazy;
use regex::Regex;
use serde::Deserialize;
use tracing::info;
use url::Url;
Expand Down Expand Up @@ -106,7 +108,13 @@ pub async fn webfinger(
query: web::Query<WebfingerQuery>,
data: Data<StateHandle>,
) -> Result<HttpResponse, Error> {
let name = extract_webfinger_name(&query.resource, &data)?;
static WEBFINGER_REGEX: Lazy<Regex> =
Lazy::new(|| Regex::new(r"^acct:([\p{L}0-9_\.\-]+)@(.*)$").expect("compile regex"));
let captures = WEBFINGER_REGEX
.captures(&query.resource)
.ok_or(WebFingerError::WrongFormat)?;
let account_name = captures.get(1).ok_or(WebFingerError::WrongFormat)?;
let name = account_name.as_str();
let user = local_db_user_from_name(name.to_string()).await?;
Ok(HttpResponse::Ok().json(build_webfinger_response(
query.resource.clone(),
Expand Down

0 comments on commit dde8692

Please sign in to comment.