Compare commits
3 commits
646696a49e
...
2d3421e2c3
Author | SHA1 | Date | |
---|---|---|---|
2d3421e2c3 | |||
025311e100 | |||
8145ce57cc |
10 changed files with 147 additions and 11 deletions
|
@ -9,6 +9,7 @@
|
||||||
<sourceFolder url="file://$MODULE_DIR$/acrate-inbox/src" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/acrate-inbox/src" isTestSource="false" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/acrate-nodeinfo/src" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/acrate-nodeinfo/src" isTestSource="false" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/acrate-nodeinfo/tests" isTestSource="true" />
|
<sourceFolder url="file://$MODULE_DIR$/acrate-nodeinfo/tests" isTestSource="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/acrate-webfinger/src" isTestSource="false" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="inheritedJdk" />
|
||||||
|
|
12
.idea/dataSources.xml
Normal file
12
.idea/dataSources.xml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
|
||||||
|
<data-source source="LOCAL" name="acrate" uuid="8258414e-095d-430b-a0a5-b48e72af23a9">
|
||||||
|
<driver-ref>postgresql</driver-ref>
|
||||||
|
<synchronize>true</synchronize>
|
||||||
|
<jdbc-driver>org.postgresql.Driver</jdbc-driver>
|
||||||
|
<jdbc-url>jdbc:postgresql:///acrate</jdbc-url>
|
||||||
|
<working-dir>$ProjectFileDir$</working-dir>
|
||||||
|
</data-source>
|
||||||
|
</component>
|
||||||
|
</project>
|
6
.idea/sqldialects.xml
Normal file
6
.idea/sqldialects.xml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="SqlDialectMappings">
|
||||||
|
<file url="file://$PROJECT_DIR$/acrate-core/migrations/2024-11-14-031744_Add webfinger table/up.sql" dialect="GenericSQL" />
|
||||||
|
</component>
|
||||||
|
</project>
|
|
@ -0,0 +1,8 @@
|
||||||
|
DROP FUNCTION get_meta_property;
|
||||||
|
DROP FUNCTION get_meta_link;
|
||||||
|
DROP FUNCTION get_meta_aliases;
|
||||||
|
|
||||||
|
DROP TABLE meta_property;
|
||||||
|
DROP TABLE meta_link_property;
|
||||||
|
DROP TABLE meta_link;
|
||||||
|
DROP TABLE meta_alias;
|
|
@ -0,0 +1,47 @@
|
||||||
|
CREATE TABLE meta_alias (
|
||||||
|
id UUID DEFAULT gen_random_uuid(),
|
||||||
|
pattern BPCHAR NOT NULL,
|
||||||
|
alias BPCHAR NOT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT unique_aliases UNIQUE (alias),
|
||||||
|
PRIMARY KEY (id)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE meta_link (
|
||||||
|
id UUID DEFAULT gen_random_uuid(),
|
||||||
|
pattern BPCHAR NOT NULL,
|
||||||
|
rel BPCHAR NOT NULL,
|
||||||
|
type BPCHAR,
|
||||||
|
href BPCHAR,
|
||||||
|
|
||||||
|
PRIMARY KEY (id)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE meta_link_property (
|
||||||
|
id UUID DEFAULT gen_random_uuid(),
|
||||||
|
link UUID REFERENCES meta_link (id),
|
||||||
|
rel BPCHAR NOT NULL,
|
||||||
|
value BPCHAR,
|
||||||
|
|
||||||
|
PRIMARY KEY (id)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE meta_property (
|
||||||
|
id UUID DEFAULT gen_random_uuid(),
|
||||||
|
pattern BPCHAR NOT NULL,
|
||||||
|
value BPCHAR,
|
||||||
|
|
||||||
|
PRIMARY KEY (id)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE FUNCTION get_meta_aliases(BPCHAR) RETURNS SETOF meta_alias AS $$
|
||||||
|
SELECT * FROM meta_alias WHERE meta_alias.pattern ILIKE $1;
|
||||||
|
$$ LANGUAGE SQL;
|
||||||
|
|
||||||
|
CREATE FUNCTION get_meta_link(BPCHAR) RETURNS SETOF meta_link AS $$
|
||||||
|
SELECT * FROM meta_link WHERE meta_link.pattern ILIKE $1;
|
||||||
|
$$ LANGUAGE SQL;
|
||||||
|
|
||||||
|
CREATE FUNCTION get_meta_property(BPCHAR) RETURNS SETOF meta_property AS $$
|
||||||
|
SELECT * FROM meta_property WHERE meta_property.pattern ILIKE $1;
|
||||||
|
$$ LANGUAGE SQL;
|
46
acrate-core/src/schema.rs
Normal file
46
acrate-core/src/schema.rs
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
// @generated automatically by Diesel CLI.
|
||||||
|
|
||||||
|
diesel::table! {
|
||||||
|
meta_alias (id) {
|
||||||
|
id -> Uuid,
|
||||||
|
pattern -> Bpchar,
|
||||||
|
alias -> Bpchar,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
diesel::table! {
|
||||||
|
meta_link (id) {
|
||||||
|
id -> Uuid,
|
||||||
|
pattern -> Bpchar,
|
||||||
|
rel -> Bpchar,
|
||||||
|
#[sql_name = "type"]
|
||||||
|
type_ -> Nullable<Bpchar>,
|
||||||
|
href -> Nullable<Bpchar>,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
diesel::table! {
|
||||||
|
meta_link_property (id) {
|
||||||
|
id -> Uuid,
|
||||||
|
link -> Nullable<Uuid>,
|
||||||
|
rel -> Bpchar,
|
||||||
|
value -> Nullable<Bpchar>,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
diesel::table! {
|
||||||
|
meta_property (id) {
|
||||||
|
id -> Uuid,
|
||||||
|
pattern -> Bpchar,
|
||||||
|
value -> Nullable<Bpchar>,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
diesel::joinable!(meta_link_property -> meta_link (link));
|
||||||
|
|
||||||
|
diesel::allow_tables_to_appear_in_same_query!(
|
||||||
|
meta_alias,
|
||||||
|
meta_link,
|
||||||
|
meta_link_property,
|
||||||
|
meta_property,
|
||||||
|
);
|
|
@ -5,8 +5,10 @@ edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1.0.93"
|
anyhow = "1.0.93"
|
||||||
axum = "0.7.7"
|
axum = { version = "0.7.7", features = ["macros"] }
|
||||||
|
axum-extra = { version = "0.9.4", features = ["query"] }
|
||||||
log = "0.4.22"
|
log = "0.4.22"
|
||||||
micronfig = "0.3.0"
|
micronfig = "0.3.0"
|
||||||
pretty_env_logger = "0.5.0"
|
pretty_env_logger = "0.5.0"
|
||||||
|
serde = { version = "1.0.215", features = ["derive"] }
|
||||||
tokio = { version = "1.41.1", features = ["macros", "net", "rt-multi-thread"] }
|
tokio = { version = "1.41.1", features = ["macros", "net", "rt-multi-thread"] }
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
micronfig::config!(
|
micronfig::config!(
|
||||||
ACRATE_INBOX_BIND_ADDRESS: String,
|
ACRATE_WEBFINGER_BIND_ADDRESS: String,
|
||||||
);
|
);
|
||||||
|
|
|
@ -11,11 +11,11 @@ async fn main() -> anyhow::Result<std::convert::Infallible> {
|
||||||
|
|
||||||
log::trace!("Creating Axum router...");
|
log::trace!("Creating Axum router...");
|
||||||
let app = axum::Router::new()
|
let app = axum::Router::new()
|
||||||
.route("/inbox", axum::routing::post(route::inbox_handler));
|
.route("/.well-known/webfinger", axum::routing::get(route::webfinger_handler));
|
||||||
log::trace!("Axum router created successfully!");
|
log::trace!("Axum router created successfully!");
|
||||||
|
|
||||||
log::trace!("Creating Tokio listener...");
|
log::trace!("Creating Tokio listener...");
|
||||||
let bind_address = config::ACRATE_INBOX_BIND_ADDRESS();
|
let bind_address = config::ACRATE_WEBFINGER_BIND_ADDRESS();
|
||||||
let listener = tokio::net::TcpListener::bind(bind_address)
|
let listener = tokio::net::TcpListener::bind(bind_address)
|
||||||
.await
|
.await
|
||||||
.context("failed to bind listener to address")?;
|
.context("failed to bind listener to address")?;
|
||||||
|
|
|
@ -1,8 +1,22 @@
|
||||||
#[allow(unreachable_code)]
|
use axum::http::StatusCode;
|
||||||
pub async fn inbox_handler() {
|
use axum_extra::extract::Query;
|
||||||
todo!("pre-validation hook");
|
use serde::Deserialize;
|
||||||
todo!("validate signature");
|
|
||||||
todo!("post-validation hook");
|
#[derive(Debug, Clone, Deserialize)]
|
||||||
todo!("database storage");
|
pub struct WebfingerQuery {
|
||||||
todo!("post-storage hook");
|
pub resource: String,
|
||||||
|
|
||||||
|
#[serde(default)]
|
||||||
|
pub rel: Vec<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[axum::debug_handler]
|
||||||
|
pub async fn webfinger_handler(
|
||||||
|
Query(WebfingerQuery {resource, rel}): Query<WebfingerQuery>
|
||||||
|
) -> StatusCode {
|
||||||
|
log::info!("Handling a WebFinger request!");
|
||||||
|
log::debug!("Resource is: {resource:#?}");
|
||||||
|
log::debug!("Rel is: {rel:#?}");
|
||||||
|
|
||||||
|
StatusCode::NO_CONTENT
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue