Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InMemoryClientRegistrationRepository should accept an empty set of registrations #14508

Open
espenhw opened this issue Jan 30, 2024 · 2 comments
Assignees
Labels
in: oauth2 An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose) status: feedback-provided Feedback has been provided type: enhancement A general enhancement

Comments

@espenhw
Copy link

espenhw commented Jan 30, 2024

InMemoryClientRegistrationRepository can be constructed with either a List of ClientRegistrations or a Map of same. However,
passing an empty list is a runtime error while passing an empty map is not.

Commit e554547 changed the assertion in the list case from notNull to notEmpty.

IMO, an empty repository is a perfectly valid use case, so the list constructor should also accept an empty list.

@espenhw espenhw added status: waiting-for-triage An issue we've not yet triaged type: bug A general bug labels Jan 30, 2024
@jzheaux
Copy link
Contributor

jzheaux commented Apr 15, 2024

@espenhw, thanks for the suggestion; however e554547 brings the var args and list constructors into alignment and both require the list to be non-empty. This is also consistent across the servlet and reactive versions.

Can you better explain your use case and why you need to be able to construct a repository with no values?

@jzheaux jzheaux self-assigned this Apr 15, 2024
@jzheaux jzheaux added type: enhancement A general enhancement in: oauth2 An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose) and removed status: waiting-for-triage An issue we've not yet triaged type: bug A general bug labels Apr 15, 2024
@jzheaux jzheaux changed the title Inconsistent constructors in org.springframework.security.oauth2.client.registration.InMemoryClientRegistrationRepository InMemoryClientRegistrationRepository should accept an empty set of registrations Apr 15, 2024
@jzheaux jzheaux added status: waiting-for-triage An issue we've not yet triaged status: waiting-for-feedback We need additional information before we can continue type: enhancement A general enhancement and removed type: enhancement A general enhancement status: waiting-for-triage An issue we've not yet triaged labels Apr 15, 2024
@espenhw
Copy link
Author

espenhw commented Apr 16, 2024

Once again: There is a constructor that takes a Map (https://docs.spring.io/spring-security/site/docs/current/api/org/springframework/security/oauth2/client/registration/InMemoryClientRegistrationRepository.html#%3Cinit%3E(java.util.Map)). That constructor accepts empty input, while the list- and varargs-taking constructors do not. It should be consistent.

As for why you'd want an empty registry: Imagine you have support for a configurable set of OIDC providers in addition to other authentication sources. Removing all the OIDC-related wiring just because there happens to be no OIDC providers configured isn't feasible.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: oauth2 An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose) status: feedback-provided Feedback has been provided type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

3 participants