Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .snyk
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Snyk (https://snyk.io) policy file
version: v1.25.0
# test code is not shipped; keep its fixtures out of Snyk Code results
exclude:
global:
- test/**
- py/**/tests/**
- py/testing/**
20 changes: 14 additions & 6 deletions src/prerna/util/linotp/LinOTPUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,17 @@ public class LinOTPUtil {

private static final Logger classLogger = LogManager.getLogger(LinOTPUtil.class);

private static final String SKIP_HOSTNAME_VERIFY_KEY = "linotp_skip_hostname_verify";

// host names are checked unless the admin opts out in social.properties
private static CloseableHttpClient newClient(SocialPropertiesUtil socialData) {
if (Boolean.parseBoolean(socialData.getProperty(SKIP_HOSTNAME_VERIFY_KEY, "false").trim())) {
classLogger.warn("{} is true so the LinOTP server's host name is not checked", SKIP_HOSTNAME_VERIFY_KEY);
return HttpClients.custom().setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE).build();
}
return HttpClients.createDefault();
}

/**
*
* @param request
Expand Down Expand Up @@ -184,8 +195,7 @@ public static LinOTPResponse login(HttpServletRequest request) throws ClientProt

// first, request for challenge request using user pin
// Create HTTP request via ssl port (https) and pass post parameters
try (CloseableHttpClient httpclient = HttpClients.custom()
.setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE).build()) {
try (CloseableHttpClient httpclient = newClient(socialData)) {
HttpPost httpPost = new HttpPost(requestURL);
List<NameValuePair> nvps = new ArrayList<NameValuePair>();
nvps.add(new BasicNameValuePair("user", username));
Expand Down Expand Up @@ -259,8 +269,7 @@ public static LinOTPResponse login(HttpServletRequest request) throws ClientProt
} else {
// subsequent challenge request with otp
// Create HTTP request via ssl port (https) and pass post parameters
try (CloseableHttpClient httpclient = HttpClients.custom()
.setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE).build()) {
try (CloseableHttpClient httpclient = newClient(socialData)) {
HttpPost httpPost = new HttpPost(requestURL);
HttpSession session = request.getSession();
username = (String) session.getAttribute(LINOTP_USERNAME);
Expand Down Expand Up @@ -445,8 +454,7 @@ private static LinOTPResponse resetCounter(LinOTPResponse linotpResponse, String
context.setCookieStore(cstore);

// Create HTTP request via ssl port (https) and pass post parameters
try (CloseableHttpClient httpclient = HttpClients.custom().setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE)
.build()) {
try (CloseableHttpClient httpclient = newClient(socialData)) {
HttpPost httpPost = new HttpPost(requestURL);

List<NameValuePair> nvps = new ArrayList<NameValuePair>();
Expand Down
Loading