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

SimpleDirContextAuthenticationStrategy and DefaultSpringSecurityContextSource should accept SSLSocketFactory #546

Open
marschall opened this issue Jan 8, 2020 · 5 comments

Comments

@marschall
Copy link

In order to support custom truststores more SSL configuration SimpleDirContextAuthenticationStrategy and DefaultSpringSecurityContextSource should accept a SSLSocketFactory.

This is a follow up for #494

@jakub-moravec
Copy link

This would be very helpful.

@jzheaux
Copy link
Contributor

jzheaux commented Feb 23, 2022

Hi, @marschall. I can see how this would be nice, but I'm not sure the underlying Java API supports it since ultimately the DirContext environment wants a class name, not a fully-constructed class in the java.naming.ldap.factory.socket environment property.

Is there a way that SimpleDirContextAuthenticationStrategy and DefaultSpringSecurityContextSource could accept a fully-constructed SSLSocketFactory?

@jzheaux jzheaux self-assigned this Feb 23, 2022
@jzheaux jzheaux added in: core status: waiting-for-feedback We need additional information before we can continue type: enhancement labels Feb 23, 2022
@marschall
Copy link
Author

Hi, @marschall. I can see how this would be nice, but I'm not sure the underlying Java API supports it since ultimately the DirContext environment wants a class name, not a fully-constructed class in the java.naming.ldap.factory.socket environment property.

Yes, that's a problem. There is discussion about this in #547. For a possible solution see https://github.com/marschall/ssl-socket-factory-factory-bean.

@jzheaux
Copy link
Contributor

jzheaux commented Mar 1, 2022

@marschall, sorry, I'm still not quite seeing how the factory bean helps in this situation. It may help in others, but in the cases listed in this ticket, the Java API asks for a class name. Having a factory construct the object still doesn't help since Java doesn't allow for specifying socket factory instances.

Does it sound like I'm missing something? If so, maybe it would help if you shared a code snippet of how DefaultSpringSecurityContextSource should change.

@jzheaux jzheaux added this to the 2.4.x milestone Sep 30, 2024
@jzheaux jzheaux modified the milestones: 2.4.x, 3.3.x Oct 11, 2024
@jzheaux jzheaux removed the status: waiting-for-feedback We need additional information before we can continue label Oct 11, 2024
@jzheaux
Copy link
Contributor

jzheaux commented Oct 11, 2024

Jotting down a quick note to myself to test the following:

contextSource.setBaseEnvironmentProperties(Map.of("java.naming.ldap.factory.socket", CustomSslSocketFactory.class.getName()))

The possible drawback is the setting would apply to the anonymous and authenticated environments, which may not be desired.

Alternatively, SimpleDirContextAuthenticationStrategy could add a setter to post-process the Hashtable or perhaps a constructor.

It sort of begs the question of whether all DirContextAuthenticationStrategys should have a way to augment the hashtable, so a final way to consider is whether Spring Security can easily expose its wrapper authentication strategy and simplify post-processing through delegation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants