new migration mode
This commit is contained in:
parent
e94ed21061
commit
337b6b9736
8 changed files with 179 additions and 58 deletions
|
|
@ -14,18 +14,17 @@
|
||||||
{
|
{
|
||||||
matrixoidc = {
|
matrixoidc = {
|
||||||
enable = true;
|
enable = true;
|
||||||
jwtSecretFile = config.age.secrets."oidcJwtSecret.age".path;
|
# A snapshot from before the cutover, made by ~/Documents/fednex-password-hashes.sh
|
||||||
|
passwordHashesFile = "/var/lib/matrix-password-hashes/hashes";
|
||||||
args = [
|
args = [
|
||||||
"--socket"
|
"--socket"
|
||||||
socket
|
socket
|
||||||
"--homeserver"
|
"--homeserver"
|
||||||
config.services.matrix-continuwuity.settings.global.well_known.client
|
config.services.matrix-continuwuity.settings.global.well_known.client
|
||||||
"--issuer"
|
"--migrateUri"
|
||||||
"https://${domain}"
|
"https://federated.nexus/migrate/"
|
||||||
"--authorizeEndpoint"
|
|
||||||
"https://federated.nexus/login"
|
|
||||||
"--serviceDomain"
|
"--serviceDomain"
|
||||||
"federated.nexus"
|
config.quad.matrix.domain
|
||||||
];
|
];
|
||||||
group = "caddy";
|
group = "caddy";
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ let
|
||||||
bootstrapDir = "/var/lib/kanidm-bootstrap";
|
bootstrapDir = "/var/lib/kanidm-bootstrap";
|
||||||
mailSenderToken = "${bootstrapDir}/mail-sender-token";
|
mailSenderToken = "${bootstrapDir}/mail-sender-token";
|
||||||
migrateToken = "${bootstrapDir}/migrate-token";
|
migrateToken = "${bootstrapDir}/migrate-token";
|
||||||
|
registrationToken = "${bootstrapDir}/registration-token";
|
||||||
|
|
||||||
secretsDir = "/var/lib/kanidm-oauth2-secrets";
|
secretsDir = "/var/lib/kanidm-oauth2-secrets";
|
||||||
oauth2Clients = builtins.attrNames config.services.kanidm.provision.systems.oauth2;
|
oauth2Clients = builtins.attrNames config.services.kanidm.provision.systems.oauth2;
|
||||||
|
|
@ -90,6 +91,8 @@ in
|
||||||
./hide-radius.patch
|
./hide-radius.patch
|
||||||
# Applies dark mode before the page is drawn, rather than flashing light mode first
|
# Applies dark mode before the page is drawn, rather than flashing light mode first
|
||||||
./theme-flash.patch
|
./theme-flash.patch
|
||||||
|
# Emails new accounts a welcome message instead of "This is your credential reset link"
|
||||||
|
./welcome-email.patch
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -164,6 +167,24 @@ in
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
"03-registration" = {
|
||||||
|
id = "5837871f-1810-47a5-ad43-60ecbf313462";
|
||||||
|
assertions = [
|
||||||
|
{
|
||||||
|
# Used by nexusbot to create approved registrations
|
||||||
|
state = "present";
|
||||||
|
id = "662082c2-9ec4-443d-98b5-537c4d128914";
|
||||||
|
class = [
|
||||||
|
"account"
|
||||||
|
"service_account"
|
||||||
|
];
|
||||||
|
name = "registration";
|
||||||
|
displayname = "Registration approval";
|
||||||
|
entry_managed_by = "idm_admins";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
# Existing built-in entries: class is omitted, as asserting it would
|
# Existing built-in entries: class is omitted, as asserting it would
|
||||||
# replace the entry's classes
|
# replace the entry's classes
|
||||||
"10-builtin" = {
|
"10-builtin" = {
|
||||||
|
|
@ -192,7 +213,7 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# Its /migrate creates Kanidm accounts for legacy Matrix users
|
# Creates Kanidm accounts for legacy Matrix users
|
||||||
matrixoidc = {
|
matrixoidc = {
|
||||||
kanidmTokenFile = migrateToken;
|
kanidmTokenFile = migrateToken;
|
||||||
args = [
|
args = [
|
||||||
|
|
@ -201,6 +222,15 @@ in
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Creates Kanidm accounts for approved registrations
|
||||||
|
nexusbot = {
|
||||||
|
kanidmTokenFile = registrationToken;
|
||||||
|
args = [
|
||||||
|
"--kanidmUrl"
|
||||||
|
"https://${domain}"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
caddy.virtualHosts.${domain}.extraConfig = ''
|
caddy.virtualHosts.${domain}.extraConfig = ''
|
||||||
reverse_proxy https://${address} {
|
reverse_proxy https://${address} {
|
||||||
transport http {
|
transport http {
|
||||||
|
|
@ -212,11 +242,15 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.services = {
|
systemd.services = {
|
||||||
# Its token is created by kanidm-bootstrap
|
# Their tokens are created by kanidm-bootstrap
|
||||||
matrixoidc = {
|
matrixoidc = {
|
||||||
wants = [ "kanidm-bootstrap.service" ];
|
wants = [ "kanidm-bootstrap.service" ];
|
||||||
after = [ "kanidm-bootstrap.service" ];
|
after = [ "kanidm-bootstrap.service" ];
|
||||||
};
|
};
|
||||||
|
nexusbot = {
|
||||||
|
wants = [ "kanidm-bootstrap.service" ];
|
||||||
|
after = [ "kanidm-bootstrap.service" ];
|
||||||
|
};
|
||||||
|
|
||||||
kanidm-tls = {
|
kanidm-tls = {
|
||||||
description = "Generate Kanidm's loopback TLS certificate";
|
description = "Generate Kanidm's loopback TLS certificate";
|
||||||
|
|
@ -331,7 +365,7 @@ in
|
||||||
# Asserting these memberships in a migration didn't persist, so they're
|
# Asserting these memberships in a migration didn't persist, so they're
|
||||||
# re-applied here on every start. Adding an existing member is a no-op.
|
# re-applied here on every start. Adding an existing member is a no-op.
|
||||||
kanidm group add-members idm_message_senders mail-sender -D idm_admin >/dev/null
|
kanidm group add-members idm_message_senders mail-sender -D idm_admin >/dev/null
|
||||||
kanidm group add-members idm_people_admins migrate -D idm_admin >/dev/null
|
kanidm group add-members idm_people_admins migrate registration -D idm_admin >/dev/null
|
||||||
|
|
||||||
# Usernames must match Matrix localparts, so people can't rename themeselves.
|
# Usernames must match Matrix localparts, so people can't rename themeselves.
|
||||||
# This also locks display and legal names, as Kanidm has no separate permission for those
|
# This also locks display and legal names, as Kanidm has no separate permission for those
|
||||||
|
|
@ -356,6 +390,7 @@ in
|
||||||
|
|
||||||
token mail-sender ${mailSenderToken}
|
token mail-sender ${mailSenderToken}
|
||||||
token migrate ${migrateToken}
|
token migrate ${migrateToken}
|
||||||
|
token registration ${registrationToken}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
(% endif -%)
|
(% endif -%)
|
||||||
|
|
||||||
+ <div class="input-group mb-3 justify-content-md-center text-center">
|
+ <div class="input-group mb-3 justify-content-md-center text-center">
|
||||||
+ <a href="https://federated.nexus/login?redirect_uri=https://auth.federated.nexus/migrate">Don't have a Kanidm account yet? Migrate your legacy Federated Nexus account</a>
|
+ <a href="https://federated.nexus/migrate/">Don't have a Kanidm account yet? Migrate your legacy Federated Nexus account</a>
|
||||||
+ </div>
|
+ </div>
|
||||||
+
|
+
|
||||||
</form>
|
</form>
|
||||||
|
|
|
||||||
65
clients/quadraticserver/kanidm/welcome-email.patch
Normal file
65
clients/quadraticserver/kanidm/welcome-email.patch
Normal file
|
|
@ -0,0 +1,65 @@
|
||||||
|
diff -ru a/proto/src/v1/message.rs b/proto/src/v1/message.rs
|
||||||
|
--- a/proto/src/v1/message.rs 2026-11-15 20:02:57.593682769 -0500
|
||||||
|
+++ b/proto/src/v1/message.rs 2026-11-15 20:03:05.231705521 -0500
|
||||||
|
@@ -12,6 +12,9 @@
|
||||||
|
intent_id: String,
|
||||||
|
#[serde(with = "time::serde::timestamp")]
|
||||||
|
expiry_time: OffsetDateTime,
|
||||||
|
+ // The account has no credentials yet, so this sets them up for the first time
|
||||||
|
+ #[serde(default)]
|
||||||
|
+ first_setup: bool,
|
||||||
|
},
|
||||||
|
AccountSignupRequestV1 {
|
||||||
|
username: String,
|
||||||
|
diff -ru a/server/lib/src/idm/credupdatesession.rs b/server/lib/src/idm/credupdatesession.rs
|
||||||
|
--- a/server/lib/src/idm/credupdatesession.rs 2026-11-15 20:02:57.602151429 -0500
|
||||||
|
+++ b/server/lib/src/idm/credupdatesession.rs 2026-11-15 20:03:05.233821288 -0500
|
||||||
|
@@ -1107,6 +1107,9 @@
|
||||||
|
display_name,
|
||||||
|
intent_id,
|
||||||
|
expiry_time,
|
||||||
|
+ first_setup: account.primary.is_none()
|
||||||
|
+ && account.passkeys.is_empty()
|
||||||
|
+ && account.attested_passkeys.is_empty(),
|
||||||
|
};
|
||||||
|
|
||||||
|
let ident = Identity::message_queue();
|
||||||
|
diff -ru a/tools/mail_sender/src/main.rs b/tools/mail_sender/src/main.rs
|
||||||
|
--- a/tools/mail_sender/src/main.rs 2026-11-15 20:02:57.611181240 -0500
|
||||||
|
+++ b/tools/mail_sender/src/main.rs 2026-11-15 20:03:05.236297186 -0500
|
||||||
|
@@ -94,6 +94,7 @@
|
||||||
|
display_name,
|
||||||
|
intent_id,
|
||||||
|
expiry_time,
|
||||||
|
+ first_setup,
|
||||||
|
} => {
|
||||||
|
let mut reset_url = ctx.instance_url.clone();
|
||||||
|
reset_url.set_path("/ui/reset");
|
||||||
|
@@ -108,6 +109,27 @@
|
||||||
|
.format(&Rfc2822)
|
||||||
|
.unwrap_or("ERROR - invalid expiration time".into());
|
||||||
|
|
||||||
|
+ if *first_setup {
|
||||||
|
+ return (
|
||||||
|
+ format!("Welcome to {0}", ctx.instance_display_name),
|
||||||
|
+ format!(
|
||||||
|
+ r#"Welcome to {instance}, {display_name}
|
||||||
|
+
|
||||||
|
+You can set up your authentication here:
|
||||||
|
+
|
||||||
|
+{reset_url}
|
||||||
|
+
|
||||||
|
+This link will expire at {pretty_expiry_time}
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+msg_id: {message_id}
|
||||||
|
+ "#,
|
||||||
|
+ instance = ctx.instance_display_name,
|
||||||
|
+ message_id = ctx.message_id,
|
||||||
|
+ ),
|
||||||
|
+ );
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
(
|
||||||
|
format!("{0}: Credential Reset Link", ctx.instance_display_name),
|
||||||
|
format!(
|
||||||
|
|
@ -14,56 +14,19 @@
|
||||||
{
|
{
|
||||||
nexusbot = {
|
nexusbot = {
|
||||||
enable = true;
|
enable = true;
|
||||||
botPasswordFile = config.age.secrets."botPassword.age".path;
|
# An access token from a password login, made before continuwuity switched to Kanidm logins
|
||||||
smtpPasswordFile = config.age.secrets."smtpPassword.age".path;
|
botTokenFile = config.age.secrets."botToken.age".path;
|
||||||
args = [
|
args = [
|
||||||
"--socket"
|
"--socket"
|
||||||
socket
|
socket
|
||||||
"--homeserver"
|
"--homeserver"
|
||||||
config.services.matrix-continuwuity.settings.global.well_known.client
|
config.services.matrix-continuwuity.settings.global.well_known.client
|
||||||
"--username"
|
|
||||||
"nexusbot"
|
|
||||||
"--adminRoom"
|
"--adminRoom"
|
||||||
"#admins:federated.nexus"
|
"#admins:federated.nexus"
|
||||||
"--successUri"
|
"--successUri"
|
||||||
"https://federated.nexus/success"
|
"https://federated.nexus/success"
|
||||||
"--failureUri"
|
"--failureUri"
|
||||||
"https://federated.nexus/failure"
|
"https://federated.nexus/failure"
|
||||||
"--inviteTo"
|
|
||||||
"#space:federated.nexus"
|
|
||||||
"--adminName"
|
|
||||||
"conduit"
|
|
||||||
"--email"
|
|
||||||
("inf" + "o@f" + "edera" + "ted.n" + "exus")
|
|
||||||
"--mailDomain"
|
|
||||||
"email-smtp.us-east-1.amazonaws.com"
|
|
||||||
"--mailName"
|
|
||||||
"Federated Nexus"
|
|
||||||
"--mailUsername"
|
|
||||||
"AKIAREHCBHZLJ3FNCCSM"
|
|
||||||
"--subject"
|
|
||||||
"Your registration for Federated Nexus has been accepted!"
|
|
||||||
"--plainText"
|
|
||||||
"Your registration for Federated Nexus has been accepted! Your credentials are:
|
|
||||||
Username: @{username}
|
|
||||||
Password: @{password}
|
|
||||||
|
|
||||||
You can change your password in your favorite Matrix client, or here: https://matrix.federated.nexus/_continuwuity/account/password/change
|
|
||||||
|
|
||||||
If you have any questions, check out our documentation: https://federated.nexus/services/matrix/.
|
|
||||||
|
|
||||||
If you have any issues, reply to this email."
|
|
||||||
"--markdown"
|
|
||||||
"# Your registration for Federated Nexus has been accepted!
|
|
||||||
## Your credentials are:
|
|
||||||
- ### Username: @{username}
|
|
||||||
- ### Password: @{password}
|
|
||||||
|
|
||||||
You can change your password in your favorite Matrix client, or [here](https://matrix.federated.nexus/_continuwuity/account/password/change).
|
|
||||||
|
|
||||||
If you have any questions, check out [our documentation](https://federated.nexus/services/matrix/).
|
|
||||||
|
|
||||||
If you have any issues, reply to this email."
|
|
||||||
];
|
];
|
||||||
group = "caddy";
|
group = "caddy";
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,73 @@
|
||||||
{ lib, pkgs, ... }: {
|
{
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
config,
|
||||||
|
inputs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
client = "matrix";
|
||||||
|
in
|
||||||
|
{
|
||||||
systemd.services.continuwuity = {
|
systemd.services.continuwuity = {
|
||||||
unitConfig.RequiresMountsFor = [ "/var/lib/private/continuwuity/media" ];
|
unitConfig.RequiresMountsFor = [ "/var/lib/private/continuwuity/media" ];
|
||||||
|
# It fetches Kanidm's OIDC metadata once at startup, and logins fail until a restart if that fails
|
||||||
|
requires = [ "kanidm-oauth2-secrets.service" ];
|
||||||
|
wants = [ "kanidm.service" ];
|
||||||
|
after = [
|
||||||
|
"kanidm-oauth2-secrets.service"
|
||||||
|
"kanidm.service"
|
||||||
|
"caddy.service"
|
||||||
|
];
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
MemoryMax = "5.5G";
|
MemoryMax = "5.5G";
|
||||||
MemorySwapMax = "4.5G";
|
MemorySwapMax = "4.5G";
|
||||||
TimeoutStartSec = "10m";
|
TimeoutStartSec = "10m";
|
||||||
Restart = lib.mkForce "always";
|
Restart = lib.mkForce "always";
|
||||||
ExecStartPost = "/bin/sh -c 'until ${lib.getExe pkgs.curl} -s -f https://matrix.federated.nexus/.well-known/matrix/client; do sleep 1; done'";
|
ExecStartPost = "/bin/sh -c 'until ${lib.getExe pkgs.curl} -s -f https://matrix.federated.nexus/.well-known/matrix/client; do sleep 1; done'";
|
||||||
|
LoadCredential = [
|
||||||
|
"oidc-secret:${config.services.kanidm.provision.systems.oauth2.${client}.basicSecretFile}"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
services.kanidm.provision.systems.oauth2.${client} = {
|
||||||
|
displayName = "Matrix";
|
||||||
|
originUrl = "${config.services.matrix-continuwuity.settings.global.well_known.client}/_continuwuity/oidc/complete";
|
||||||
|
originLanding = "https://app.${config.quad.matrix.domain}";
|
||||||
|
imageFile = "${
|
||||||
|
inputs.sable.packages.${pkgs.stdenv.hostPlatform.system}.default
|
||||||
|
}/public/svg/logo.svg";
|
||||||
|
basicSecretFile = "/var/lib/kanidm-oauth2-secrets/${client}";
|
||||||
|
# The username claim is the Matrix localpart
|
||||||
|
preferShortUsername = true;
|
||||||
|
scopeMaps.idm_all_persons = [
|
||||||
|
"openid"
|
||||||
|
"email"
|
||||||
|
"profile"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
quad.matrix = rec {
|
quad.matrix = rec {
|
||||||
enable = true;
|
enable = true;
|
||||||
domain = "federated.nexus";
|
domain = "federated.nexus";
|
||||||
settings = {
|
settings = {
|
||||||
|
auto_join_rooms = [ "#space:${domain}" ];
|
||||||
|
|
||||||
|
# Logins go through Kanidm only. Existing accounts are linked by username
|
||||||
|
# on first login, and new ones are created then
|
||||||
|
oauth.oidc = {
|
||||||
|
discovery_url = "${config.services.kanidm.server.settings.origin}/oauth2/openid/${client}";
|
||||||
|
client_id = client;
|
||||||
|
client_secret_file = "/run/credentials/continuwuity.service/oidc-secret";
|
||||||
|
provider_name = "Federated Nexus";
|
||||||
|
prompt_for_localpart = false;
|
||||||
|
additional_scopes = [
|
||||||
|
"email"
|
||||||
|
"profile"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
admins_list = [
|
admins_list = [
|
||||||
"@nexusbot:federated.nexus"
|
"@nexusbot:federated.nexus"
|
||||||
"@quadradical:federated.nexus"
|
"@quadradical:federated.nexus"
|
||||||
|
|
|
||||||
16
flake.lock
generated
16
flake.lock
generated
|
|
@ -907,11 +907,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1794694767,
|
"lastModified": 1794790630,
|
||||||
"narHash": "sha256-OkyR28RS3gjy5eMME332vZa1atniqi1YGiLQBHVcZ5g=",
|
"narHash": "sha256-Bdm9crlxdbOlzUbLudsoUlASaSMJuvZCrm6qc5jJvm0=",
|
||||||
"ref": "kanidm",
|
"ref": "kanidm",
|
||||||
"rev": "be6b7bdf99b78bb4b1ce998dfe99e1444c254b18",
|
"rev": "08e34fd98a55f1b69a080fa1dbebe281c0473115",
|
||||||
"revCount": 52,
|
"revCount": 55,
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://git.federated.nexus/Henry-Hiles/matrixoidc"
|
"url": "https://git.federated.nexus/Henry-Hiles/matrixoidc"
|
||||||
},
|
},
|
||||||
|
|
@ -968,11 +968,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1794682139,
|
"lastModified": 1794791313,
|
||||||
"narHash": "sha256-+3L78fPwX2C/USrLi38B3Xd1Kmv9h8cdRfCR2TnQNpA=",
|
"narHash": "sha256-+wFjQq+UVWzDS7+FWdoYURewOj7bUINj1LD/QRSnPBY=",
|
||||||
"ref": "refs/heads/main",
|
"ref": "refs/heads/main",
|
||||||
"rev": "cc3320ec54a9dabf75e8ad981169b6cb569b099c",
|
"rev": "3c69fa54d010c3534c9df855b2a2e469b00860bb",
|
||||||
"revCount": 45,
|
"revCount": 47,
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://git.federated.nexus/federated-nexus/nexusbot"
|
"url": "https://git.federated.nexus/federated-nexus/nexusbot"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
5
secrets/botToken.age
Normal file
5
secrets/botToken.age
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
age-encryption.org/v1
|
||||||
|
-> ssh-ed25519 VKQUdQ M5n/VTu7zsanPNj9oiQvbb4BoTWjemwuV1GoB+DUFjQ
|
||||||
|
5LosU8YQ2xuVwlC8bfyHeiuqx6NOVDElSykTsVfLDYE
|
||||||
|
--- ysAguw4CGqsJamR7jMmmYxJqBpdDdZVDN0tr6DYzdc8
|
||||||
|
<EFBFBD>ãÒÉòˆ¨c•3Ú4&ôÙ6ïj’þΜ
ç|e;Vô^]t`F6Ý“ü‰päð¬ƒ:¸t›ätÔ
|
||||||
Loading…
Reference in a new issue