|
1 |
package eu.dnetlib.uoaauthorizationlibrary.security;
|
|
2 |
|
|
3 |
import org.apache.log4j.Logger;
|
|
4 |
import org.springframework.beans.factory.annotation.Value;
|
|
5 |
import org.springframework.context.annotation.Bean;
|
|
6 |
import org.springframework.context.annotation.Configuration;
|
|
7 |
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
|
8 |
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
|
|
9 |
import org.springframework.session.web.http.CookieSerializer;
|
|
10 |
import org.springframework.session.web.http.DefaultCookieSerializer;
|
|
11 |
|
|
12 |
@Configuration
|
|
13 |
@EnableRedisHttpSession
|
|
14 |
public class RedisConfig {
|
|
15 |
|
|
16 |
private static final Logger logger = Logger.getLogger(RedisConfig.class);
|
|
17 |
|
|
18 |
@Value("${redis.host:localhost}")
|
|
19 |
private String host;
|
|
20 |
|
|
21 |
@Value("${redis.port:6379}")
|
|
22 |
private String port;
|
|
23 |
|
|
24 |
@Value("${redis.password:#{null}}")
|
|
25 |
private String password;
|
|
26 |
|
|
27 |
@Value("${webbapp.front.domain:.openaire.eu}")
|
|
28 |
private String domain;
|
|
29 |
|
|
30 |
@Bean
|
|
31 |
public LettuceConnectionFactory connectionFactory() {
|
|
32 |
logger.info(String.format("Redis connection listens to %s:%s ",host,port));
|
|
33 |
LettuceConnectionFactory factory = new LettuceConnectionFactory(host,Integer.parseInt(port));
|
|
34 |
if(password != null) factory.setPassword(password);
|
|
35 |
return factory;
|
|
36 |
}
|
|
37 |
|
|
38 |
@Bean
|
|
39 |
public CookieSerializer cookieSerializer() {
|
|
40 |
logger.info("Cookie Serializer: Domain is "+domain);
|
|
41 |
DefaultCookieSerializer serializer = new DefaultCookieSerializer();
|
|
42 |
serializer.setCookieName("openAIRESession"); // <1>
|
|
43 |
serializer.setCookiePath("/"); // <2>
|
|
44 |
// serializer.setDomainNamePattern(""); //with value "" set's the domain of the service e.g scoobydoo.di.uoa.gr
|
|
45 |
serializer.setDomainName(domain);
|
|
46 |
return serializer;
|
|
47 |
}
|
|
48 |
}
|
[AuthorizationLibrary | Trunk]: Add Entry point class to get 401 if user is not loggedin