Add an `id.nul.ie` OpenID Connect login source to Gitea, kept up to date from `preStart` since Gitea stores login sources in its database. Its client is declared on `middleman` with the secret shared by both. Registration stays disabled, so a Pocket ID sign-in links to an existing account. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
eeb1f2d15c
commit
540366abac
4 files changed
+63
-1
No files matched your search
@@ -20,6 +20,13 @@ The Git forge at `git.nul.ie` (self-registration disabled), configured in
|
||||
`gitea`, on [`object`](shill/containers/object.md)) — the secret is spliced into `app.ini` at
|
||||
startup.
|
||||
- Mail goes out via `mail.nul.ie`, including the issue-reply incoming-mail poller.
|
||||
- **Sign-in with Pocket ID:** `preStart` adds or updates the `id.nul.ie` OpenID Connect login
|
||||
source. The client `gitea` and its secret `gitea/oidc-secret.txt` are declared on
|
||||
[`middleman`](shill/containers/middleman.md#pocket-id).
|
||||
- Registration stays disabled, so a Pocket ID sign-in can't create an account. The first one
|
||||
links to an existing account after signing in with its password.
|
||||
- The CLI only takes the secret as an argument, so it is briefly visible in the process list
|
||||
while `preStart` runs.
|
||||
|
||||
### Gitea Actions runner
|
||||
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
{ lib, pkgs, config, assignments, allAssignments, ... }:
|
||||
let
|
||||
inherit (lib) mkMerge;
|
||||
inherit (lib) mkMerge mkAfter getExe;
|
||||
inherit (lib.my.c) pubDomain;
|
||||
inherit (lib.my.c.colony) prefixes;
|
||||
|
||||
# Pocket ID login source, client `gitea` (declared on `middleman`)
|
||||
oidcSource = "id.${pubDomain}";
|
||||
in
|
||||
{
|
||||
config = {
|
||||
@@ -48,6 +51,31 @@ in
|
||||
# The default /tmp is on the small tmpfs root, so keep them on the state volume.
|
||||
environment.TMPDIR = "${config.services.gitea.stateDir}/tmp";
|
||||
}
|
||||
{
|
||||
# Gitea keeps login sources in its database: add the Pocket ID one, or bring it up to
|
||||
# date. The CLI only takes the secret as an argument.
|
||||
preStart = mkAfter (
|
||||
let
|
||||
gitea = getExe config.services.gitea.package;
|
||||
in
|
||||
''
|
||||
oidc_args=(
|
||||
--name '${oidcSource}'
|
||||
--provider openidConnect
|
||||
--key gitea
|
||||
--secret "$(< '${config.age.secrets."gitea/oidc-secret.txt".path}')"
|
||||
--auto-discover-url 'https://${oidcSource}/.well-known/openid-configuration'
|
||||
--scopes openid --scopes email --scopes profile
|
||||
)
|
||||
|
||||
oidc_id="$(${gitea} admin auth list | awk '$2 == "${oidcSource}" { print $1 }')"
|
||||
if [ -n "$oidc_id" ]; then
|
||||
${gitea} admin auth update-oauth --id "$oidc_id" "''${oidc_args[@]}"
|
||||
else
|
||||
${gitea} admin auth add-oauth "''${oidc_args[@]}"
|
||||
fi
|
||||
'');
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
@@ -139,6 +167,8 @@ in
|
||||
"gitea/db.txt" = ownedByGit;
|
||||
"gitea/mail.txt" = ownedByGit;
|
||||
"gitea/minio.txt" = ownedByGit;
|
||||
# Shared with `middleman`, which registers it with Pocket ID
|
||||
"gitea/oidc-secret.txt" = ownedByGit;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -15,6 +15,8 @@ in
|
||||
"middleman/pocket-id-api-key" = { };
|
||||
# `OAUTH2_PROXY_CLIENT_SECRET` and `OAUTH2_PROXY_COOKIE_SECRET`
|
||||
"middleman/oauth2-proxy.env" = { };
|
||||
# Client secrets shared with the boxes that run the apps
|
||||
"gitea/oidc-secret.txt" = { };
|
||||
};
|
||||
|
||||
pocket-id = {
|
||||
@@ -38,6 +40,14 @@ in
|
||||
key = "OAUTH2_PROXY_CLIENT_SECRET";
|
||||
};
|
||||
};
|
||||
|
||||
# Gitea's `id.nul.ie` login source (`git` VM)
|
||||
gitea = {
|
||||
name = "Gitea";
|
||||
callbackURLs = [ "https://git.${pubDomain}/user/oauth2/id.${pubDomain}/callback" ];
|
||||
launchURL = "https://git.${pubDomain}/";
|
||||
secret.file = config.age.secrets."gitea/oidc-secret.txt".path;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
-----BEGIN AGE ENCRYPTED FILE-----
|
||||
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IHNzaC1lZDI1NTE5IGpJOFJBZyBzU2lH
|
||||
U05YNG5ISEJtTklOZmZRUUI3MWxuU1JRWG0vNEIxekt3NTdWYVdJCldDMENWenl1
|
||||
ZmZCTW1ySFBXZFEvbHZhR0NDOWpLSzhNRTZUcFU1NWZXUWcKLT4gc3NoLWVkMjU1
|
||||
MTkgVkZjdzVnIDdXSXdnK1VvQzJrbWMyRzltL3BZMEZPV2pEV1lSUW5ySXkxaDRC
|
||||
RjRMVDAKRjVRSm9sMGRNUTBWYkdWNlEwKzNTTU8xRXBmV1JDREhtNThabFRIVERU
|
||||
MAotPiBYMjU1MTkgdHFnZ1RKQlRDTmg0TksvaGgrUER6SU5MYWV6WlpEWXA3Qktv
|
||||
MFZJTktTSQpyMHhRb0FNeGFFZkIvUUxjMWlVbkxRY2pKZnhSanlrUWFITWZHUE1i
|
||||
dldvCi0+IFgyNTUxOSBGbkhrVlZYYjZIakZ5MnZ5ZDJXdnoycEVtL08zYjNjNUty
|
||||
OTY2amsrWTJnCk9neE80T25naFBDV3pjZXh0QmFKNW9YZ1VHdXJsREJidHlNRUY5
|
||||
Y0haTDAKLT4gdEkuc210LWdyZWFzZSA0UT5jYyBkICUgIzArNQpCVE5aQnM1blNO
|
||||
L0Nvb1hDMTRSOVNHUmlTM1lmZWcKLS0tIGFBTDN1ZUhSM21LaVFLZDBUQkFJcDJZ
|
||||
OUVSYVp5Q2NIL01IUTNsSmQ3Y2MKAuYjogUq28f/Cdf5jd/RkWaPZEqA+qGAmTnx
|
||||
fXgii0zfKVsAMGtro8wB4RdKYcvyW86k7zYaZobXHzR4ApCF+Zg=
|
||||
-----END AGE ENCRYPTED FILE-----
|
||||
Reference in new issue
Block a user