Commit e2f0564b authored by Gradl, Tobias's avatar Gradl, Tobias
Browse files

18: Adapt according to needs of first actual implementation (CR)

Task-Url: #18
parent 68b8b536
Pipeline #17978 passed with stage
in 1 minute and 48 seconds
...@@ -5,7 +5,7 @@ plugins { ...@@ -5,7 +5,7 @@ plugins {
allprojects { allprojects {
group = 'eu.dariah.de' group = 'eu.dariah.de'
version = '2.1.2-SNAPSHOT' version = '2.1.3-SNAPSHOT'
apply plugin: 'eclipse' apply plugin: 'eclipse'
......
...@@ -55,7 +55,7 @@ public class SecurityConfig { ...@@ -55,7 +55,7 @@ public class SecurityConfig {
@Setter private String defaultLoginUrl = null; @Setter private String defaultLoginUrl = null;
@Setter private String defaultLogoutUrl = null; @Setter private String defaultLogoutUrl = null;
@Getter private List<String> enabledClientNames = null; @Getter private List<String> enabledClientNames = new ArrayList<>(0);
public String getDefaultLoginUrl() { return defaultLoginUrl==null ? baseUrl : defaultLoginUrl; } public String getDefaultLoginUrl() { return defaultLoginUrl==null ? baseUrl : defaultLoginUrl; }
public String getDefaultLogoutUrl() { return defaultLogoutUrl==null ? baseUrl : defaultLogoutUrl; } public String getDefaultLogoutUrl() { return defaultLogoutUrl==null ? baseUrl : defaultLogoutUrl; }
......
...@@ -4,6 +4,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -4,6 +4,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import eu.dariah.de.dariahsp.config.SecurityConfig;
import eu.dariah.de.dariahsp.web.AuthInfoHandlerInterceptor; import eu.dariah.de.dariahsp.web.AuthInfoHandlerInterceptor;
import eu.dariah.de.dariahsp.web.AuthInfoHelper; import eu.dariah.de.dariahsp.web.AuthInfoHelper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -18,6 +19,7 @@ import lombok.extern.slf4j.Slf4j; ...@@ -18,6 +19,7 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j @Slf4j
public class AuthInfoConfigurer implements WebMvcConfigurer { public class AuthInfoConfigurer implements WebMvcConfigurer {
@Autowired private AuthInfoHelper authInfoHelper; @Autowired private AuthInfoHelper authInfoHelper;
@Autowired private SecurityConfig securityConfig;
/** /**
* Adds an {@link AuthInfoHandlerInterceptor} to the {@link InterceptorRegistry} * Adds an {@link AuthInfoHandlerInterceptor} to the {@link InterceptorRegistry}
...@@ -29,8 +31,6 @@ public class AuthInfoConfigurer implements WebMvcConfigurer { ...@@ -29,8 +31,6 @@ public class AuthInfoConfigurer implements WebMvcConfigurer {
} }
private AuthInfoHandlerInterceptor authInfoHandlerInterceptor() { private AuthInfoHandlerInterceptor authInfoHandlerInterceptor() {
AuthInfoHandlerInterceptor i = new AuthInfoHandlerInterceptor(); return new AuthInfoHandlerInterceptor(authInfoHelper, securityConfig.getEnabledClientNames());
i.setAuthInfoHelper(authInfoHelper);
return i;
} }
} }
\ No newline at end of file
package eu.dariah.de.dariahsp.web; package eu.dariah.de.dariahsp.web;
import java.util.List;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
...@@ -9,18 +11,17 @@ import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; ...@@ -9,18 +11,17 @@ import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import org.springframework.web.servlet.support.RequestContextUtils; import org.springframework.web.servlet.support.RequestContextUtils;
import eu.dariah.de.dariahsp.web.model.AuthPojo; import eu.dariah.de.dariahsp.web.model.AuthPojo;
import lombok.RequiredArgsConstructor;
/** /**
* Interceptor that adds basic authentication and authorization information as {@link AuthPojo} to each request model * Interceptor that adds basic authentication and authorization information as {@link AuthPojo} to each request model
* *
* @author Tobias Gradl * @author Tobias Gradl
*/ */
@RequiredArgsConstructor
public class AuthInfoHandlerInterceptor extends HandlerInterceptorAdapter { public class AuthInfoHandlerInterceptor extends HandlerInterceptorAdapter {
private AuthInfoHelper authInfoHelper; private final AuthInfoHelper authInfoHelper;
private final List<String> configuredAuthClientNames;
public AuthInfoHelper getAuthInfoHelper() { return authInfoHelper; }
public void setAuthInfoHelper(AuthInfoHelper authInfoHelper) { this.authInfoHelper = authInfoHelper; }
/* /*
* Adds the _sessionId and _auth request model attributes * Adds the _sessionId and _auth request model attributes
...@@ -33,6 +34,7 @@ public class AuthInfoHandlerInterceptor extends HandlerInterceptorAdapter { ...@@ -33,6 +34,7 @@ public class AuthInfoHandlerInterceptor extends HandlerInterceptorAdapter {
AuthPojo auth = authInfoHelper.getAuth(); AuthPojo auth = authInfoHelper.getAuth();
String sessionId = authInfoHelper.getOrCreateSessionId(); String sessionId = authInfoHelper.getOrCreateSessionId();
modelAndView.addObject("_sessionId", sessionId); modelAndView.addObject("_sessionId", sessionId);
modelAndView.addObject("_authClients", configuredAuthClientNames);
if (auth!=null && auth.isAuth()) { if (auth!=null && auth.isAuth()) {
modelAndView.addObject("_auth", auth); modelAndView.addObject("_auth", auth);
setUserLocale(request, response, auth.getLanguage()); setUserLocale(request, response, auth.getLanguage());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment