Skip to content

Provide @ConditionalOn… annotations for all concrete conditions #41044

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

Closed
OrangeDog opened this issue Jun 10, 2024 · 11 comments
Closed

Provide @ConditionalOn… annotations for all concrete conditions #41044

OrangeDog opened this issue Jun 10, 2024 · 11 comments
Assignees
Labels
type: enhancement A general enhancement
Milestone

Comments

@OrangeDog
Copy link
Contributor

As I'm partially customising the SAML configuration, it would be very useful to be able to make my config also conditional on org.springframework.boot.autoconfigure.security.saml2.RegistrationConfiguredCondition, rather than having to duplicate it.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jun 10, 2024
@wilkinsona
Copy link
Member

We wouldn't make the condition itself public, but provide a public annotation that references the condition. That said, without significant demand, I'm not sure that it's something that we'd want to do and copy-pasting the code may be your best option. To help us to decide, can you please describe in a bit more detail what you're trying to do and the role that the condition would perform in that.

@wilkinsona wilkinsona added the status: waiting-for-feedback We need additional information before we can continue label Jun 10, 2024
@OrangeDog
Copy link
Contributor Author

I'm trying to have service(s) that can optionally have SAML enabled via application properties.

I am building my own RelyingPartyRegistrationRepository, so I cannot use @ConditionalOnBean. There's only a single properly that triggers SAML configuration, but it's a map hence why you have a RegistrationConfiguredCondition in the first place instead of being able to use @ConditionalOnProperty.

What I have done is define my own saml.enabled boolean property to use, but that's not the best because Boot's autoconfiguration ignores it.

@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 Jun 10, 2024
@wilkinsona wilkinsona added for: team-meeting An issue we'd like to discuss as a team to make progress and removed status: feedback-provided Feedback has been provided labels Jun 10, 2024
@philwebb
Copy link
Member

Thanks for the additional information @OrangeDog. I'm afraid I don't think we should make RegistrationConfiguredCondition public in our own code. I'd rather keep that code internal.

Give that the class is only about 60 lines I would recommend taking the copy/paste approach that @wilkinsona suggested.

@philwebb philwebb closed this as not planned Won't fix, can't repro, duplicate, stale Jun 10, 2024
@philwebb philwebb added status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-triage An issue we've not yet triaged for: team-meeting An issue we'd like to discuss as a team to make progress labels Jun 10, 2024
@OrangeDog
Copy link
Contributor Author

Fine I guess, but I still have to check and re-copy it every time you change it.

@philwebb
Copy link
Member

If it's any consolation, the class hasn't had any functional changes since it was written 5 years ago.

@gbaso
Copy link

gbaso commented Nov 19, 2024

I found this issue looking for the same problem. While I understand the decision to keep the condition class, it's not really satisfying since the corresponding oauth2 condition is indeed public: ClientsConfiguredCondition.

Would it be possible to reconsider the decision? Or, alternatively, add public annotations that reference the conditions?

@philwebb philwebb added the for: team-meeting An issue we'd like to discuss as a team to make progress label Nov 19, 2024
@philwebb
Copy link
Member

philwebb commented Dec 9, 2024

ClientsConfiguredCondition is public because it's used by other packages so we couldn't make it package-private. Having said that, the inconsistency is a bit annoying. I'm going to reopen this one to discuss further if we should make the class public or add an annotation.

@philwebb philwebb reopened this Dec 9, 2024
@philwebb philwebb added type: enhancement A general enhancement status: pending-design-work Needs design work before any code can be developed and removed status: declined A suggestion or change that we don't feel we should currently apply labels Dec 9, 2024
@philwebb
Copy link
Member

We discussed this today and we'd like to hide the ClientsConfiguredCondition behind a @ConditionalOnClientsConfigured annotation which we'll make public. We'd actually like to go further and make sure that all *Condition classes are package-private and have an annotation.

@philwebb philwebb removed the for: team-meeting An issue we'd like to discuss as a team to make progress label Dec 18, 2024
@philwebb philwebb added this to the 3.5.x milestone Dec 18, 2024
@wilkinsona wilkinsona changed the title Make RegistrationConfiguredCondition public Provide @ConditionalOn… annotations for all concrete conditions Jan 23, 2025
@wilkinsona wilkinsona self-assigned this Jan 23, 2025
@wilkinsona
Copy link
Member

A first pass at this can be found in this branch. I'd like to get some feedback from the team on the names of the new annotations:

We should also consider if we want to list the new annotations in the relevant section of the docs.

@wilkinsona wilkinsona added the for: team-attention An issue we'd like other members of the team to review label Jan 24, 2025
@OrangeDog
Copy link
Contributor Author

My 2¢ are that the words Enabled and Configured are probably not needed in the names.

@wilkinsona
Copy link
Member

We're going to keep @ConditionalOnEnabledDevTools as we feel that the enabled part if important to distinguish between DevTools just being on the classpath. We're going to rename @ConditionalOnOAuth2ClientRegistrationConfigured to @ConditionalOnOAuth2ClientRegistrationProperties to make it clear that it's properties that have to be set for the condition to match.

@wilkinsona wilkinsona removed for: team-attention An issue we'd like other members of the team to review status: pending-design-work Needs design work before any code can be developed labels Feb 17, 2025
@wilkinsona wilkinsona modified the milestones: 3.5.x, 3.5.0-M3 Mar 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

5 participants