Skip to content

feat(keycloak): add keycloak_realm_security fetcher - #387

Open
bruceweygandt wants to merge 1 commit into
mainfrom
feat/keycloak-realm-security
Open

bruceweygandt wants to merge 1 commit into
mainfrom
feat/keycloak-realm-security

Conversation

@bruceweygandt

Copy link
Copy Markdown
Contributor

Summary

Adds the keycloak category and its first fetcher, keycloak_realm_security (evidence set EVD-KEYCLOAK-REALM-SECURITY). It reads a Keycloak realm through the Admin REST API with a read-only service-account client and reports sessions, brute-force lockout, password policy, the browser and reset-credentials flows, required actions, identity providers, user federation, and login and admin event logging.

  • Read-only: one client-credentials token request, then GETs under /admin/realms/{realm}. The service account needs only view-realm, view-identity-providers and view-events.
  • Effective requirements, not labels: each flow step is marked always required only when it is REQUIRED and every subflow above it is REQUIRED, so a phishing-resistant authenticator offered as one ALTERNATIVE does not read as enforced.
  • No secrets in evidence: identity provider configs (client secrets) and user federation configs (bind credentials) are never copied.
  • Null, not empty: each section is null when its call fails, and any failed call exits non-zero with the matching status code (auth_failed, not_authorized, target_unreachable, bad_config).
  • _shared/keycloak_client.py is shared so the next Keycloak fetchers (users_and_roles, service_accounts, admin_events) can reuse it.

Validators are in a separate PR to all-validators.

Solution Capabilities this supports (Defense Unicorns)

Capability What the evidence shows Fit
Phishing-Resistant Authentication Enforcement WebAuthn or X.509 always required in the browser flow Direct
Session Expiry and Re-Authentication Idle and maximum session lifetimes, remember me Bounded: no evidence of re-authentication on role or authenticator change
Workforce Sign-In Notification Terms and conditions as a default required action Bounded: shown once per user, not every sign-in
Federated Workforce Authentication Identity providers, user federation, self-registration Bounded
Automated Lockout Brute-force detection, threshold, lockout length Bounded: the capability credits Entra ID PIM
Privileged Function Logging Admin events and their details Bounded: the capability credits Azure Monitor
Conditional Sign-In Enforcement, Fallback Authenticator Restriction Conditional authenticators; recovery flow steps Collected, no validator yet: needs the real flow to judge

Steps to validate

  • pytest tests/test_keycloak_realm_security.py: 12 passed (flow nesting, password policy parsing, null sections, secrets kept out, token and auth-realm handling, 403 and 401 paths, missing settings).
  • pytest tests/test_contracts.py: 903 passed, including the instructions layout and summary documentation checks.
  • Smoke run with fake credentials: evidence saved, exit 1, status target_unreachable.
  • Not run against a live Keycloak yet; the first real run on DU staging will confirm field values and flow shapes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant