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 {
allprojects {
group = 'eu.dariah.de'
version = '2.1.2-SNAPSHOT'
version = '2.1.3-SNAPSHOT'
apply plugin: 'eclipse'
......
......@@ -55,7 +55,7 @@ public class SecurityConfig {
@Setter private String defaultLoginUrl = 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 getDefaultLogoutUrl() { return defaultLogoutUrl==null ? baseUrl : defaultLogoutUrl; }
......
......@@ -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.WebMvcConfigurer;
import eu.dariah.de.dariahsp.config.SecurityConfig;
import eu.dariah.de.dariahsp.web.AuthInfoHandlerInterceptor;
import eu.dariah.de.dariahsp.web.AuthInfoHelper;
import lombok.extern.slf4j.Slf4j;
......@@ -18,6 +19,7 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
public class AuthInfoConfigurer implements WebMvcConfigurer {
@Autowired private AuthInfoHelper authInfoHelper;
@Autowired private SecurityConfig securityConfig;
/**
* Adds an {@link AuthInfoHandlerInterceptor} to the {@link InterceptorRegistry}
......@@ -29,8 +31,6 @@ public class AuthInfoConfigurer implements WebMvcConfigurer {
}
private AuthInfoHandlerInterceptor authInfoHandlerInterceptor() {
AuthInfoHandlerInterceptor i = new AuthInfoHandlerInterceptor();
i.setAuthInfoHelper(authInfoHelper);
return i;
return new AuthInfoHandlerInterceptor(authInfoHelper, securityConfig.getEnabledClientNames());
}
}
\ No newline at end of file
package eu.dariah.de.dariahsp.web;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.util.StringUtils;
......@@ -9,18 +11,17 @@ import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import org.springframework.web.servlet.support.RequestContextUtils;
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
*
* @author Tobias Gradl
*/
@RequiredArgsConstructor
public class AuthInfoHandlerInterceptor extends HandlerInterceptorAdapter {
private AuthInfoHelper authInfoHelper;
public AuthInfoHelper getAuthInfoHelper() { return authInfoHelper; }
public void setAuthInfoHelper(AuthInfoHelper authInfoHelper) { this.authInfoHelper = authInfoHelper; }
private final AuthInfoHelper authInfoHelper;
private final List<String> configuredAuthClientNames;
/*
* Adds the _sessionId and _auth request model attributes
......@@ -33,6 +34,7 @@ public class AuthInfoHandlerInterceptor extends HandlerInterceptorAdapter {
AuthPojo auth = authInfoHelper.getAuth();
String sessionId = authInfoHelper.getOrCreateSessionId();
modelAndView.addObject("_sessionId", sessionId);
modelAndView.addObject("_authClients", configuredAuthClientNames);
if (auth!=null && auth.isAuth()) {
modelAndView.addObject("_auth", auth);
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