Skip to content

feat: add conditional authenticator that matches org and client attributes at runtime#438

Open
tchoumi313 wants to merge 2 commits intop2-inc:mainfrom
tchoumi313:feat/conditional-org-client-attr
Open

feat: add conditional authenticator that matches org and client attributes at runtime#438
tchoumi313 wants to merge 2 commits intop2-inc:mainfrom
tchoumi313:feat/conditional-org-client-attr

Conversation

@tchoumi313
Copy link

Summary

This PR adds a new conditional authenticator that compares a user organization attribute against a client attribute value resolved at login time.

It is intended for multi-tenant setups where each OIDC client carries a tenant marker such as tenant_id, and authentication should continue only when the user belongs to a matching organization.

What is added

  • ConditionalOrgAttributeMatchesClientAttribute
  • ConditionalOrgAttributeMatchesClientAttributeFactory
  • Provider ID: conditional-org-client-attr

Behavior

Config properties:

  • org_attribute_name (String): organization attribute key to check, for example tenant_id
  • client_attribute_name (String): client attribute key containing the expected value
  • negate_output (Boolean): invert the result

Evaluation flow:

  1. Read the current client attribute value using client_attribute_name
  2. Enumerate the user’s organization memberships
  3. Return a match if any organization has org_attribute_name == clientAttributeValue
  4. Apply negate_output when configured

Why this is needed

The existing ConditionalOrgAttributeValue provider compares an organization attribute against a static value configured in the authenticator.

This new provider allows the expected value to come from the current client at runtime, so one shared flow can work across many tenant-specific clients without duplicating flows per tenant.

Security model

The provider is fail-closed by design.

Missing config, missing client attribute, missing OrganizationProvider, or empty memberships evaluate to no-match.

Validation

  • Maven package build passed
  • The built jar contains the new authenticator classes
  • The factory is registered for discovery and the provider is visible at runtime as conditional-org-client-attr
Screenshot from2026-03-10 23-41-59 image

Notes

  • This PR adds a new provider alongside the existing ConditionalOrgAttributeValue; it does not modify the behavior of the existing provider.
  • Implementation follows the existing condition/factory pattern in this module and keeps scope limited to a new condition.

Implements a new conditional authenticator that checks if an organization's
attribute value matches a client attribute. This allows dynamic tenant/org
isolation at the authentication flow level without hardcoding values.

- Checks org attribute against client attribute (retrieved at runtime)
- Supports negate_output config for deny conditions
- Mirrors ConditionalOrgAttributeValue pattern but uses client attributes
- Fail-closed security model (denies on missing attributes)
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