Compare commits

...
1 Commits
14 changed files with 378 additions and 169 deletions

No files matched your search

+24
View File
@@ -1796,3 +1796,27 @@ Consequences: A change made during a run is applied by the extra run that follow
A plain `systemctl restart linux-manager-setup` still kills a run in progress; the documentation
names `linux-manager-config-edit apply` instead. A run that fails runs once more when a request came
during it, and the unit's result is that of the last run.
## ADR-64: The schema is two LDIF files, and the PKI part is a schema of its own
Status: Accepted
Context: An application other than Linux Manager, such as Simple CA, is to keep its CAs in OpenLDAP
in Linux Manager's PKI classes, either on the server's own slapd or on a slapd without Linux
Manager. The second needs the PKI's definitions as a file its administrator can load, without the
account, OpenID Provider and role classes. The first needs an account other than root that may
read and write the keys, which no account could.
Decision: The schema is defined only in two LDIF files of `/usr/share/linux-manager/schema/`, in the
form `ldapadd` loads into `cn=config`: `linux-manager-pki.ldif` (`cn=linux-manager-pki`), the CAs,
the certificates and the host certificates, which needs only the core schema, and
`linux-manager.ldif` (`cn=linux-manager`), the rest. Setup loads each into its own schema entry, the
same way a slapd without Linux Manager loads the PKI file. A certificate may name what it is filed
under with `linuxManagerCertificateName`, which Linux Manager does not set. The members of the group
`pki-managers` may manage `ou=pki` with its keys; an application binds as a service account in that
group. On a slapd without Linux Manager, access is that slapd's administrator's business.
Consequences: One file serves both kinds of slapd, so the definitions cannot drift apart. The group
is an ordinary one, made with its first member; until it exists, only root reads the keys, and
renaming it takes the access away. A server whose slapd holds the PKI definitions inside
`cn=linux-manager` is installed anew, as slapd refuses the same OIDs in a second entry.
+21
View File
@@ -1,5 +1,26 @@
# Changelog
## 0.43.0 - 2026-11-24 14:30:50 +0100
feature: the PKI's schema is a file of its own that another slapd loads, a certificate can carry the
name an application files it under, and the members of pki-managers manage the PKI with its keys.
- The directory's schema is loaded from /usr/share/linux-manager/schema/: linux-manager-pki.ldif,
the CAs and certificates, as the schema entry cn=linux-manager-pki, and linux-manager.ldif, the
accounts, OpenID Provider and roles, as cn=linux-manager. A slapd without Linux Manager loads
linux-manager-pki.ldif with ldapadd; it needs only the core schema.
- A certificate entry may have linuxManagerCertificateName, indexed for equality, the name an
application such as Simple CA files the certificate under.
- The members of the group pki-managers read and write ou=pki with its keys, so an application
binds as a service account in that group; the group is made with linux-manager-group add.
- A server installed before this version holds the PKI definitions inside cn=linux-manager and
is installed anew.
- The development VM of lm-dev-vm.py, lm-dev-otp-register.py and lm-dev-otp-code.py is named
router by default, and its credentials are in .lm-dev-config/vm-lm-dev-router.json.
- lm-dev-vm.py create reuses the password and otp_url of the VM's credentials file and generates
only those it lacks, and remove keeps the file, so a VM made again has the same password and
TOTP token.
## 0.42.0-2 - 2026-11-24 06:51:04 +0100
update: the history of the package is CHANGELOG.md, from which the build writes debian/changelog,
+33 -2
View File
@@ -162,7 +162,10 @@ Table of Contents
6.2. LDAP Attribute Types
Every attribute type below has the status active, was allocated on
2026-11-21, and is defined in "linuxmanager_ldap.py" of this
2026-11-21 unless its entry gives another date, and is defined in
"linux-manager-pki.ldif" (the PKI: .2.1.2 to .2.1.12 and .2.1.24 to
.2.1.28) or "linux-manager.ldif" (the others) in
"debian-package/src/usr/share/linux-manager/schema/" of this
repository.
.2.1.1 linuxManagerScope
@@ -236,10 +239,34 @@ Table of Contents
.2.1.23 linuxManagerResourceScope
A scope of a resource of the OpenID Provider
.2.1.24 linuxManagerToken
The Simple CA token that signs the issuing CAs
Allocated: 2026-11-23
.2.1.25 linuxManagerUpstreamName
The Simple CA issuing CA of the token
Allocated: 2026-11-23
.2.1.26 linuxManagerCertificateChain
A certificate and its chain, PEM
Allocated: 2026-11-24
.2.1.27 linuxManagerRequestKey
The private key of a CSR, PEM
Allocated: 2026-11-24
.2.1.28 linuxManagerCertificateName
The name a certificate is filed under by the application
that keeps it
Allocated: 2026-11-24
6.3. LDAP Object Classes
Every object class below has the status active, was allocated on
2026-11-21, and is defined in "linuxmanager_ldap.py" of this
2026-11-21 unless its entry gives another date, and is defined in
"linux-manager-pki.ldif" (.2.2.2, .2.2.3 and .2.2.5) or
"linux-manager.ldif" (.2.2.1 and .2.2.4) in
"debian-package/src/usr/share/linux-manager/schema/" of this
repository.
.2.2.1 linuxManagerAccount
@@ -254,6 +281,10 @@ Table of Contents
.2.2.4 linuxManagerRole
Structural: a role of a resource of the OpenID Provider
.2.2.5 linuxManagerHostCertificate
Structural: a certificate of the server kept with its key
Allocated: 2026-11-24
7. Requesting an OID
An allocation is a change to this document. The change adds an
+30 -5
View File
@@ -497,14 +497,37 @@ A CA entry (class `linuxManagerAuthority`) has its certificate (`cACertificate;b
(`certificateRevocationList;binary`) and CRL number. A certificate entry (class
`linuxManagerCertificate`) has the certificate (`userCertificate;binary`), its kind (`ca`, `router`,
`user` or `external`), template, names, expiry and revocation, and for the server's and the users'
certificates the key. A user's certificate is also the `userCertificate` of the user's entry. No
account of the directory reads a key (`linuxManagerPrivateKey`); only root does, through the local
socket. `slapcat` writes the whole PKI into every backup with the users.
certificates the key. A user's certificate is also the `userCertificate` of the user's entry. A
certificate may also have `linuxManagerCertificateName`, the name an application other than Linux
Manager files it under; Linux Manager does not set it. Keys (`linuxManagerPrivateKey`) are read by
root, through the local socket, and by the members of the group `pki-managers`; no other account
reads them. `slapcat` writes the whole PKI into every backup with the users.
```sh
ldapsearch -Q -Y EXTERNAL -H ldapi:/// -b ou=pki,dc=linux-manager,dc=local -s one cn
```
### The PKI schema in another application
The PKI's classes and attributes are a schema of their own, `linux-manager-pki`, in
`/usr/share/linux-manager/schema/linux-manager-pki.ldif`; it needs only slapd's core schema. An
application that keeps its CAs in LDAP, such as Simple CA, uses it in one of two ways:
- **On the server's slapd.** The application binds as a service account of the server, which is a
member of `pki-managers`; the members of that group read and write `ou=pki` with its keys. The
group is made with its first member, and renaming it takes the access away:
```sh
linux-manager-group add pki-managers --member simple-ca
```
- **On a slapd without Linux Manager.** Its administrator loads the schema and grants the identity
the application binds as, such as the database's administrator, the access it needs:
```sh
ldapadd -Y EXTERNAL -H ldapi:/// -f linux-manager-pki.ldif
```
### The CAs
The root signs the issuing CAs only (path length 1), and the issuing CAs sign the certificates
@@ -773,8 +796,10 @@ is switched on:
password;
- `ou=users` holds one entry per user, named by `uid`: an `inetOrgPerson` for a VPN user, an
`account` for a Manager-only account (see Managing users);
- the package's own schema, `cn=linux-manager,cn=schema,cn=config`, under the OID
`1.3.6.1.4.1.67380.10.1.2`, listed in `OID-REGISTRY.txt`: the auxiliary class
- the package's own schema under the OID `1.3.6.1.4.1.67380.10.1.2`, listed in
`OID-REGISTRY.txt`, in two schema entries loaded from `/usr/share/linux-manager/schema/`:
`cn=linux-manager-pki,cn=schema,cn=config`, the PKI (see Certificates), and
`cn=linux-manager,cn=schema,cn=config`, the accounts, with the auxiliary class
`linuxManagerAccount`, which Manager-only and service accounts have, and the attribute
`linuxManagerScope`, authorization scopes, of which `service` marks a service account;
`displayName` and `description` are the display name and the description of a service
+3 -3
View File
@@ -2,21 +2,21 @@
"""Print the current TOTP code of a user of a Linux Manager VM: lm-dev-otp-code.py.
The code is the one of the key <vm>-<user> in the TOTP engine of the Vault of the project --project
(LXD_PROJECT, lm-dev by default), for --user (admin by default) of the VM --vm (lm-dev), which
(LXD_PROJECT, lm-dev by default), for --user (admin by default) of the VM --vm (router), which
lm-dev-otp-register.py or lm-dev-vm.py create enrolled.
"""
import argparse
import sys
from lm_dev import PROJECT, VaultError, otp_code, setting
from lm_dev import PROJECT, VM, VaultError, otp_code, setting
def main():
parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])
parser.add_argument('--project', default=setting('LXD_PROJECT', PROJECT),
help=f'the project of the VM (LXD_PROJECT, default {PROJECT})')
parser.add_argument('--vm', default='lm-dev', help='the name of the VM (default lm-dev)')
parser.add_argument('--vm', default=VM, help=f'the name of the VM (default {VM})')
parser.add_argument('--user', default='admin', help='the user (default admin)')
args = parser.parse_args()
try:
+6 -5
View File
@@ -1,17 +1,18 @@
#!/usr/bin/env python3
"""Register a TOTP token for a user of a Linux Manager VM on an LXD remote: lm-dev-otp-register.py.
The token is enrolled for --user (admin by default) of the VM --vm (lm-dev) in the project --project
The token is enrolled for --user (admin by default) of the VM --vm (router) in the project --project
(LXD_PROJECT, lm-dev by default) on the remote --remote (LXD_REMOTE): the project's Vault generates
the key in its TOTP engine as <vm>-<user> and hands it to the VM, where linuxmanager_users stores
it with its current code, replacing a token the user had. The secret stays in the Vault and the
VM; lm-dev-otp-code.py prints the user's codes.
it with its current code, replacing a token the user had. For the administrator of
.lm-dev-config/vm-PROJECT-VM.json, the key is made from the file's otp_url when it has one, and a generated key's
otpauth URI is kept there as otp_url. lm-dev-otp-code.py prints the user's codes.
"""
import argparse
import sys
from lm_dev import PROJECT, MissingSetting, enrol_otp, setting, totp_key
from lm_dev import PROJECT, VM, MissingSetting, enrol_otp, setting, totp_key
def main():
@@ -19,7 +20,7 @@ def main():
parser.add_argument('--remote', help='the lxc remote (LXD_REMOTE)')
parser.add_argument('--project', default=setting('LXD_PROJECT', PROJECT),
help=f'the project of the VM (LXD_PROJECT, default {PROJECT})')
parser.add_argument('--vm', default='lm-dev', help='the name of the VM (default lm-dev)')
parser.add_argument('--vm', default=VM, help=f'the name of the VM (default {VM})')
parser.add_argument('--user', default='admin', help='the user to enrol (default admin)')
args = parser.parse_args()
try:
+19 -16
View File
@@ -1,18 +1,19 @@
#!/usr/bin/env python3
"""Launch one Linux Manager server VM on an LXD remote to work with, or remove it: lm-dev-vm.py create|remove.
create launches the VM --vm (lm-dev by default) on the remote --remote (LXD_REMOTE) in the project
create launches the VM --vm (router by default) on the remote --remote (LXD_REMOTE) in the project
--project (LXD_PROJECT, lm-dev by default) with that project's default profile. In a test project
made by lm-dev-lxd-project.py, which .lm-dev-config/lxd-project-PROJECT.json describes, the VM gets the package
from that project's repository, as its apt source, so later dev builds reach it as updates;
elsewhere it gets --deb, or else the package built last, in out/ or out/dev/. The administrator is admin with a
generated password, kept as username and password in .lm-dev-config/vm-PROJECT-VM.json, and a TOTP
token, the key VM-admin of the project's Vault's TOTP engine, unless --no-otp is given;
lm-dev-otp-code.py prints its codes. The VM gets a configuration from tests/remote/configs/
(--config, core.json by default), whose @ETH0@ is the interface of its default route, @CIDR0@ its
network and @PSK@ a generated key. The VM gets an AppRole of its own in the project's Vault
elsewhere it gets --deb, or else the package built last, in out/ or out/dev/. The administrator is admin with the
password of .lm-dev-config/vm-PROJECT-VM.json, and a TOTP token, the key VM-admin of the project's Vault's TOTP
engine made from the file's otp_url, unless --no-otp is given; lm-dev-otp-code.py prints its codes. A password or
otp_url the file lacks, or all of them when there is no file, is generated and kept in the file, so a VM made again
has the same password and token until they are deleted from the file.
The VM gets a configuration from tests/remote/configs/ (--config, core.json by default), whose @ETH0@ is the
interface of its default route, @CIDR0@ its network and @PSK@ a generated key. The VM gets an AppRole of its own in the project's Vault
(lm_dev.enrol_instance), with which it reads the debconf preseed with the admin's password and the
configuration with its key, kept there as VM/preseed and VM/config, and creates its TOTP key; no
configuration with its key, kept there as VM/preseed and VM/config, and its TOTP key, generated or from otp_url; no
secret is an argument or on standard input, so create needs a project with a Vault
(lm-dev-lxd-project.py vault create). The admin's password is also kept there as VM/admin.
@@ -21,8 +22,8 @@ the same ports of the VM, and port 2222 to its SSH port. In a test project the l
network forward's on the project's WAN, --forward-address (LXD_FORWARD_ADDRESS) or else one allocated
from its uplink's routes; elsewhere NAT proxy
devices listen on the host address --listen (LXD_LISTEN, by default the IPv4 address of the host of
the remote's URL). remove deletes the VM, its forward, its .lm-dev-config/vm-PROJECT-VM.json and what
the Vault keeps for it. The defaults of the options come from the environment, else from
the remote's URL). remove deletes the VM, its forward and what the Vault keeps
for it, and keeps .lm-dev-config/vm-PROJECT-VM.json. The defaults of the options come from the environment, else from
.lm-dev-config/settings.json (lm_dev.setting).
"""
@@ -36,7 +37,7 @@ import subprocess
import sys
import time
from lm_dev import HANDOVER_DIR, PROJECT, ROOT, TESTS, VAULT_MOUNT, MissingSetting, VaultError, config_path, \
from lm_dev import HANDOVER_DIR, PROJECT, VM, ROOT, TESTS, VAULT_MOUNT, MissingSetting, VaultError, config_path, \
credentials_path, enrol_instance, enrol_otp, forget_instance, hand_over, host_address, lxc_exec, newest_deb, \
setting, store_secret, vault_state, write_private
@@ -50,7 +51,7 @@ def main():
parser.add_argument('--remote', help='the lxc remote (LXD_REMOTE)')
parser.add_argument('--project', default=setting('LXD_PROJECT', PROJECT),
help=f'the project of the VM (LXD_PROJECT, default {PROJECT})')
parser.add_argument('--vm', default='lm-dev', help='the name of the VM (default lm-dev)')
parser.add_argument('--vm', default=VM, help=f'the name of the VM (default {VM})')
parser.add_argument('--image', default=setting('LXD_IMAGE', 'ubuntu:26.04'),
help='the image of the VM (LXD_IMAGE, default ubuntu:26.04)')
parser.add_argument('--config', default='core.json',
@@ -111,8 +112,7 @@ def main():
forget_instance(vault, args.vm)
except VaultError as error:
print(f'the Vault keeps what it had for {args.vm}: {error}', file=sys.stderr)
credentials.unlink(missing_ok=True)
print(f'removed {where}')
print(f'removed {where}; {credentials} is kept for the next create')
return
if exists:
@@ -129,8 +129,11 @@ def main():
sys.exit(f'project {args.project} has no Vault, which the secrets reach the VM through; make it with '
'lm-dev-lxd-project.py vault create')
password, psk = secrets.token_hex(16), secrets.token_hex(24)
write_private(credentials, json.dumps({'username': 'admin', 'password': password}, indent=2) + '\n')
# The password and otp_url of the credentials file are reused; a missing one is generated.
known = json.loads(credentials.read_text(encoding='utf-8')) if credentials.is_file() else {}
password, psk = known.get('password') or secrets.token_hex(16), secrets.token_hex(24)
known.update(username='admin', password=password)
write_private(credentials, json.dumps(known, indent=2) + '\n')
reached = f'a forward on {project["networks"][0]}' if project else f'proxies on {args.listen}'
print(f'launching {where} from {args.image} with {source}; reached through {reached}')
+25 -7
View File
@@ -25,6 +25,8 @@ ROOT = pathlib.Path(__file__).resolve().parent.parent
TESTS = ROOT / 'tests' / 'remote'
# The project of the manual tests, which lm-dev-lxd-project.py makes.
PROJECT = 'lm-dev'
# The default VM of the manual tests, which lm-dev-vm.py makes.
VM = 'router'
# The state of the scripts that outlives a clean-up of tmp/: settings, project and Vault states, keys and secrets; 0700.
CONFIG = ROOT / '.lm-dev-config'
# The settings of the scripts, the defaults of their options: a JSON object of LXD_* names and their values.
@@ -290,11 +292,13 @@ def totp_key(instance, user):
def enrol_otp(remote, project, instance, user):
"""Enrol a new TOTP token for the user of the VM, replacing one the user had; the problem, or None.
"""Enrol a TOTP token for the user of the VM, replacing one the user had; the problem, or None.
The VM has the Vault generate the key with its AppRole and enrols its secret with its current code; the codes are
read from the Vault (otp_code). When the user is the administrator of the VM's credentials_path, the key's otpauth
URI, read from the VM's file before it is removed, is kept there as otp_url, to add the token to an authenticator.
When the user is the administrator of the VM's credentials_path and the file has otp_url, the Vault's key is made
from that otpauth URI and the VM receives it through the Vault (hand_over), so the token stays the same. Otherwise
the VM has the Vault generate a new key with its AppRole, and for the administrator the key's otpauth URI, read
from the VM's file before it is removed, is kept in the file as otp_url, to add the token to an authenticator. The
VM enrols the key's secret with its current code; the codes are read from the Vault (otp_code).
"""
state = vault_state(project)
if state is None:
@@ -308,9 +312,23 @@ def enrol_otp(remote, project, instance, user):
credentials = credentials_path(project, instance)
known = json.loads(credentials.read_text(encoding='utf-8')) if credentials.is_file() else {}
keep = known.get('username') == user
steps = (('install', '-d', '-m', '0700', HANDOVER_DIR), (HELPER, 'totp', key, instance, user, target, '0600'),
*((('cat', target),) if keep else ()), ('python3', '-c', OTP_ENROL, user, target))
for command in steps:
reuse = known.get('otp_url') if keep else None
prepared = lxc_exec(remote, project, instance, 'install', '-d', '-m', '0700', HANDOVER_DIR)
if prepared.returncode != 0:
return f'{HANDOVER_DIR} cannot be made in {instance}: {prepared.stderr.strip()}'
if reuse:
try:
vault_call(state['url'], 'POST', f'/v1/{TOTP_MOUNT}/keys/{key}', {'url': reuse},
token=state['root_token'])
except VaultError as error:
return f'the TOTP key {key} cannot be made from otp_url: {error}'
problem = hand_over(remote, project, instance, state, 'otp-url', reuse + '\n', target, '0600')
if problem:
return problem
steps = ()
else:
steps = ((HELPER, 'totp', key, instance, user, target, '0600'), *((('cat', target),) if keep else ()))
for command in (*steps, ('python3', '-c', OTP_ENROL, user, target)):
result = lxc_exec(remote, project, instance, *command)
if result.returncode != 0:
return f'{user} was not enrolled: {(result.stderr.strip().splitlines() or ["lxc exec failed"])[-1]}'
+1
View File
@@ -41,6 +41,7 @@ src/usr/lib/linux-manager/upgrade usr/lib/linux-manager/
src/usr/lib/linux-manager/linuxmanager_platforms/*.py usr/lib/linux-manager/linuxmanager_platforms/
src/usr/share/linux-manager/templates/* usr/share/linux-manager/templates/
src/usr/share/linux-manager/sql/* usr/share/linux-manager/sql/
src/usr/share/linux-manager/schema/* usr/share/linux-manager/schema/
src/usr/share/bash-completion/completions/*.bash usr/share/bash-completion/completions/
src/usr/lib/systemd/system/caddy.service.d/linux-manager.conf usr/lib/systemd/system/caddy.service.d/
src/usr/share/doc/linux-manager/linux-manager.json.example usr/share/doc/linux-manager/
@@ -17,7 +17,9 @@ CONSOLE_UID_MIN and the gidNumber of the local group CONSOLE_GROUP; nslcd serves
linuxManagerConsoleLogin TRUE to the system over the local socket.
ou=pki holds the server's PKI (linuxmanager_pki): an entry per CA, and under it an entry per
certificate the CA issued. Private keys are readable by root alone, the database's root DN.
certificate the CA issued. Private keys are readable by root, the database's root DN, and by the
members of the group PKI_GROUP, which also write ou=pki: an application that keeps its CAs there,
such as Simple CA, binds as a service account in that group.
ou=roles holds the roles of the resources of the OpenID Provider: an entry per role,
cn=<resource>:<role>, whose members are the groups, users and service accounts it is assigned to.
@@ -32,6 +34,7 @@ import secrets
import ldap
import ldap.modlist
import ldap.sasl
import ldif
URI = 'ldapi:///'
#: The local socket ldapi:/// names, which slapd listens on.
@@ -64,102 +67,15 @@ LOCKOUT_SECONDS = 900
#: The overlays of the database, in the order they are configured.
OVERLAYS = ('ppolicy', 'otp')
#: The package's own schema, under the LDAP arc of the Linux Manager OID arc (OID-REGISTRY.txt):
#: attribute types under .1 and object classes under .2. linuxManagerAccount, auxiliary, adds properties of the
#: package to a user of either kind: mail, for a Manager-only account, linuxManagerScope,
#: authorization scopes, of which service marks a service account, displayName and
#: description, the labels of a service account, and linuxManagerConsoleLogin and
#: linuxManagerConsoleAccount, whether the user may use a console and the local account it runs as,
#: without which it runs as the user's own posixAccount, and linuxManagerWireGuardPeer, each a
#: WireGuard peer of the user as "<public key> <IP>[,<IP>...]", and linuxManagerPasskey, each a
#: passkey of the user as JSON (linuxmanager_passkeys). A service account with linuxManagerRedirectUri
#: is a client of the OpenID Provider (linuxmanager_oidc): the URIs it is sent back to after a sign-in
#: and, linuxManagerPostLogoutRedirectUri, after a sign-out, and linuxManagerAllowedGroup, the DNs of the
#: groups whose members may sign in to it; linuxManagerGrantType, the further grants it may use,
#: linuxManagerPublicClient, whether it has no secret, and linuxManagerClientScope, the scopes of
#: resources it may ask for, as <resource>:<scope>. A service account with linuxManagerResourceScope
#: is a resource of the OpenID Provider with those scopes. linuxManagerRole is a role of a resource,
#: named cn=<resource>:<role>, with the DNs of the groups and accounts it is assigned to in
#: member. linuxManagerAuthority is a CA of the PKI: its
#: certificate and CRL (cACertificate and certificateRevocationList of RFC 4523), its key, the
#: CSR it waits with for its certificate, the number of its last CRL, where the CRL came from,
#: and when it was retired; the root also holds the Simple CA token, linuxManagerToken, and the
#: name of the Simple CA issuing CA that signs with it, linuxManagerUpstreamName.
#: linuxManagerHostCertificate, cn=https, is the server's HTTPS certificate when no ACME CA or
#: issuing CA gives it: the certificate with its chain, its key, the CSR waiting for a certificate
#: of another CA and that CSR's key, and its kind, self-signed or external. linuxManagerCertificate is a certificate a CA issued, named by its
#: serial number: the certificate, the key the server keeps for its own and the users'
#: certificates, its kind, template, names and expiry, and its revocation.
SCHEMA_OID = '1.3.6.1.4.1.67380.10.1.2'
SCHEMA_NAME = 'linux-manager'
_STRING = 'EQUALITY caseIgnoreMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{256} SINGLE-VALUE'
_TIME = 'EQUALITY generalizedTimeMatch ORDERING generalizedTimeOrderingMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 SINGLE-VALUE'
_OCTETS = 'EQUALITY octetStringMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 SINGLE-VALUE'
SCHEMA_ATTRIBUTE_TYPES = (
f"( {SCHEMA_OID}.1.1 NAME 'linuxManagerScope' DESC 'Linux Manager: an authorization scope of the account' "
"EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{256} )",
f"( {SCHEMA_OID}.1.2 NAME 'linuxManagerPrivateKey' DESC 'Linux Manager: a private key, PEM' {_OCTETS} )",
f"( {SCHEMA_OID}.1.3 NAME 'linuxManagerCertificateRequest' DESC 'Linux Manager: the CSR of a CA, PEM' {_OCTETS} )",
f"( {SCHEMA_OID}.1.4 NAME 'linuxManagerCRLNumber' DESC 'Linux Manager: the number of the last CRL of a CA' "
"EQUALITY integerMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )",
f"( {SCHEMA_OID}.1.5 NAME 'linuxManagerCRLSource' DESC 'Linux Manager: signed or uploaded, where the CRL of a CA came from' {_STRING} )",
f"( {SCHEMA_OID}.1.6 NAME 'linuxManagerRetired' DESC 'Linux Manager: when a CA was retired' {_TIME} )",
f"( {SCHEMA_OID}.1.7 NAME 'linuxManagerKind' DESC 'Linux Manager: ca, router, user or external, the kind of a certificate' {_STRING} )",
f"( {SCHEMA_OID}.1.8 NAME 'linuxManagerTemplate' DESC 'Linux Manager: the template of a certificate' {_STRING} )",
f"( {SCHEMA_OID}.1.9 NAME 'linuxManagerSubjectAltName' DESC 'Linux Manager: a subject alternative name of a certificate' "
"EQUALITY caseIgnoreMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{256} )",
f"( {SCHEMA_OID}.1.10 NAME 'linuxManagerNotAfter' DESC 'Linux Manager: when a certificate expires' {_TIME} )",
f"( {SCHEMA_OID}.1.11 NAME 'linuxManagerRevoked' DESC 'Linux Manager: when a certificate was revoked' {_TIME} )",
f"( {SCHEMA_OID}.1.12 NAME 'linuxManagerRevocationReason' DESC 'Linux Manager: why a certificate was revoked' {_STRING} )",
f"( {SCHEMA_OID}.1.13 NAME 'linuxManagerConsoleLogin' DESC 'Linux Manager: whether the user may use a console' "
"EQUALITY booleanMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 SINGLE-VALUE )",
f"( {SCHEMA_OID}.1.14 NAME 'linuxManagerConsoleAccount' DESC 'Linux Manager: the local account the console of the user runs as' "
f"{_STRING} )",
f"( {SCHEMA_OID}.1.15 NAME 'linuxManagerWireGuardPeer' DESC 'Linux Manager: a WireGuard peer of the user, its public key and IPs' "
"EQUALITY caseExactMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{1024} )",
f"( {SCHEMA_OID}.1.16 NAME 'linuxManagerPasskey' DESC 'Linux Manager: a passkey of the user, its credential as JSON' "
"EQUALITY caseExactMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{4096} )",
f"( {SCHEMA_OID}.1.17 NAME 'linuxManagerRedirectUri' DESC 'Linux Manager: a redirect URI of an OpenID Connect client' "
"EQUALITY caseExactMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{1024} )",
f"( {SCHEMA_OID}.1.18 NAME 'linuxManagerPostLogoutRedirectUri' DESC 'Linux Manager: a post-logout redirect URI of an "
"OpenID Connect client' EQUALITY caseExactMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{1024} )",
f"( {SCHEMA_OID}.1.19 NAME 'linuxManagerAllowedGroup' DESC 'Linux Manager: a group whose members may sign in to an "
"OpenID Connect client' EQUALITY distinguishedNameMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )",
f"( {SCHEMA_OID}.1.20 NAME 'linuxManagerGrantType' DESC 'Linux Manager: a grant an OpenID Connect client may use besides "
"the authorization code' EQUALITY caseExactMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{64} )",
f"( {SCHEMA_OID}.1.21 NAME 'linuxManagerPublicClient' DESC 'Linux Manager: whether an OpenID Connect client has no secret' "
"EQUALITY booleanMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 SINGLE-VALUE )",
f"( {SCHEMA_OID}.1.22 NAME 'linuxManagerClientScope' DESC 'Linux Manager: a scope of a resource an OpenID Connect client "
"may ask for' EQUALITY caseExactMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{128} )",
f"( {SCHEMA_OID}.1.23 NAME 'linuxManagerResourceScope' DESC 'Linux Manager: a scope of a resource of the OpenID Provider' "
"EQUALITY caseExactMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{64} )",
f"( {SCHEMA_OID}.1.24 NAME 'linuxManagerToken' DESC 'Linux Manager: the Simple CA token that signs the issuing CAs' "
f"{_OCTETS} )",
f"( {SCHEMA_OID}.1.25 NAME 'linuxManagerUpstreamName' DESC 'Linux Manager: the Simple CA issuing CA of the token' "
f"{_STRING} )",
f"( {SCHEMA_OID}.1.26 NAME 'linuxManagerCertificateChain' DESC 'Linux Manager: a certificate and its chain, PEM' "
f"{_OCTETS} )",
f"( {SCHEMA_OID}.1.27 NAME 'linuxManagerRequestKey' DESC 'Linux Manager: the private key of a CSR, PEM' {_OCTETS} )",
)
SCHEMA_OBJECT_CLASSES = (
f"( {SCHEMA_OID}.2.1 NAME 'linuxManagerAccount' DESC 'Linux Manager: properties of a user or a Manager-only account' "
"SUP top AUXILIARY MAY ( mail $ linuxManagerScope $ displayName $ description $ linuxManagerConsoleLogin $ "
"linuxManagerConsoleAccount $ linuxManagerWireGuardPeer $ linuxManagerPasskey $ linuxManagerRedirectUri $ "
"linuxManagerPostLogoutRedirectUri $ linuxManagerAllowedGroup $ linuxManagerGrantType $ linuxManagerPublicClient $ "
"linuxManagerClientScope $ linuxManagerResourceScope ) )",
f"( {SCHEMA_OID}.2.2 NAME 'linuxManagerAuthority' DESC 'Linux Manager: a CA of the PKI' SUP top STRUCTURAL MUST cn "
"MAY ( cACertificate $ certificateRevocationList $ linuxManagerPrivateKey $ linuxManagerCertificateRequest $ "
"linuxManagerCRLNumber $ linuxManagerCRLSource $ linuxManagerRetired $ linuxManagerToken $ "
"linuxManagerUpstreamName ) )",
f"( {SCHEMA_OID}.2.3 NAME 'linuxManagerCertificate' DESC 'Linux Manager: a certificate a CA of the PKI issued' SUP top "
"STRUCTURAL MUST serialNumber MAY ( cn $ userCertificate $ linuxManagerPrivateKey $ linuxManagerKind $ linuxManagerTemplate $ "
"linuxManagerSubjectAltName $ linuxManagerNotAfter $ linuxManagerRevoked $ linuxManagerRevocationReason ) )",
f"( {SCHEMA_OID}.2.4 NAME 'linuxManagerRole' DESC 'Linux Manager: a role of a resource of the OpenID Provider' SUP top "
"STRUCTURAL MUST cn MAY ( description $ member ) )",
f"( {SCHEMA_OID}.2.5 NAME 'linuxManagerHostCertificate' DESC 'Linux Manager: a certificate of the server kept with "
"its key' SUP top STRUCTURAL MUST cn MAY ( linuxManagerCertificateChain $ linuxManagerPrivateKey $ "
"linuxManagerCertificateRequest $ linuxManagerRequestKey $ linuxManagerKind ) )",
)
#: The package's schema, two schema entries of cn=config, each loaded from its LDIF file (ldapadd's form): the PKI,
#: linux-manager-pki, which a slapd without the package loads alike, and the accounts, the clients and resources of
#: the OpenID Provider and their roles, linux-manager. The files describe their attribute types and object classes.
SCHEMA_DIR = pathlib.Path('/usr/share/linux-manager/schema')
SCHEMA_FILES = (SCHEMA_DIR / 'linux-manager-pki.ldif', SCHEMA_DIR / 'linux-manager.ldif')
#: The group whose members manage the PKI, ou=pki with the keys; it is made when its first member is added.
PKI_GROUP = 'pki-managers'
PKI_MANAGERS = f'cn={PKI_GROUP},{GROUPS}'
#: The TOTP parameters: digits, the OID of HMAC-SHA1, seconds per time step, and the time steps accepted before and after now.
TOTP_DIGITS = 6
@@ -171,7 +87,7 @@ TOTP_WINDOW = 1
DISABLED = '000001010000Z'
#: The indexes of the database.
INDEXES = ('objectClass eq', 'uid eq', 'uidNumber eq', 'linuxManagerConsoleLogin eq')
INDEXES = ('objectClass eq', 'uid eq', 'uidNumber eq', 'linuxManagerConsoleLogin eq', 'linuxManagerCertificateName eq')
#: The POSIX accounts of console login (linuxmanager_users.console): the lowest uidNumber, which nslcd's nss_min_uid
#: matches, the local group that is their primary group and grants sudo, the shell and the parent of their homes.
@@ -182,12 +98,14 @@ CONSOLE_HOMES = '/home'
#: The ACLs of the database, in order.
ACCESS = (
'to attrs=linuxManagerPrivateKey,linuxManagerToken,linuxManagerRequestKey by * none',
f'to attrs=linuxManagerPrivateKey,linuxManagerToken,linuxManagerRequestKey by group.exact="{PKI_MANAGERS}" manage '
'by * none',
f'to attrs=userPassword by dn.exact="{MANAGER}" =wx by self =wx by anonymous auth by * none',
f'to attrs=oathSecret by dn.exact="{MANAGER}" =w by * none',
f'to dn.subtree="{USERS}" by dn.exact="{MANAGER}" manage by * read',
f'to dn.subtree="{GROUPS}" by dn.exact="{MANAGER}" manage by * read',
f'to dn.subtree="{ROLES}" by dn.exact="{MANAGER}" manage by * read',
f'to dn.subtree="{PKI}" by group.exact="{PKI_MANAGERS}" manage by * read',
'to * by * read',
)
@@ -236,27 +154,32 @@ def _ensure_modules(connection):
def _ensure_schema(connection):
"""Add the package's schema to cn=config when missing, else add the definitions it lacks; a definition that differs
from the one of the same OID replaces the whole list of its kind."""
found = connection.search_s('cn=schema,cn=config', ldap.SCOPE_ONELEVEL, f'(cn=*{SCHEMA_NAME})',
['olcAttributeTypes', 'olcObjectClasses'])
attributes = {'olcAttributeTypes': list(SCHEMA_ATTRIBUTE_TYPES), 'olcObjectClasses': list(SCHEMA_OBJECT_CLASSES)}
if not found:
connection.add_s(f'cn={SCHEMA_NAME},cn=schema,cn=config', ldap.modlist.addModlist(
dict({name: [value.encode() for value in values] for name, values in attributes.items()},
objectClass=[b'olcSchemaConfig'], cn=[SCHEMA_NAME.encode()])))
return
dn, current = found[0]
for name, wanted in attributes.items():
present = unordered(current.get(name, []))
oids = {value.split()[1] for value in present}
missing = [value for value in wanted if value not in present]
if not missing:
"""Add each schema of SCHEMA_FILES to cn=config when missing, else add the definitions it lacks; a definition that
differs from the one of the same OID replaces the whole list of its kind."""
for path in SCHEMA_FILES:
with open(path, encoding='utf-8') as handle:
records = ldif.LDIFRecordList(handle)
records.parse()
dn, wanted = records.all_records[0]
name = wanted['cn'][0]
found = [(found_dn, current) for found_dn, current in connection.search_s(
'cn=schema,cn=config', ldap.SCOPE_ONELEVEL, f'(cn=*{name.decode()})', ['cn', 'olcAttributeTypes', 'olcObjectClasses'])
if ORDER.sub(b'', current['cn'][0]) == name]
if not found:
connection.add_s(dn, ldap.modlist.addModlist(wanted))
continue
if any(value.split()[1] in oids for value in missing):
connection.modify_s(dn, [(ldap.MOD_REPLACE, name, [value.encode() for value in wanted])])
else:
connection.modify_s(dn, [(ldap.MOD_ADD, name, [value.encode() for value in missing])])
found_dn, current = found[0]
for kind in ('olcAttributeTypes', 'olcObjectClasses'):
values = [value.decode() for value in wanted.get(kind, [])]
present = unordered(current.get(kind, []))
oids = {value.split()[1] for value in present}
missing = [value for value in values if value not in present]
if not missing:
continue
if any(value.split()[1] in oids for value in missing):
connection.modify_s(found_dn, [(ldap.MOD_REPLACE, kind, [value.encode() for value in values])])
else:
connection.modify_s(found_dn, [(ldap.MOD_ADD, kind, [value.encode() for value in missing])])
def _ensure_password_hash(connection):
@@ -33,7 +33,9 @@ optional description and at least one member; a group cannot be empty, so the la
cannot leave it and a user who is the last member of a group cannot be removed. ADMIN_GROUP grants the management of
the server, the allowed groups of the OpenID Provider's clients who may sign in to them, and the editors group of a web
site who may change its files (linuxmanager_sites); renaming a group renames it in those, and a group a client allows or a
site has cannot be removed.
site has cannot be removed. The members of linuxmanager_ldap.PKI_GROUP manage the PKI in ou=pki with its keys,
which an application that keeps its CAs there binds for as a service account; the group is made with its first member,
and renaming it takes that access away.
A VPN user may have WireGuard peers, each a device with its public key and its IPs, in
linuxManagerWireGuardPeer; linux-manager-setup writes a [Peer] of wg0.conf for each peer of a user who
@@ -0,0 +1,90 @@
# Linux Manager's PKI schema: CAs, the certificates they issued and the server's host certificates,
# with their keys. It needs only the core schema. A slapd without Linux Manager loads it with:
#
# ldapadd -Y EXTERNAL -H ldapi:/// -f linux-manager-pki.ldif
#
# OIDs: the LDAP arc 1.3.6.1.4.1.67380.10.1.2 of OID-REGISTRY.txt, attribute types under .1 and
# object classes under .2.
dn: cn=linux-manager-pki,cn=schema,cn=config
objectClass: olcSchemaConfig
cn: linux-manager-pki
olcAttributeTypes: ( 1.3.6.1.4.1.67380.10.1.2.1.2 NAME
'linuxManagerPrivateKey' DESC 'Linux Manager: a private key, PEM' EQUALITY
octetStringMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 SINGLE-VALUE )
olcAttributeTypes: ( 1.3.6.1.4.1.67380.10.1.2.1.3 NAME
'linuxManagerCertificateRequest' DESC 'Linux Manager: the CSR of a CA, PEM'
EQUALITY octetStringMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 SINGLE-VALUE
)
olcAttributeTypes: ( 1.3.6.1.4.1.67380.10.1.2.1.4 NAME 'linuxManagerCRLNumber'
DESC 'Linux Manager: the number of the last CRL of a CA' EQUALITY
integerMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )
olcAttributeTypes: ( 1.3.6.1.4.1.67380.10.1.2.1.5 NAME 'linuxManagerCRLSource'
DESC 'Linux Manager: signed or uploaded, where the CRL of a CA came from'
EQUALITY caseIgnoreMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{256}
SINGLE-VALUE )
olcAttributeTypes: ( 1.3.6.1.4.1.67380.10.1.2.1.6 NAME 'linuxManagerRetired'
DESC 'Linux Manager: when a CA was retired' EQUALITY generalizedTimeMatch
ORDERING generalizedTimeOrderingMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.24
SINGLE-VALUE )
olcAttributeTypes: ( 1.3.6.1.4.1.67380.10.1.2.1.7 NAME 'linuxManagerKind' DESC
'Linux Manager: ca, router, user or external, the kind of a certificate'
EQUALITY caseIgnoreMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{256}
SINGLE-VALUE )
olcAttributeTypes: ( 1.3.6.1.4.1.67380.10.1.2.1.8 NAME 'linuxManagerTemplate'
DESC 'Linux Manager: the template of a certificate' EQUALITY caseIgnoreMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{256} SINGLE-VALUE )
olcAttributeTypes: ( 1.3.6.1.4.1.67380.10.1.2.1.9 NAME
'linuxManagerSubjectAltName' DESC 'Linux Manager: a subject alternative name
of a certificate' EQUALITY caseIgnoreMatch SYNTAX
1.3.6.1.4.1.1466.115.121.1.15{256} )
olcAttributeTypes: ( 1.3.6.1.4.1.67380.10.1.2.1.10 NAME 'linuxManagerNotAfter'
DESC 'Linux Manager: when a certificate expires' EQUALITY
generalizedTimeMatch ORDERING generalizedTimeOrderingMatch SYNTAX
1.3.6.1.4.1.1466.115.121.1.24 SINGLE-VALUE )
olcAttributeTypes: ( 1.3.6.1.4.1.67380.10.1.2.1.11 NAME 'linuxManagerRevoked'
DESC 'Linux Manager: when a certificate was revoked' EQUALITY
generalizedTimeMatch ORDERING generalizedTimeOrderingMatch SYNTAX
1.3.6.1.4.1.1466.115.121.1.24 SINGLE-VALUE )
olcAttributeTypes: ( 1.3.6.1.4.1.67380.10.1.2.1.12 NAME
'linuxManagerRevocationReason' DESC 'Linux Manager: why a certificate was
revoked' EQUALITY caseIgnoreMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{256}
SINGLE-VALUE )
olcAttributeTypes: ( 1.3.6.1.4.1.67380.10.1.2.1.24 NAME 'linuxManagerToken'
DESC 'Linux Manager: the Simple CA token that signs the issuing CAs'
EQUALITY octetStringMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 SINGLE-VALUE
)
olcAttributeTypes: ( 1.3.6.1.4.1.67380.10.1.2.1.25 NAME
'linuxManagerUpstreamName' DESC 'Linux Manager: the Simple CA issuing CA of
the token' EQUALITY caseIgnoreMatch SYNTAX
1.3.6.1.4.1.1466.115.121.1.15{256} SINGLE-VALUE )
olcAttributeTypes: ( 1.3.6.1.4.1.67380.10.1.2.1.26 NAME
'linuxManagerCertificateChain' DESC 'Linux Manager: a certificate and its
chain, PEM' EQUALITY octetStringMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.40
SINGLE-VALUE )
olcAttributeTypes: ( 1.3.6.1.4.1.67380.10.1.2.1.27 NAME
'linuxManagerRequestKey' DESC 'Linux Manager: the private key of a CSR, PEM'
EQUALITY octetStringMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 SINGLE-VALUE
)
olcAttributeTypes: ( 1.3.6.1.4.1.67380.10.1.2.1.28 NAME
'linuxManagerCertificateName' DESC 'Linux Manager: the name a certificate is
filed under by the application that keeps it' EQUALITY caseExactMatch SYNTAX
1.3.6.1.4.1.1466.115.121.1.15{256} SINGLE-VALUE )
olcObjectClasses: ( 1.3.6.1.4.1.67380.10.1.2.2.2 NAME 'linuxManagerAuthority'
DESC 'Linux Manager: a CA of the PKI' SUP top STRUCTURAL MUST cn MAY (
cACertificate $ certificateRevocationList $ linuxManagerPrivateKey $
linuxManagerCertificateRequest $ linuxManagerCRLNumber $
linuxManagerCRLSource $ linuxManagerRetired $ linuxManagerToken $
linuxManagerUpstreamName ) )
olcObjectClasses: ( 1.3.6.1.4.1.67380.10.1.2.2.3 NAME
'linuxManagerCertificate' DESC 'Linux Manager: a certificate a CA of the PKI
issued' SUP top STRUCTURAL MUST serialNumber MAY ( cn $ userCertificate $
linuxManagerPrivateKey $ linuxManagerKind $ linuxManagerTemplate $
linuxManagerSubjectAltName $ linuxManagerNotAfter $ linuxManagerRevoked $
linuxManagerRevocationReason $ linuxManagerCertificateName ) )
olcObjectClasses: ( 1.3.6.1.4.1.67380.10.1.2.2.5 NAME
'linuxManagerHostCertificate' DESC 'Linux Manager: a certificate of the
server kept with its key' SUP top STRUCTURAL MUST cn MAY (
linuxManagerCertificateChain $ linuxManagerPrivateKey $
linuxManagerCertificateRequest $ linuxManagerRequestKey $ linuxManagerKind )
)
@@ -0,0 +1,67 @@
# Linux Manager's schema of its accounts, of the clients and resources of its OpenID Provider, and
# of the roles of those resources; the PKI is in linux-manager-pki.ldif.
#
# OIDs: the LDAP arc 1.3.6.1.4.1.67380.10.1.2 of OID-REGISTRY.txt, attribute types under .1 and
# object classes under .2.
dn: cn=linux-manager,cn=schema,cn=config
objectClass: olcSchemaConfig
cn: linux-manager
olcAttributeTypes: ( 1.3.6.1.4.1.67380.10.1.2.1.1 NAME 'linuxManagerScope'
DESC 'Linux Manager: an authorization scope of the account' EQUALITY
caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX
1.3.6.1.4.1.1466.115.121.1.15{256} )
olcAttributeTypes: ( 1.3.6.1.4.1.67380.10.1.2.1.13 NAME
'linuxManagerConsoleLogin' DESC 'Linux Manager: whether the user may use a
console' EQUALITY booleanMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.7
SINGLE-VALUE )
olcAttributeTypes: ( 1.3.6.1.4.1.67380.10.1.2.1.14 NAME
'linuxManagerConsoleAccount' DESC 'Linux Manager: the local account the
console of the user runs as' EQUALITY caseIgnoreMatch SYNTAX
1.3.6.1.4.1.1466.115.121.1.15{256} SINGLE-VALUE )
olcAttributeTypes: ( 1.3.6.1.4.1.67380.10.1.2.1.15 NAME
'linuxManagerWireGuardPeer' DESC 'Linux Manager: a WireGuard peer of the
user, its public key and IPs' EQUALITY caseExactMatch SYNTAX
1.3.6.1.4.1.1466.115.121.1.15{1024} )
olcAttributeTypes: ( 1.3.6.1.4.1.67380.10.1.2.1.16 NAME 'linuxManagerPasskey'
DESC 'Linux Manager: a passkey of the user, its credential as JSON' EQUALITY
caseExactMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{4096} )
olcAttributeTypes: ( 1.3.6.1.4.1.67380.10.1.2.1.17 NAME
'linuxManagerRedirectUri' DESC 'Linux Manager: a redirect URI of an OpenID
Connect client' EQUALITY caseExactMatch SYNTAX
1.3.6.1.4.1.1466.115.121.1.15{1024} )
olcAttributeTypes: ( 1.3.6.1.4.1.67380.10.1.2.1.18 NAME
'linuxManagerPostLogoutRedirectUri' DESC 'Linux Manager: a post-logout
redirect URI of an OpenID Connect client' EQUALITY caseExactMatch SYNTAX
1.3.6.1.4.1.1466.115.121.1.15{1024} )
olcAttributeTypes: ( 1.3.6.1.4.1.67380.10.1.2.1.19 NAME
'linuxManagerAllowedGroup' DESC 'Linux Manager: a group whose members may
sign in to an OpenID Connect client' EQUALITY distinguishedNameMatch SYNTAX
1.3.6.1.4.1.1466.115.121.1.12 )
olcAttributeTypes: ( 1.3.6.1.4.1.67380.10.1.2.1.20 NAME
'linuxManagerGrantType' DESC 'Linux Manager: a grant an OpenID Connect
client may use besides the authorization code' EQUALITY caseExactMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{64} )
olcAttributeTypes: ( 1.3.6.1.4.1.67380.10.1.2.1.21 NAME
'linuxManagerPublicClient' DESC 'Linux Manager: whether an OpenID Connect
client has no secret' EQUALITY booleanMatch SYNTAX
1.3.6.1.4.1.1466.115.121.1.7 SINGLE-VALUE )
olcAttributeTypes: ( 1.3.6.1.4.1.67380.10.1.2.1.22 NAME
'linuxManagerClientScope' DESC 'Linux Manager: a scope of a resource an
OpenID Connect client may ask for' EQUALITY caseExactMatch SYNTAX
1.3.6.1.4.1.1466.115.121.1.15{128} )
olcAttributeTypes: ( 1.3.6.1.4.1.67380.10.1.2.1.23 NAME
'linuxManagerResourceScope' DESC 'Linux Manager: a scope of a resource of
the OpenID Provider' EQUALITY caseExactMatch SYNTAX
1.3.6.1.4.1.1466.115.121.1.15{64} )
olcObjectClasses: ( 1.3.6.1.4.1.67380.10.1.2.2.1 NAME 'linuxManagerAccount'
DESC 'Linux Manager: properties of a user or a Manager-only account' SUP top
AUXILIARY MAY ( mail $ linuxManagerScope $ displayName $ description $
linuxManagerConsoleLogin $ linuxManagerConsoleAccount $
linuxManagerWireGuardPeer $ linuxManagerPasskey $ linuxManagerRedirectUri $
linuxManagerPostLogoutRedirectUri $ linuxManagerAllowedGroup $
linuxManagerGrantType $ linuxManagerPublicClient $ linuxManagerClientScope $
linuxManagerResourceScope ) )
olcObjectClasses: ( 1.3.6.1.4.1.67380.10.1.2.2.4 NAME 'linuxManagerRole' DESC
'Linux Manager: a role of a resource of the OpenID Provider' SUP top
STRUCTURAL MUST cn MAY ( description $ member ) )
+14 -11
View File
@@ -121,13 +121,14 @@ default, such as `LXD_REMOTE`, is required: without its option, the script stops
## A VM to work with
`lm-dev-vm.py create` launches one server VM, `lm-dev` by default, on the LXD remote and leaves
`lm-dev-vm.py create` launches one server VM, `router` by default, on the LXD remote and leaves
it running. The VM is created in a project, the test project `lm-dev` by default, with that
project's default profile, and takes its address from DHCP. It gets the package with the
administrator `admin` and a generated password, kept as `username` and `password` in
`.lm-dev-config/vm-<project>-<vm>.json`, a TOTP token for `admin` in the project's Vault unless `--no-otp` is given,
and a configuration from `configs/`, `core.json` by default; `@ETH0@` is the interface of the VM's
default route.
administrator `admin`, whose password and TOTP token, unless `--no-otp` is given, are `password` and
`otp_url` of `.lm-dev-config/vm-<project>-<vm>.json`, and a configuration from `configs/`,
`core.json` by default; `@ETH0@` is the interface of the VM's default route. A password or
`otp_url` the file lacks, or both when there is no file, is generated and kept in the file, so a VM
made again has the same password and token; delete one from the file to have a new one made.
In a test project made by `lm-dev-lxd-project.py`, the VM installs the package from the project's
repository, so later dev builds reach it as updates; in another project it installs `--deb`, or
@@ -157,14 +158,15 @@ bin/lm-dev-vm.py remove
`create` needs the project's Vault (`lm-dev-lxd-project.py vault create`): the VM gets its
AppRole there, and reads the preseed and the configuration, kept as `<vm>/preseed` and
`<vm>/config`, and creates the TOTP key `<vm>-admin` with it. `remove` deletes the VM, its forward,
its `vm-<project>-<vm>.json` and what the Vault keeps for it. Options:
`<vm>/config`; the TOTP key `<vm>-admin` is made from `otp_url`, or else the VM has the Vault
generate it. `remove` deletes the VM, its forward and what the Vault keeps for it, and keeps
`vm-<project>-<vm>.json`. Options:
| Option | Variable | Default | Meaning |
|---|---|---|---|
| `--remote` | `LXD_REMOTE` | required | The `lxc` remote |
| `--project` | `LXD_PROJECT` | `lm-dev` | The project of the VM |
| `--vm` | | `lm-dev` | The name of the VM; it must not exist for `create` |
| `--vm` | | `router` | The name of the VM; it must not exist for `create` |
| `--image` | `LXD_IMAGE` | `ubuntu:26.04` | The image of the VM |
| `--config` | | `core.json` | The configuration from `configs/` |
| `--listen` | `LXD_LISTEN` | the remote URL's host | Outside a test project, the address the proxies listen on |
@@ -262,10 +264,11 @@ read from its state file, so the script takes no `--remote`.
## A TOTP token for a user of a test VM
`bin/lm-dev-otp-register.py` enrols a new TOTP token for a user of a VM, `admin` of `lm-dev` by
`bin/lm-dev-otp-register.py` enrols a TOTP token for a user of a VM, `admin` of `router` by
default, replacing a token the user had. The project's Vault generates the key `<vm>-<user>` in its
TOTP engine and hands it to the VM (see Secrets), where the package's `linuxmanager_users` stores
it. A new token of the VM's administrator replaces `otp_url` in `vm-<project>-<vm>.json`.
it. For the VM's administrator, the key is made from `otp_url` in `vm-<project>-<vm>.json` when the
file has it, and a generated key's URL is kept there as `otp_url`.
`bin/lm-dev-otp-code.py` prints the user's current code, read from the Vault, for the Manager's
sign-in, SSH or `sudo`.
@@ -281,7 +284,7 @@ bin/lm-dev-otp-code.py
|---|---|---|---|
| `--remote` | `LXD_REMOTE` | required by `lm-dev-otp-register.py` | The `lxc` remote |
| `--project` | `LXD_PROJECT` | `lm-dev` | The project of the VM |
| `--vm` | | `lm-dev` | The name of the VM |
| `--vm` | | `router` | The name of the VM |
| `--user` | | `admin` | The user |
## A command-line authenticator app