Skip to content

[#225] Bind identity provider configs through the DS bind methods - #226

Open
vharseko wants to merge 1 commit into
OpenIdentityPlatform:masterfrom
vharseko:issue-225-idp-bind
Open

vharseko wants to merge 1 commit into
OpenIdentityPlatform:masterfrom
vharseko:issue-225-idp-bind

Conversation

@vharseko

Copy link
Copy Markdown
Member

Fixes #225

Problem

IdentityProviderService declared its @Reference to IdentityProviderConfig on a Map<String, List<IdentityProviderConfig>> field. Declarative Services cannot inject that type, so SCR rejected the reference (Field identityProviders ... has unsupported type java.util.Map) and bindIdentityProviderConfig / unbindIdentityProviderConfig were never called. As a result /identityProviders always answered {"providers":[]}, no OPENID_CONNECT / OAUTH auth module was generated, and the social self-service stage received no providers.

The annotations were moved onto the fields in 5aa45c8 (the Felix SCR → OSGi DS migration). The same thing happened in AuthenticationService: its @Reference to IdentityProviderService is on the field, and because the field type is valid, SCR injects it without logging anything. bindIdentityProviderService, which registers the provider listener, was never called either, so provider changes never reached the authentication filter.

Changes

  • IdentityProviderService: the reference is declared on bindIdentityProviderConfig, with an explicit unbind and the same reference name identityProviders. Providers are added atomically (computeIfAbsent + CopyOnWriteArrayList). getIdentityProviderByType now returns an empty list for a type with no bound provider. Before this change that path could not be reached; with providers bound it would have thrown an NPE.
  • AuthenticationService: the reference is declared on bindIdentityProviderService, and unbindIdentityProviderService now takes the service argument that DS requires. Both methods rebuild the social auth modules. This does nothing before activation, and covers IdentityProviderService arriving after AuthenticationService has already activated.

Generated descriptors:

<reference name="identityProviders" cardinality="0..n" policy="dynamic" interface="org.forgerock.openidm.idp.impl.IdentityProviderConfig" bind="bindIdentityProviderConfig" unbind="unbindIdentityProviderConfig"/>
<reference name="identityProviderService" cardinality="0..1" policy="dynamic" interface="org.forgerock.openidm.idp.impl.IdentityProviderService" bind="bindIdentityProviderService" unbind="unbindIdentityProviderService"/>

Tests

  • IdentityProviderServiceTest: added tests for a lookup by a type with no bound providers, and for unbind (the provider is removed and listeners are notified).
  • AuthenticationServiceTest: added tests that bind registers the listener and that unbind unregisters it and stops injecting providers. The existing tests now call setConfig after bind, which is the order SCR uses (bind before activate).
  • The existing tests called bind* directly and so never exercised the SCR wiring. The descriptors above were checked in the built jars.

Note: #207 touches the same line in getIdentityProviderByType, so whichever PR merges second will get a trivial conflict.

… DS bind methods

The @reference to IdentityProviderConfig sat on a Map field, a type
Declarative Services cannot inject, so SCR rejected it and
bindIdentityProviderConfig was never called: /identityProviders stayed
empty and no social auth module was generated. Move the annotation to
the bind method, and do the same for AuthenticationService, whose
bindIdentityProviderService (which registers the provider listener)
was bypassed by field injection too.

Also make getIdentityProviderByType return an empty list for a type
with no bound provider, and add providers atomically.

Fixes OpenIdentityPlatform#225
@vharseko vharseko added bug Something isn't working concurrency Thread-safety, locking and synchronization issues java Pull requests that update Java code test Tests and test infrastructure (unit, e2e, smoke) labels Sep 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working concurrency Thread-safety, locking and synchronization issues java Pull requests that update Java code test Tests and test infrastructure (unit, e2e, smoke)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Configured identity providers are never bound, so /identityProviders is always empty

1 participant