refactor(base): SimpleLogin's forwarding page on the OpenID Connect module (ADR 0023)

halkyon_base depends on halkyon_oidc_server, and its forwarding page
is now the module's (`addOidcCallbackForwarding`) with Halkyon's table
of apps and its page in English or German; its tests keep what is
Halkyon's own, the rest is tested in the module.

Every host now includes the module: migrations `…-oidc-module` in
halkyon_base, Learn and Todo create its two tables (no data touched)
and record its version; Learn's devices get them empty, as they have
halkyon_base's server-only tables. halkyon_base_client depends on
halkyon_oidc_client, whose models its generated code uses, and Learn's
server image copies both packages into its narrowed workspace.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
Tizian 「ティツィアーン」 2026-10-23 20:28:37 +02:00
commit 620ad270db
Signed by: raisondetredev
GPG key ID: 07F6FCF405488B64
10 changed files with 43572 additions and 408 deletions

View file

@ -11,6 +11,7 @@
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'package:halkyon_base_client/halkyon_base_client.dart' as _ihk4p5t7;
import 'package:halkyon_oidc_client/halkyon_oidc_client.dart' as _ibkpwzgl;
import 'package:http/http.dart' as _i85jenna;
import 'package:serverpod_auth_core_client/serverpod_auth_core_client.dart'
as _iacc;
@ -23,6 +24,7 @@ class Modules {
Modules(Client client) {
base = _ihk4p5t7.Caller(client);
serverpod_auth_idp = _iaic.Caller(client);
oidc = _ibkpwzgl.Caller(client);
serverpod_auth_core = _iacc.Caller(client);
}
@ -30,6 +32,8 @@ class Modules {
late final _iaic.Caller serverpod_auth_idp;
late final _ibkpwzgl.Caller oidc;
late final _iacc.Caller serverpod_auth_core;
}
@ -72,6 +76,7 @@ class Client extends _isc.ServerpodClientShared {
Map<String, _isc.ModuleEndpointCaller> get moduleLookup => {
'base': modules.base,
'serverpod_auth_idp': modules.serverpod_auth_idp,
'oidc': modules.oidc,
'serverpod_auth_core': modules.serverpod_auth_core,
};
}

View file

@ -12,6 +12,7 @@
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'package:halkyon_base_client/halkyon_base_client.dart' as _ihk4p5t7;
import 'package:halkyon_oidc_client/halkyon_oidc_client.dart' as _ibkpwzgl;
import 'package:serverpod_auth_core_client/serverpod_auth_core_client.dart'
as _iacc;
import 'package:serverpod_auth_idp_client/serverpod_auth_idp_client.dart'
@ -59,6 +60,9 @@ class Protocol extends _isc.SerializationManager {
try {
return _iaic.Protocol().deserialize<T>(data, t);
} on _isc.DeserializationTypeNotFoundException catch (_) {}
try {
return _ibkpwzgl.Protocol().deserialize<T>(data, t);
} on _isc.DeserializationTypeNotFoundException catch (_) {}
try {
return _iacc.Protocol().deserialize<T>(data, t);
} on _isc.DeserializationTypeNotFoundException catch (_) {}
@ -93,6 +97,10 @@ class Protocol extends _isc.SerializationManager {
? className
: 'serverpod_auth_idp.$className';
}
className = _ibkpwzgl.Protocol().getClassNameForObject(data);
if (className != null) {
return className.contains('.') ? className : 'halkyon_oidc.$className';
}
className = _iacc.Protocol().getClassNameForObject(data);
if (className != null) {
return className.contains('.')
@ -116,6 +124,10 @@ class Protocol extends _isc.SerializationManager {
data['className'] = dataClassName.substring(19);
return _iaic.Protocol().deserializeByClassName(data);
}
if (dataClassName.startsWith('halkyon_oidc.')) {
data['className'] = dataClassName.substring(13);
return _ibkpwzgl.Protocol().deserializeByClassName(data);
}
if (dataClassName.startsWith('serverpod_auth_core.')) {
data['className'] = dataClassName.substring(20);
return _iacc.Protocol().deserializeByClassName(data);
@ -126,6 +138,7 @@ class Protocol extends _isc.SerializationManager {
void _registerHostProtocols() {
_ihk4p5t7.Protocol().registerHostProtocol('halkyon_todo', this);
_iaic.Protocol().registerHostProtocol('halkyon_todo', this);
_ibkpwzgl.Protocol().registerHostProtocol('halkyon_todo', this);
_iacc.Protocol().registerHostProtocol('halkyon_todo', this);
}
@ -147,6 +160,9 @@ class Protocol extends _isc.SerializationManager {
try {
return _iaic.Protocol().mapRecordToJson(record);
} catch (_) {}
try {
return _ibkpwzgl.Protocol().mapRecordToJson(record);
} catch (_) {}
try {
return _iacc.Protocol().mapRecordToJson(record);
} catch (_) {}

View file

@ -11,6 +11,7 @@
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'package:halkyon_base_server/halkyon_base_server.dart' as _ik8molhd;
import 'package:halkyon_oidc_server/halkyon_oidc_server.dart' as _ipoqfiqr;
import 'package:halkyon_todo_server/src/generated/future_calls.dart'
as _i772x17y;
import 'package:serverpod/serverpod.dart' as _is;
@ -27,6 +28,8 @@ class Endpoints extends _is.EndpointDispatch {
..initializeEndpoints(server);
modules['serverpod_auth_idp'] = _iais.Endpoints()
..initializeEndpoints(server);
modules['halkyon_oidc'] = _ipoqfiqr.Endpoints()
..initializeEndpoints(server);
modules['serverpod_auth_core'] = _iacs.Endpoints()
..initializeEndpoints(server);
}

View file

@ -12,6 +12,7 @@
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'package:halkyon_base_server/halkyon_base_server.dart' as _ik8molhd;
import 'package:halkyon_oidc_server/halkyon_oidc_server.dart' as _ipoqfiqr;
import 'package:serverpod/protocol.dart' as _isp;
import 'package:serverpod/serverpod.dart' as _is;
import 'package:serverpod_auth_core_server/serverpod_auth_core_server.dart'
@ -29,6 +30,7 @@ class Protocol extends _is.DatabaseSerializationManager {
static List<_isp.TableDefinition> get targetTableDefinitions => [
..._ik8molhd.Protocol.targetTableDefinitions,
..._iais.Protocol.targetTableDefinitions,
..._ipoqfiqr.Protocol.targetTableDefinitions,
..._iacs.Protocol.targetTableDefinitions,
..._isp.Protocol.targetTableDefinitions,
];
@ -66,6 +68,9 @@ class Protocol extends _is.DatabaseSerializationManager {
try {
return _iais.Protocol().deserialize<T>(data, t);
} on _is.DeserializationTypeNotFoundException catch (_) {}
try {
return _ipoqfiqr.Protocol().deserialize<T>(data, t);
} on _is.DeserializationTypeNotFoundException catch (_) {}
try {
return _iacs.Protocol().deserialize<T>(data, t);
} on _is.DeserializationTypeNotFoundException catch (_) {}
@ -103,6 +108,10 @@ class Protocol extends _is.DatabaseSerializationManager {
? className
: 'serverpod_auth_idp.$className';
}
className = _ipoqfiqr.Protocol().getClassNameForObject(data);
if (className != null) {
return className.contains('.') ? className : 'halkyon_oidc.$className';
}
className = _iacs.Protocol().getClassNameForObject(data);
if (className != null) {
return className.contains('.')
@ -130,6 +139,10 @@ class Protocol extends _is.DatabaseSerializationManager {
data['className'] = dataClassName.substring(19);
return _iais.Protocol().deserializeByClassName(data);
}
if (dataClassName.startsWith('halkyon_oidc.')) {
data['className'] = dataClassName.substring(13);
return _ipoqfiqr.Protocol().deserializeByClassName(data);
}
if (dataClassName.startsWith('serverpod_auth_core.')) {
data['className'] = dataClassName.substring(20);
return _iacs.Protocol().deserializeByClassName(data);
@ -144,6 +157,7 @@ class Protocol extends _is.DatabaseSerializationManager {
void _registerHostProtocols() {
_ik8molhd.Protocol().registerHostProtocol('halkyon_todo', this);
_iais.Protocol().registerHostProtocol('halkyon_todo', this);
_ipoqfiqr.Protocol().registerHostProtocol('halkyon_todo', this);
_iacs.Protocol().registerHostProtocol('halkyon_todo', this);
}
@ -161,6 +175,12 @@ class Protocol extends _is.DatabaseSerializationManager {
return table;
}
}
{
var table = _ipoqfiqr.Protocol().getTableForType(t);
if (table != null) {
return table;
}
}
{
var table = _iacs.Protocol().getTableForType(t);
if (table != null) {
@ -198,6 +218,9 @@ class Protocol extends _is.DatabaseSerializationManager {
try {
return _iais.Protocol().mapRecordToJson(record);
} catch (_) {}
try {
return _ipoqfiqr.Protocol().mapRecordToJson(record);
} catch (_) {}
try {
return _iacs.Protocol().mapRecordToJson(record);
} catch (_) {}

View file

@ -0,0 +1,34 @@
{
"__className__": "serverpod.DatabaseDefinition",
"schemaVersion": 2,
"moduleName": "halkyon_todo",
"tables": [],
"installedModules": [
{
"__className__": "serverpod.DatabaseMigrationVersion",
"module": "halkyon_base",
"version": "20261023181809816-oidc-module"
},
{
"__className__": "serverpod.DatabaseMigrationVersion",
"module": "serverpod",
"version": "20260824182259319"
},
{
"__className__": "serverpod.DatabaseMigrationVersion",
"module": "serverpod_auth_idp",
"version": "20260924105404509"
},
{
"__className__": "serverpod.DatabaseMigrationVersion",
"module": "halkyon_oidc",
"version": "20261023180644988"
},
{
"__className__": "serverpod.DatabaseMigrationVersion",
"module": "serverpod_auth_core",
"version": "20260924105232991"
}
],
"migrationApiVersion": 1
}

View file

@ -0,0 +1,229 @@
{
"__className__": "serverpod.DatabaseMigration",
"actions": [
{
"__className__": "serverpod.DatabaseMigrationAction",
"type": "createTable",
"createTable": {
"__className__": "serverpod.TableDefinition",
"name": "halkyon_oidc_attempt",
"dartName": "OidcAttempt",
"module": "halkyon_oidc",
"schema": "public",
"columns": [
{
"__className__": "serverpod.ColumnDefinition",
"name": "id",
"fieldName": "id",
"columnType": 7,
"isNullable": false,
"columnDefault": "random",
"dartType": "UuidValue?"
},
{
"__className__": "serverpod.ColumnDefinition",
"name": "provider",
"fieldName": "provider",
"columnType": 0,
"isNullable": false,
"dartType": "String"
},
{
"__className__": "serverpod.ColumnDefinition",
"name": "state",
"fieldName": "state",
"columnType": 0,
"isNullable": false,
"dartType": "String"
},
{
"__className__": "serverpod.ColumnDefinition",
"name": "nonce",
"fieldName": "nonce",
"columnType": 0,
"isNullable": false,
"dartType": "String"
},
{
"__className__": "serverpod.ColumnDefinition",
"name": "codeVerifier",
"fieldName": "codeVerifier",
"columnType": 0,
"isNullable": true,
"dartType": "String?"
},
{
"__className__": "serverpod.ColumnDefinition",
"name": "callerId",
"fieldName": "callerId",
"columnType": 7,
"isNullable": true,
"dartType": "UuidValue?"
},
{
"__className__": "serverpod.ColumnDefinition",
"name": "subject",
"fieldName": "subject",
"columnType": 0,
"isNullable": true,
"dartType": "String?"
},
{
"__className__": "serverpod.ColumnDefinition",
"name": "expiresAt",
"fieldName": "expiresAt",
"columnType": 4,
"isNullable": false,
"dartType": "DateTime"
}
],
"foreignKeys": [
{
"__className__": "serverpod.ForeignKeyDefinition",
"constraintName": "halkyon_oidc_attempt_fk_0",
"columns": [
"callerId"
],
"referenceTable": "serverpod_auth_core_user",
"referenceTableSchema": "public",
"referenceColumns": [
"id"
],
"onUpdate": 3,
"onDelete": 4
}
],
"indexes": [
{
"__className__": "serverpod.IndexDefinition",
"indexName": "halkyon_oidc_attempt_expires_idx",
"elements": [
{
"__className__": "serverpod.IndexElementDefinition",
"type": 0,
"definition": "expiresAt"
}
],
"type": "btree",
"isUnique": false,
"isPrimary": false
}
],
"managed": true
}
},
{
"__className__": "serverpod.DatabaseMigrationAction",
"type": "createTable",
"createTable": {
"__className__": "serverpod.TableDefinition",
"name": "halkyon_oidc_identity",
"dartName": "OidcIdentity",
"module": "halkyon_oidc",
"schema": "public",
"columns": [
{
"__className__": "serverpod.ColumnDefinition",
"name": "id",
"fieldName": "id",
"columnType": 7,
"isNullable": false,
"columnDefault": "random_v7",
"dartType": "UuidValue?"
},
{
"__className__": "serverpod.ColumnDefinition",
"name": "authUserId",
"fieldName": "authUserId",
"columnType": 7,
"isNullable": false,
"dartType": "UuidValue"
},
{
"__className__": "serverpod.ColumnDefinition",
"name": "provider",
"fieldName": "provider",
"columnType": 0,
"isNullable": false,
"dartType": "String"
},
{
"__className__": "serverpod.ColumnDefinition",
"name": "subject",
"fieldName": "subject",
"columnType": 0,
"isNullable": false,
"dartType": "String"
},
{
"__className__": "serverpod.ColumnDefinition",
"name": "createdAt",
"fieldName": "createdAt",
"columnType": 4,
"isNullable": false,
"dartType": "DateTime"
}
],
"foreignKeys": [
{
"__className__": "serverpod.ForeignKeyDefinition",
"constraintName": "halkyon_oidc_identity_fk_0",
"columns": [
"authUserId"
],
"referenceTable": "serverpod_auth_core_user",
"referenceTableSchema": "public",
"referenceColumns": [
"id"
],
"onUpdate": 3,
"onDelete": 4
}
],
"indexes": [
{
"__className__": "serverpod.IndexDefinition",
"indexName": "halkyon_oidc_identity_subject_idx",
"elements": [
{
"__className__": "serverpod.IndexElementDefinition",
"type": 0,
"definition": "provider"
},
{
"__className__": "serverpod.IndexElementDefinition",
"type": 0,
"definition": "subject"
}
],
"type": "btree",
"isUnique": true,
"isPrimary": false
},
{
"__className__": "serverpod.IndexDefinition",
"indexName": "halkyon_oidc_identity_person_idx",
"elements": [
{
"__className__": "serverpod.IndexElementDefinition",
"type": 0,
"definition": "authUserId"
},
{
"__className__": "serverpod.IndexElementDefinition",
"type": 0,
"definition": "provider"
}
],
"type": "btree",
"isUnique": true,
"isPrimary": false
}
],
"managed": true
}
}
],
"warnings": [],
"migrationApiVersion": 1
}

View file

@ -0,0 +1,134 @@
BEGIN;
--
-- Function: gen_random_uuid_v7()
-- Source: https://gist.github.com/kjmph/5bd772b2c2df145aa645b837da7eca74
-- License: MIT (copyright notice included on the generator source code).
--
create or replace function gen_random_uuid_v7()
returns uuid
as $$
begin
-- use random v4 uuid as starting point (which has the same variant we need)
-- then overlay timestamp
-- then set version 7 by flipping the 2 and 1 bit in the version 4 string
return encode(
set_bit(
set_bit(
overlay(uuid_send(gen_random_uuid())
placing substring(int8send(floor(extract(epoch from clock_timestamp()) * 1000)::bigint) from 3)
from 1 for 6
),
52, 1
),
53, 1
),
'hex')::uuid;
end
$$
language plpgsql
volatile;
--
-- ACTION CREATE TABLE
--
CREATE TABLE "halkyon_oidc_attempt" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid(),
"provider" text NOT NULL,
"state" text NOT NULL,
"nonce" text NOT NULL,
"codeVerifier" text,
"callerId" uuid,
"subject" text,
"expiresAt" timestamp without time zone NOT NULL
);
-- Indexes
CREATE INDEX "halkyon_oidc_attempt_expires_idx" ON "halkyon_oidc_attempt" USING btree ("expiresAt");
--
-- ACTION CREATE TABLE
--
CREATE TABLE "halkyon_oidc_identity" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid_v7(),
"authUserId" uuid NOT NULL,
"provider" text NOT NULL,
"subject" text NOT NULL,
"createdAt" timestamp without time zone NOT NULL
);
-- Indexes
CREATE UNIQUE INDEX "halkyon_oidc_identity_subject_idx" ON "halkyon_oidc_identity" USING btree ("provider", "subject");
CREATE UNIQUE INDEX "halkyon_oidc_identity_person_idx" ON "halkyon_oidc_identity" USING btree ("authUserId", "provider");
--
-- ACTION CREATE FOREIGN KEY
--
ALTER TABLE ONLY "halkyon_oidc_attempt"
ADD CONSTRAINT "halkyon_oidc_attempt_fk_0"
FOREIGN KEY("callerId")
REFERENCES "serverpod_auth_core_user"("id")
ON DELETE CASCADE
ON UPDATE NO ACTION;
--
-- ACTION CREATE FOREIGN KEY
--
ALTER TABLE ONLY "halkyon_oidc_identity"
ADD CONSTRAINT "halkyon_oidc_identity_fk_0"
FOREIGN KEY("authUserId")
REFERENCES "serverpod_auth_core_user"("id")
ON DELETE CASCADE
ON UPDATE NO ACTION;
--
-- MIGRATION VERSION FOR halkyon_todo
--
INSERT INTO "serverpod_migrations" ("module", "version", "timestamp")
VALUES ('halkyon_todo', '20261023181810436-oidc-module', now())
ON CONFLICT ("module")
DO UPDATE SET "version" = '20261023181810436-oidc-module', "timestamp" = now();
--
-- MIGRATION VERSION FOR halkyon_base
--
INSERT INTO "serverpod_migrations" ("module", "version", "timestamp")
VALUES ('halkyon_base', '20261023181809816-oidc-module', now())
ON CONFLICT ("module")
DO UPDATE SET "version" = '20261023181809816-oidc-module', "timestamp" = now();
--
-- MIGRATION VERSION FOR serverpod
--
INSERT INTO "serverpod_migrations" ("module", "version", "timestamp")
VALUES ('serverpod', '20260824182259319', now())
ON CONFLICT ("module")
DO UPDATE SET "version" = '20260824182259319', "timestamp" = now();
--
-- MIGRATION VERSION FOR serverpod_auth_idp
--
INSERT INTO "serverpod_migrations" ("module", "version", "timestamp")
VALUES ('serverpod_auth_idp', '20260924105404509', now())
ON CONFLICT ("module")
DO UPDATE SET "version" = '20260924105404509', "timestamp" = now();
--
-- MIGRATION VERSION FOR halkyon_oidc
--
INSERT INTO "serverpod_migrations" ("module", "version", "timestamp")
VALUES ('halkyon_oidc', '20261023180644988', now())
ON CONFLICT ("module")
DO UPDATE SET "version" = '20261023180644988', "timestamp" = now();
--
-- MIGRATION VERSION FOR serverpod_auth_core
--
INSERT INTO "serverpod_migrations" ("module", "version", "timestamp")
VALUES ('serverpod_auth_core', '20260924105232991', now())
ON CONFLICT ("module")
DO UPDATE SET "version" = '20260924105232991', "timestamp" = now();
COMMIT;

View file

@ -16,3 +16,4 @@
20261021100422779-session-ended-warning
20261021110200318-second-factor-paths
20261021134804476-reset-hold-outs
20261023181810436-oidc-module