Skip to content

Commit 0ebc6a2

Browse files
committed
GraphQL API changes
1 parent 2f97a8f commit 0ebc6a2

File tree

19 files changed

+1301
-16
lines changed

19 files changed

+1301
-16
lines changed

Cargo.lock

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

crates/cli/src/commands/server.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ impl Options {
152152
&config.passwords,
153153
&config.account,
154154
&config.captcha,
155+
&config.http,
155156
)?;
156157

157158
// Load and compile the templates

crates/cli/src/commands/templates.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use clap::Parser;
1010
use figment::Figment;
1111
use mas_config::{
1212
AccountConfig, BrandingConfig, CaptchaConfig, ConfigurationSection, ConfigurationSectionExt,
13-
ExperimentalConfig, MatrixConfig, PasswordsConfig, TemplatesConfig,
13+
ExperimentalConfig, HttpConfig, MatrixConfig, PasswordsConfig, TemplatesConfig,
1414
};
1515
use mas_storage::{Clock, SystemClock};
1616
use rand::SeedableRng;
@@ -44,6 +44,7 @@ impl Options {
4444
let password_config = PasswordsConfig::extract_or_default(figment)?;
4545
let account_config = AccountConfig::extract_or_default(figment)?;
4646
let captcha_config = CaptchaConfig::extract_or_default(figment)?;
47+
let http_config = HttpConfig::extract_or_default(figment)?;
4748

4849
let clock = SystemClock::default();
4950
// XXX: we should disallow SeedableRng::from_entropy
@@ -57,6 +58,7 @@ impl Options {
5758
&password_config,
5859
&account_config,
5960
&captcha_config,
61+
&http_config,
6062
)?;
6163
let templates =
6264
templates_from_config(&template_config, &site_config, &url_builder).await?;

crates/cli/src/commands/worker.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ impl Options {
4747
&config.passwords,
4848
&config.account,
4949
&config.captcha,
50+
&config.http,
5051
)?;
5152

5253
// Load and compile the templates

crates/cli/src/util.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ use std::{sync::Arc, time::Duration};
99
use anyhow::Context;
1010
use mas_config::{
1111
AccountConfig, BrandingConfig, CaptchaConfig, DatabaseConfig, EmailConfig, EmailSmtpMode,
12-
EmailTransportKind, ExperimentalConfig, HomeserverKind, MatrixConfig, PasswordsConfig,
13-
PolicyConfig, TemplatesConfig,
12+
EmailTransportKind, ExperimentalConfig, HomeserverKind, HttpConfig, MatrixConfig,
13+
PasswordsConfig, PolicyConfig, TemplatesConfig,
1414
};
1515
use mas_data_model::{SessionExpirationConfig, SiteConfig};
1616
use mas_email::{MailTransport, Mailer};
@@ -183,6 +183,7 @@ pub fn site_config_from_config(
183183
password_config: &PasswordsConfig,
184184
account_config: &AccountConfig,
185185
captcha_config: &CaptchaConfig,
186+
http_config: &HttpConfig,
186187
) -> Result<SiteConfig, anyhow::Error> {
187188
let captcha = captcha_config_from_config(captcha_config)?;
188189
let session_expiration = experimental_config
@@ -198,6 +199,7 @@ pub fn site_config_from_config(
198199
access_token_ttl: experimental_config.access_token_ttl,
199200
compat_token_ttl: experimental_config.compat_token_ttl,
200201
server_name: matrix_config.homeserver.clone(),
202+
public_base: http_config.public_base.clone(),
201203
policy_uri: branding_config.policy_uri.clone(),
202204
tos_uri: branding_config.tos_uri.clone(),
203205
imprint: branding_config.imprint.clone(),

crates/data-model/src/site_config.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ pub struct SiteConfig {
4949
/// The server name, e.g. "matrix.org".
5050
pub server_name: String,
5151

52+
/// Public base URL
53+
pub public_base: Url,
54+
5255
/// The URL to the privacy policy.
5356
pub policy_uri: Option<Url>,
5457

crates/handlers/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ rand.workspace = true
8585
rand_chacha.workspace = true
8686
headers.workspace = true
8787
ulid.workspace = true
88+
webauthn-rs = { version = "0.5.1", features = ["danger-allow-state-serialisation"]}
89+
webauthn-rs-proto = "0.5.1"
8890

8991
mas-axum-utils.workspace = true
9092
mas-config.workspace = true

crates/handlers/src/graphql/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,12 @@ impl OwnerId for mas_data_model::UpstreamOAuthLink {
512512
}
513513
}
514514

515+
impl OwnerId for mas_data_model::UserPasskey {
516+
fn owner_id(&self) -> Option<Ulid> {
517+
Some(self.user_id)
518+
}
519+
}
520+
515521
/// A dumb wrapper around a `Ulid` to implement `OwnerId` for it.
516522
pub struct UserId(Ulid);
517523

crates/handlers/src/graphql/model/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ pub use self::{
2626
oauth::{OAuth2Client, OAuth2Session},
2727
site_config::{SITE_CONFIG_ID, SiteConfig},
2828
upstream_oauth::{UpstreamOAuth2Link, UpstreamOAuth2Provider},
29-
users::{AppSession, User, UserEmail, UserEmailAuthentication, UserRecoveryTicket},
29+
users::{
30+
AppSession, User, UserEmail, UserEmailAuthentication, UserPasskey, UserRecoveryTicket,
31+
},
3032
viewer::{Anonymous, Viewer, ViewerSession},
3133
};
3234

crates/handlers/src/graphql/model/node.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ pub enum NodeType {
2929
UserEmail,
3030
UserEmailAuthentication,
3131
UserRecoveryTicket,
32+
UserPasskey,
33+
UserPasskeyChallenge,
3234
}
3335

3436
#[derive(Debug, Error)]
@@ -55,6 +57,8 @@ impl NodeType {
5557
NodeType::UserEmail => "user_email",
5658
NodeType::UserEmailAuthentication => "user_email_authentication",
5759
NodeType::UserRecoveryTicket => "user_recovery_ticket",
60+
NodeType::UserPasskey => "user_passkey",
61+
NodeType::UserPasskeyChallenge => "user_passkey_challenge",
5862
}
5963
}
6064

@@ -72,6 +76,8 @@ impl NodeType {
7276
"user_email" => Some(NodeType::UserEmail),
7377
"user_email_authentication" => Some(NodeType::UserEmailAuthentication),
7478
"user_recovery_ticket" => Some(NodeType::UserRecoveryTicket),
79+
"user_passkey" => Some(NodeType::UserPasskey),
80+
"user_passkey_challenge" => Some(NodeType::UserPasskeyChallenge),
7581
_ => None,
7682
}
7783
}

0 commit comments

Comments
 (0)