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

Issue30 builderclasses #60

Merged
merged 18 commits into from
Oct 10, 2022
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
7 changes: 5 additions & 2 deletions src/main/java/io/aiven/klaw/auth/KwAuthenticationService.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,11 @@ private DirContextOperations searchForUser(DirContext context, String username)
String searchRoot =
this.adRootDn != null ? this.adRootDn : this.searchRootFromPrincipal(bindPrincipal);
String searchFilterUpdated;
if (adFilter != null && !adFilter.equals("")) searchFilterUpdated = adFilter;
else searchFilterUpdated = searchFilter;
if (adFilter != null && !adFilter.equals("")) {
searchFilterUpdated = adFilter;
} else {
searchFilterUpdated = searchFilter;
}

try {
return SpringSecurityLdapTemplate.searchForSingleEntryInternal(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,21 @@ private String validateUrl(String urlFromAddressBar) {
if (urlFromAddressBar != null) {
urlFromAddressBar = urlFromAddressBar.replace(contextPath + "/", "");

if (urlFromAddressBar.contains("login")) urlFromAddressBar = "index";
if (urlFromAddressBar.contains("login")) {
urlFromAddressBar = "index";
}

if (!urlFromAddressBar.contains("loggedin=true")) {
if (urlFromAddressBar.contains("?")) urlFromAddressBar += "&loggedin=true";
else urlFromAddressBar += "?loggedin=true";
if (urlFromAddressBar.contains("?")) {
urlFromAddressBar += "&loggedin=true";
} else {
urlFromAddressBar += "?loggedin=true";
}
}

} else urlFromAddressBar = "";
} else {
urlFromAddressBar = "";
}

return urlFromAddressBar;
}
Expand Down
13 changes: 9 additions & 4 deletions src/main/java/io/aiven/klaw/auth/KwRequestFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Lazy;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.AuthenticationServiceException;
import org.springframework.security.core.Authentication;
Expand All @@ -36,15 +37,15 @@ public class KwRequestFilter extends UsernamePasswordAuthenticationFilter {

@Autowired KwAuthenticationService kwAuthenticationService;

@Autowired private AuthenticationManager authenticationManager;
@Lazy private AuthenticationManager authenticationManager;

@Autowired private KwAuthenticationFailureHandler kwAuthenticationFailureHandler;

@Autowired private KwAuthenticationSuccessHandler kwAuthenticationSuccessHandler;

@Override
@Autowired
public void setAuthenticationManager(AuthenticationManager authenticationManager) {
public void setAuthenticationManager(@Lazy AuthenticationManager authenticationManager) {
super.setAuthenticationManager(authenticationManager);
}

Expand All @@ -56,7 +57,9 @@ public Authentication attemptAuthentication(
if ("saas".equals(kwInstallationType)) {
String gRecaptchaResponse = request.getParameter("g-recaptcha-response");
boolean captchaResponse = validateCaptchaService.validateCaptcha(gRecaptchaResponse);
if (!captchaResponse) throw new AuthenticationServiceException("Invalid Captcha.");
if (!captchaResponse) {
throw new AuthenticationServiceException("Invalid Captcha.");
}
}

if ("ad".equals(authenticationType)) {
Expand All @@ -68,7 +71,9 @@ public Authentication attemptAuthentication(
// User in KW db
return super.attemptAuthentication(request, response);
}
} else return super.attemptAuthentication(request, response);
} else {
return super.attemptAuthentication(request, response);
}
}

@Override
Expand Down
Loading