new migration mode
This commit is contained in:
parent
e94ed21061
commit
337b6b9736
3 changed files with 179 additions and 58 deletions
|
|
@ -37,6 +37,7 @@ let
|
|||
bootstrapDir = "/var/lib/kanidm-bootstrap";
|
||||
mailSenderToken = "${bootstrapDir}/mail-sender-token";
|
||||
migrateToken = "${bootstrapDir}/migrate-token";
|
||||
registrationToken = "${bootstrapDir}/registration-token";
|
||||
|
||||
secretsDir = "/var/lib/kanidm-oauth2-secrets";
|
||||
oauth2Clients = builtins.attrNames config.services.kanidm.provision.systems.oauth2;
|
||||
|
|
@ -90,6 +91,8 @@ in
|
|||
./hide-radius.patch
|
||||
# Applies dark mode before the page is drawn, rather than flashing light mode first
|
||||
./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
|
||||
# replace the entry's classes
|
||||
"10-builtin" = {
|
||||
|
|
@ -192,7 +213,7 @@ in
|
|||
};
|
||||
};
|
||||
|
||||
# Its /migrate creates Kanidm accounts for legacy Matrix users
|
||||
# Creates Kanidm accounts for legacy Matrix users
|
||||
matrixoidc = {
|
||||
kanidmTokenFile = migrateToken;
|
||||
args = [
|
||||
|
|
@ -201,6 +222,15 @@ in
|
|||
];
|
||||
};
|
||||
|
||||
# Creates Kanidm accounts for approved registrations
|
||||
nexusbot = {
|
||||
kanidmTokenFile = registrationToken;
|
||||
args = [
|
||||
"--kanidmUrl"
|
||||
"https://${domain}"
|
||||
];
|
||||
};
|
||||
|
||||
caddy.virtualHosts.${domain}.extraConfig = ''
|
||||
reverse_proxy https://${address} {
|
||||
transport http {
|
||||
|
|
@ -212,11 +242,15 @@ in
|
|||
};
|
||||
|
||||
systemd.services = {
|
||||
# Its token is created by kanidm-bootstrap
|
||||
# Their tokens are created by kanidm-bootstrap
|
||||
matrixoidc = {
|
||||
wants = [ "kanidm-bootstrap.service" ];
|
||||
after = [ "kanidm-bootstrap.service" ];
|
||||
};
|
||||
nexusbot = {
|
||||
wants = [ "kanidm-bootstrap.service" ];
|
||||
after = [ "kanidm-bootstrap.service" ];
|
||||
};
|
||||
|
||||
kanidm-tls = {
|
||||
description = "Generate Kanidm's loopback TLS certificate";
|
||||
|
|
@ -331,7 +365,7 @@ in
|
|||
# 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.
|
||||
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.
|
||||
# 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 migrate ${migrateToken}
|
||||
token registration ${registrationToken}
|
||||
'';
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
(% endif -%)
|
||||
|
||||
+ <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>
|
||||
+
|
||||
</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!(
|
||||
Loading…
Reference in a new issue