Skip to content

himmelblau: add Entra ID provider with libhimmelblau integration#8661

Draft
dmulder wants to merge 4 commits intoSSSD:masterfrom
dmulder:dmulder/himmelblau_provider
Draft

himmelblau: add Entra ID provider with libhimmelblau integration#8661
dmulder wants to merge 4 commits intoSSSD:masterfrom
dmulder:dmulder/himmelblau_provider

Conversation

@dmulder
Copy link
Copy Markdown
Contributor

@dmulder dmulder commented Apr 28, 2026

This series introduces a new himmelblau provider to support Microsoft Entra ID authentication in SSSD, backed by libhimmelblau through its C API.

The three commits are structured as:

  • provider scaffold and SSSD target wiring (auth + id)
  • build-system integration for libhimmelblau
  • full provider implementation (authentication, MFA flows, user lookup, device enrollment/state)

What this adds:

  • Entra ID authentication via libhimmelblau
  • MFA support (including polling and user-input challenges)
  • NSS identity lookups through the broker interface
  • Automatic device enrollment and persistent device state
  • TPM-backed initialization and key handling
  • Mapping of libhimmelblau errors to PAM return codes

Build/dependency notes:

  • This introduces a new dependency on libhimmelblau (system library exposing a C-consumable interface).
  • Configure/build support prefers a system-installed libhimmelblau via pkg-config, with optional vendored fallback for development.
  • New configure option: --with-himmelblau={auto|yes|no}.
  • Packaging can add optional libhimmelblau-devel BuildRequires when enabling this provider.

For details on building and packaging the new system library, see:
https://build.opensuse.org/package/show/network:samba:STABLE/libhimmelblau

dmulder and others added 3 commits April 27, 2026 15:01
Add a minimal himmelblau authentication provider for Azure AD /
Microsoft Entra ID authentication with device join capabilities.

The provider implements:
- Authentication target (DPT_AUTH) - returns PAM_AUTHINFO_UNAVAIL stub
- Identity target (DPT_ID) - returns ENOENT stub
- Configuration options for domain and device storage path
- Preparation for transparent device join during first authentication

This is a loadable scaffold that integrates with SSSD's provider
framework via dlopen/dlsym. The provider will store device credentials
(RSA key pair, certificate, device_id) for authentication.

New files:
- src/providers/himmelblau/himmelblau_init.c - Module and target initialization
- src/providers/himmelblau/himmelblau_auth.c - Authentication handler
- src/providers/himmelblau/himmelblau_id.c - Identity handler
- src/providers/himmelblau/himmelblau_opts.c - Configuration options
- src/providers/himmelblau/himmelblau_common.h - Context structures
- src/providers/himmelblau/himmelblau_opts.h - Options declarations

Signed-off-by: David Mulder <dmulder@samba.org>
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add build system support for linking the himmelblau provider against
libhimmelblau (Rust library with C FFI bindings). Implements a hybrid
approach that prefers system-installed libhimmelblau via pkg-config,
with optional fallback to vendored build using cargo-c for development.

- Add src/external/libhimmelblau.m4 for library detection
- Add --with-himmelblau configure option (auto/yes/no)
- Make himmelblau provider conditional on BUILD_HIMMELBLAU
- Add HIMMELBLAU_CFLAGS and HIMMELBLAU_LIBS to provider build
- Support vendored build with cargo cbuild when system library unavailable
- Update RPM spec for optional libhimmelblau-devel BuildRequires

The provider remains a stub; actual integration with libhimmelblau C API
will follow in subsequent commits.

Signed-off-by: David Mulder <dmulder@samba.org>
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Implement complete himmelblau provider for Azure AD/Entra ID
authentication in SSSD. This integrates libhimmelblau C API to
provide Azure AD authentication with MFA support and device enrollment.

Key features:
- Azure AD authentication with MFA (polling and user input types)
- Automatic device enrollment on first authentication
- Persistent device state (auth_value, transport_key, cert_key)
- NSS integration for user lookups via broker_check_user_exists()
- TPM-backed machine key and broker initialization
- Error mapping from libhimmelblau to PAM status codes

Implementation:
- himmelblau_auth.c: PAM authentication handler with MFA flows
- himmelblau_id.c: NSS account info handler for user lookups
- himmelblau_device.c: Device state management and key persistence
- himmelblau_util.c: Error mapping utilities
- himmelblau_init.c: Broker, TPM, and key initialization

Device enrollment state persists across SSSD restarts by saving:
- auth_value for machine key
- LoadableMsOapxbcRsaKey (transport key)
- LoadableMsDeviceEnrolmentKey (certificate key)

These keys are loaded on startup and passed to broker_init() to
restore enrolled device state for device-based authentication.

Signed-off-by: David Mulder <dmulder@samba.org>
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@dmulder dmulder marked this pull request as draft April 28, 2026 17:37
@alexey-tikhonov alexey-tikhonov added the no-backport This should go to target branch only. label Apr 28, 2026
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the Himmelblau provider to SSSD, enabling Azure AD authentication and identity lookups via libhimmelblau. The changes include build system updates, provider initialization with TPM support, device enrollment logic, and MFA-capable authentication handlers. Feedback was provided regarding the insecure clearing of sensitive password buffers in destructors, where using strlen may leave data behind if null bytes are present.

Comment thread src/providers/himmelblau/himmelblau_auth.c Outdated
Comment thread src/providers/himmelblau/himmelblau_auth.c Outdated
@dmulder
Copy link
Copy Markdown
Contributor Author

dmulder commented Apr 28, 2026

@sumit-bose and @abbra this is a WIP start to the discussions we had the other day.

Comment thread contrib/sssd.spec.in
BuildRequires: libdhash-devel >= 0.4.2
BuildRequires: libfido2-devel
%if 0%{?with_himmelblau}
BuildRequires: libhimmelblau-devel >= 0.8.0
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do I understand correctly lib isn't yet(?) available in Fedora repos?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not. It's not even in openSUSE distro repos yet: https://build.opensuse.org/package/show/network:samba:STABLE/libhimmelblau

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Canonical is currently shipping it vendored as part of Authd. SUSE ships it via the rust crate, inside of Himmelblau.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you could alternatively just vendor the package within SSSD, and ship it bundled.

Replace unsafe memset() with strlen() calls with secure memory erasure
using sss_erase_talloc_mem_securely(). The previous implementation had
several security issues: strlen() stops at embedded null bytes leaving
password remnants in memory, memset() can be optimized away by the
compiler, and authentication tokens were not being erased at all.

The fix sets sss_erase_talloc_mem_securely as a destructor on all
sensitive data (passwords, access_tokens, refresh_tokens) immediately
after allocation. This ensures full buffer erasure using explicit_bzero()
which cannot be optimized away, and works correctly with embedded nulls.

Signed-off-by: David Mulder <dmulder@samba.org>
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-backport This should go to target branch only.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants