-
-
Notifications
You must be signed in to change notification settings - Fork 104
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
BE: Auth: Support LDAPS for AD #840
base: main
Are you sure you want to change the base?
Conversation
@Haarolean PTAL |
fix sonar issues
private static final X509Certificate[] CERTS = new X509Certificate[0]; | ||
|
||
@Override | ||
public void checkClientTrusted(X509Certificate[] x509Certificates, String s) { |
Check failure
Code scanning / SonarCloud
Server certificates should be verified during SSL/TLS connections High
} | ||
|
||
@Override | ||
public void checkServerTrusted(X509Certificate[] x509Certificates, String s) { |
Check failure
Code scanning / SonarCloud
Server certificates should be verified during SSL/TLS connections High
public CustomSslSocketFactory() { | ||
try { | ||
SSLContext ctx = SSLContext.getInstance("TLS"); | ||
ctx.init(null, new TrustManager[] { new DisabledX509TrustManager() }, new SecureRandom()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can achieve the same like that:
SslContext context = SslContextBuilder.forClient()
.trustManager(InsecureTrustManagerFactory.INSTANCE)
.build();
and if there's a way to build a SSLSocketFactory
via supplying a SslContext
, we can reduce all this copypaste.
super.start(); | ||
|
||
if (sslEnabled) { | ||
setCustomCertAndRestartServer(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does it make sense to set the things up before start to avoid restarting?
import org.springframework.test.context.ContextConfiguration; | ||
|
||
@ContextConfiguration(initializers = {ActiveDirectoryLdapTest.Initializer.class}) | ||
public class ActiveDirectoryLdapTest extends AbstractActiveDirectoryIntegrationTest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like we're missing some tests in this test class :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved the tests to AbstractActiveDirectoryIntegrationTest
.
They are run for both classes ActiveDirectoryLdapTest/ActiveDirectoryLdapsTest
.
Or did I misunderstand?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, this is kinda counter-intuitive. Usually abstract
test classes are used as a test base for setting something up before executing tests. Here, ActiveDirectoryLdapTest
looks like it doesn't test anything due to the test itself being pulled up to AbstractActiveDirectoryIntegrationTest
instead.
What changes did you make? (Give an overview)
In this PR I added
CustomSslSocketFactory
that trusts all certificates by default.This allows you to use LDAPS to connect to an AD server without further specifying the path to the truststore/password.
Is there anything you'd like reviewers to focus on?
How Has This Been Tested? (put an "x" (case-sensitive!) next to an item)
Checklist (put an "x" (case-sensitive!) next to all the items, otherwise the build will fail)
Check out Contributing and Code of Conduct
A picture of a cute animal (not mandatory but encouraged)