spring-session

Externalizing Session State for a Spring Boot Application Using Spring-Session

只愿长相守 提交于 2019-12-07 21:32:58
Spring-session is a very cool new project that aims to provide a simpler way of managing sessions in Java based web applications. One of the features that I explored with spring-session recently was the way it supports externalizing session state without needing to fiddle with the internals of specific web containers like Tomcat or Jetty. To test spring-session I have used a shopping cart type application(available here) which makes heavy use of session by keeping the items added to the cart as a session attribute, as can be seen from these screenshots: Consider first a scenario without Spring

Correct @EnableRedisHttpSession configuration with Redis Sentinel

白昼怎懂夜的黑 提交于 2019-12-07 21:00:33
问题 I have a Spring Cloud based application with multiple backend Spring-Boot servers. The servers are all sharing their session with a Redis server via @EnableRedisHttpSession. I'm trying to configure the application with master-slave configuration and Redis Sentinel. My setup is 1 master, two slaves, and 3 sentinels. I keep getting issues with the environment. At first, I was getting an error saying that my slave it READONLY. So I had to set all slaves to READWRITE. Then, I still got this error

Best way to propagate credentials between micro services using spring-session

£可爱£侵袭症+ 提交于 2019-12-07 08:45:49
问题 We are using an architecture very similar to the one described in this great guide on spring.io. Our gateway handles authentication, and sessions are stored in Redis using spring-session. Endpoints of our micro services are secured and also use spring-session. In a micro service I need to call an endpoint of another micro service. I get the URL easily through the discovery client, but I need to provide credentials and I'm not sure of the best way to achieve that. I am thinking about getting

Correct @EnableRedisHttpSession configuration with Redis Sentinel

安稳与你 提交于 2019-12-06 06:15:22
I have a Spring Cloud based application with multiple backend Spring-Boot servers. The servers are all sharing their session with a Redis server via @EnableRedisHttpSession. I'm trying to configure the application with master-slave configuration and Redis Sentinel. My setup is 1 master, two slaves, and 3 sentinels. I keep getting issues with the environment. At first, I was getting an error saying that my slave it READONLY. So I had to set all slaves to READWRITE. Then, I still got this error. Turns out that when a slave was promoted to master, the old master was turned into slave, with the

Best way to propagate credentials between micro services using spring-session

▼魔方 西西 提交于 2019-12-05 14:59:48
We are using an architecture very similar to the one described in this great guide on spring.io . Our gateway handles authentication, and sessions are stored in Redis using spring-session. Endpoints of our micro services are secured and also use spring-session. In a micro service I need to call an endpoint of another micro service. I get the URL easily through the discovery client, but I need to provide credentials and I'm not sure of the best way to achieve that. I am thinking about getting the SESSION cookie from the HttpRequest, store it in some kind of thread local variables or request

Spring session with redis - how to mock it in integration tests?

梦想的初衷 提交于 2019-12-04 23:52:10
问题 So, Im using spring session in my project. How to write integration tests in project using it? Should I mock something for spring session internals? Or any reasonable way to use embedded redis? I saw there was some @EnableEmbeddedRedis annotation in past, but seems it was removed: https://github.com/spring-projects/spring-session/issues/248 //edit Ive tried to pass MockHttpSession to mockMvc.perform(post("/register").session(mockHttpSession) but spring tries and fails to connect to redis

Spring session + Spring web socket. Send message to specific client based on session id

↘锁芯ラ 提交于 2019-12-04 04:16:40
问题 I have followed Quetion1 and Quetion2 from stack overflow to send messages to specific client, based on its sessionId but could not find success. Below is my sample RestController class @RestController public class SpringSessionTestApi { @Autowired public SimpMessageSendingOperations messagingTemplate; @MessageMapping("/messages") public void greeting(HelloMessage message, SimpMessageHeaderAccessor headerAccessor) throws Exception { String sessionId = (String) headerAccessor

How does the session scope of a bean work in a Spring MVC application?

允我心安 提交于 2019-12-03 21:08:12
I am pretty new in Spring MVC and I have a doubt about the session scope of a bean. Into a project I have a Cart bean, this one: @Component @Scope(value=WebApplicationContext.SCOPE_SESSION, proxyMode = ScopedProxyMode.TARGET_CLASS) public class Cart { private Map<Product, Integer> contents = new HashMap<>(); public Map<Product, Integer> getContents() { return contents; } public Set<Product> getProducts() { return contents.keySet(); } public void addProduct(Product product, int count) { if (contents.containsKey(product)) { contents.put(product, contents.get(product) + count); } else { contents

Spring security OAuth2 authentication and form login in one app

丶灬走出姿态 提交于 2019-12-03 16:32:58
Is it possible to combine authoryzation and authentication by login basic and by oauth2 in one application? My project is based on jhipster project with simple spring security session login, now i need add oauth2 security for mobile app and it's look like it is not possible. Now i have situation when work one of them, oauth2 ok if WebSecurityConfigurerAdapter had bigger order number than ResourceServerConfiguration. That's mean if oauth security filter is first. I read a lot in stackoverflow and try many solution like: Spring security oauth2 and form login configuration for me thats one don't

Spring session with redis - how to mock it in integration tests?

家住魔仙堡 提交于 2019-12-03 15:51:49
So, Im using spring session in my project. How to write integration tests in project using it? Should I mock something for spring session internals? Or any reasonable way to use embedded redis? I saw there was some @EnableEmbeddedRedis annotation in past, but seems it was removed: https://github.com/spring-projects/spring-session/issues/248 //edit Ive tried to pass MockHttpSession to mockMvc.perform(post("/register").session(mockHttpSession) but spring tries and fails to connect to redis anyway. Dmitriy Kosolobov You can create your own connectionfactory and the redisserializer. Then spring