Phase 1: identity, sessions, audit, frontend shell
AD sign-in over LDAPS (search with the service account, bind as the user, nested groups through LDAP_MATCHING_RULE_IN_CHAIN, disabled accounts refused), roles as the union of PS-* groups mapped by a table derived from the seeded departments. Server-side sessions with idle, lock and absolute timeouts, Origin and X-Requested-With check, step-up unlock. Optional Argon2id PIN set with the domain password; PIN sign-in by employee ID on registered devices only; five wrong attempts disable the PIN, three wrong at unlock or signature end the session. Rate limits per account and per address before any bind. Devices, signatures table and sign helper, audit rows for every identity event, SSE over LISTEN/NOTIFY with presence. Account settings and Admin APIs and screens (AD view, devices, PIN clearing, group map with missing-group flags, refresh from AD now). CLI ad-groups --list and ad-refresh. Migration 0002. Frontend: real sign-in (password tab, PIN keypad on registered devices), lock screen, role switcher, Account settings, Admin shell, screen placeholders. CI: Samba AD DC container (PSTEST.LOCAL) with a generated CA, 49 of the 50 groups plus one extra, 17 test users; wired into the CI compose overlay and the Gitea workflow; Playwright sign-in scenario. Verified on docker-1: 171 server tests green inside the CI stack against PostgreSQL and the Samba DC, 48 frontend tests, 8 Playwright scenarios against the live stack (password and PIN sign-in, lock and unlock, Admin group map). Findings recorded in the docs: the DC needs CAP_SYS_ADMIN, a hidden tab locks only after a minute as the old build did, and the app uses the alias ps-app for Playwright because "app" is on Chromium's HSTS preload list. Co-Authored-By: Claude Fable 5.1 <[email protected]>
This commit is contained in:
@@ -88,6 +88,40 @@ def cmd_doctor(a: argparse.Namespace) -> int:
|
||||
return 1 if doctor.failed(checks) else 0
|
||||
|
||||
|
||||
def cmd_ad_groups(a: argparse.Namespace) -> int:
|
||||
"""Print the 50 mapped group names, one per line, in map order (deploy/samba/groups.txt is a copy)."""
|
||||
from .auth import groups
|
||||
|
||||
if a.list:
|
||||
for name in groups.group_names():
|
||||
print(name)
|
||||
return 0
|
||||
print("packetstation ad-groups: say what to do (--list)", file=sys.stderr)
|
||||
return 2
|
||||
|
||||
|
||||
def cmd_ad_refresh(_: argparse.Namespace) -> int:
|
||||
"""Enumerate the mapped AD groups with the service account and refresh the users table."""
|
||||
from . import db
|
||||
from .auth import groups
|
||||
from .auth.directory import refresh_from_ad
|
||||
from .auth.ldap import Directory, LdapUnavailable
|
||||
|
||||
s = _settings()
|
||||
_setup_logging(s.log_level)
|
||||
try:
|
||||
with db.connect_as("app", s, autocommit=True) as conn:
|
||||
deps = groups.load_departments(conn)
|
||||
if deps:
|
||||
groups.use_departments(deps)
|
||||
res = refresh_from_ad(conn, Directory(s))
|
||||
except LdapUnavailable as e:
|
||||
log.error("ad-refresh: AD unavailable: %s", e)
|
||||
return 1
|
||||
print(json.dumps(res.as_dict(), indent=2))
|
||||
return 0
|
||||
|
||||
|
||||
def cmd_version(_: argparse.Namespace) -> int:
|
||||
print(f"packetstation {__version__} build {os.environ.get('PS_BUILD', 'dev')}")
|
||||
return 0
|
||||
@@ -126,6 +160,12 @@ def build_parser() -> argparse.ArgumentParser:
|
||||
d.add_argument("--skip", metavar="LIST", help="Comma list of: visual,mfiles,ldap,smtp,db,volume")
|
||||
d.add_argument("--send-test", metavar="ADDR", help="Also send one test message to ADDR")
|
||||
d.set_defaults(func=cmd_doctor)
|
||||
g = sub.add_parser("ad-groups", help="The AD groups Packet Station maps to roles")
|
||||
g.add_argument("--list", action="store_true", help="Print the 50 group names, one per line")
|
||||
g.set_defaults(func=cmd_ad_groups)
|
||||
sub.add_parser("ad-refresh", help="Refresh users and roles from AD now; prints the counts as JSON").set_defaults(
|
||||
func=cmd_ad_refresh
|
||||
)
|
||||
sub.add_parser("version", help="Print the version and build").set_defaults(func=cmd_version)
|
||||
h = sub.add_parser("healthcheck", help="Container healthcheck (exit 0 healthy, 1 not)")
|
||||
h.add_argument("target", choices=["app", "worker"])
|
||||
|
||||
Reference in New Issue
Block a user