Class OidcUserProvider

java.lang.Object
io.fluxzero.sdk.tracking.handling.authentication.AbstractUserProvider
io.fluxzero.sdk.tracking.handling.authentication.OidcUserProvider
All Implemented Interfaces:
UserProvider

public class OidcUserProvider extends AbstractUserProvider
Reference UserProvider for Fluxzero-compatible OIDC providers.

The provider resolves incoming WebRequest bearer tokens by calling the configured OIDC userinfo_endpoint. This intentionally keeps the SDK implementation dependency-free while supporting both the real Fluxzero IDP and the local dev/test IDP, because both expose the same OIDC userinfo contract.

Typical application setup:

Fluxzero fluxzero = DefaultFluxzero.builder()
    .registerUserProvider(OidcUserProvider.fromProperties())
    .build();

Configuration is read from fluxzero.auth.oidc.issuer; optionally fluxzero.auth.oidc.userinfo-endpoint can override discovery.

  • Field Details

  • Constructor Details

    • OidcUserProvider

      public OidcUserProvider(String issuer)
    • OidcUserProvider

      public OidcUserProvider(String issuer, String userInfoEndpoint)
    • OidcUserProvider

      public OidcUserProvider(String issuer, String userInfoEndpoint, Duration timeout)
  • Method Details

    • fromProperties

      public static OidcUserProvider fromProperties()
      Creates a provider from application properties.
    • getUserById

      public User getUserById(Object userId)
      Description copied from interface: UserProvider
      Retrieves a User by their unique identifier.

      This method is primarily used in TestFixture-based access control tests, such as when using whenCommandByUser(...), to simulate requests by a specific user.

      Implementations may return null if the user cannot be found, or alternatively return a new, unprivileged User instance. The latter approach allows tests to verify authorization behavior for unknown or default users without requiring explicit user creation.

      Parameters:
      userId - the unique identifier of the user (typically a String or number)
      Returns:
      the matching User, a default unprivileged User, or null if not found
    • getSystemUser

      public User getSystemUser()
      Description copied from interface: UserProvider
      Returns the User representing the system (non-human) identity. Typically used for scheduled messages, internal services, etc.
    • fromMessage

      public User fromMessage(HasMessage message)
      Description copied from class: AbstractUserProvider
      Extracts a User from the metadata of a message.

      Uses the configured metadataKey to locate the user in the metadata of the given message.

      Specified by:
      fromMessage in interface UserProvider
      Overrides:
      fromMessage in class AbstractUserProvider
      Parameters:
      message - the message containing metadata
      Returns:
      the resolved User, or null if not found
    • resolveUser

      protected OidcUser resolveUser(String bearerToken)