spring-session | Spring Session provides an API and implementations | Application Framework library
kandi X-RAY | spring-session Summary
kandi X-RAY | spring-session Summary
Spring Session provides an API and implementations for managing a user’s session information, while also making it trivial to support clustered sessions without being tied to an application container specific solution. It also provides transparent integration with:.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Insert session attributes .
- Handles incoming messages .
- Write cookie value .
- Handle expiration time
- Perform the actual filtering .
- Saves a Hazelcast session .
- Creates the default cookie serializer .
- Builds a MapSession from the given map .
- Extract data from a ResultSet .
- Process the incoming session data .
spring-session Key Features
spring-session Examples and Code Snippets
public static void main(String[] args) {
SpringApplication.run(SpringSessionJdbcApplication.class, args);
}
public static void main(String[] args) {
SpringApplication.run(SpringSessionApplication.class, args);
}
Community Discussions
Trending Discussions on spring-session
QUESTION
I am using Spring Session Redis Data (configured with autoconfiguration, no customizations so far) which defaults to using FindByIndexNameSessionRepository
as the SessionRepository
implementation.
However, sometimes in Redis (after sessions have already expired but no logout is performed), key with prefix of spring:session:index:org.springframework.session.FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME:
persists with a TTL of -1, meaning Redis won't expire the key.
Why isn't Spring Session (Redis Data) cleaning this key up when sessions expire? I can't find mention in the documentation either.
I've stored attribute with the principal's name to the session as described in the documentation, but that doesn't solve this issue. See https://docs.spring.io/spring-session/reference/api.html#api-findbyindexnamesessionrepository for details.
Redis version used: 6.2.6 (docker image of bitnami/redis:6.2.6)
Relevant Dependencies:
- Spring Boot 2.6.2
- Spring Security 5.6.1
- Spring Session Core 2.5.0
- Spring Session Data Redis 2.5.0
- Spring Data Redis 2.6.0
The reason why I wouldn't want the index to persist is that if there are many users who have logged in at least once and having a key persisted to Redis which acts like index, then Redis would have to store data that may not be accessed for long time (or at all).
...ANSWER
Answered 2022-Feb-01 at 10:10This is a bug in Spring Session version 2.5.3 and prior.
If you update to Spring Session 2.5.4 or any 2.6.x, the issue is fixed.
QUESTION
I'm trying to implement SessionCreationPolicy.ALWAYS for the /testMVCController/** endpoint and SessionCreationPolicy.STATELESS for rest of endpoints (/**).
Expected scenario:
When accessing to /testMVCController/displayUsers the user logs in once and the log I have implemented in UserDetailsService logs the authorities associated to that user. After that, all the requests to /testMVCController/displayUsers or other URL under /testMVCController/** will not log the authorities again because the session creation policy is always and the user is already logged in.
This works when I don't specify the 2nd security configuration (X509ClientSessionCreationPolicyStateless) but when I add it, all the requests become session stateless.
It is not working with the current security configuration because after I log in with my client certificate, at any request executed under /testMVCController/** endpoint (e.g. /testMVCController/displayUsers), the authenticationUserDetailsService is consulted and the list of authorities is logged for each file request the browser makes (.js file, .css files, ...), even after the initial login.
So, if there are 3 requests (/testMVCController/displayUsers, displayUsers.js, displayUsers.css) the list of authorities log present in authenticationUserDetailsService is logged 3 times.
I configured SecurityConfiguration as shown below but it is not working:
...ANSWER
Answered 2022-Jan-21 at 16:47I was missing some details on my configuration. I was catching all the requests to /testMVCController/**
and that was working, but in addition to catch the requests to any endpoint of the type /testMVCController/**
(e.g.: /testMVCController/usersList), I also have to catch the requests that these pages make to get their scripts (.js files, .css files, .png files).
What was happening was: the request to /testMVCController/usersList
), was configured with SessionCreationPolicy.ALWAYS
, but the subsequent requests such as usersList.js
, usersList.css
, etc were configured with SessionCreationPolicy.STATELESS
, and in these cases the X509CustomUserDetailsService
was always consulted.
Example:
GET request to /testMVCController/usersList
works, but there also requests in this usersList page to usersList.js
, usersList.css
, etc.
So, once I included these resource paths in the antMatchers all worked perfectly.
QUESTION
As you can see, I have a simple default test. For some unknown reason for me, it does not load the application context, if I remove @SpringBootTest annotation everything works, but without it I cannot do bean injection, so I need this annotation.
test
...ANSWER
Answered 2022-Jan-07 at 10:36It seems that you have flyway dependency in your pom. When using @SpringbootTest, It will initialize the whole application context. According to the Springboot Autoconfigure mechanism, the application detects the Flyway module and tries to create a bean named flyway:
Error creating bean with name 'flyway'
And then when constructing the flyway bean, the flyway Factory needs a datasource bean.
QUESTION
I'm storing sessions in Redis using spring-boot and spring-session-redis.
I have the following use-case.
When a user lands at /admin
, Spring Boot generates an anonymous session for such user and redirects him to the login page.
When a user passes authentication process, RedisIndexedSessionRepository
persists the session identifier in the index under session:index:org.springframework.session.FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME:null
key, and this index never cleanup.
I believe this leads to a memory leak. What should I do to avoid such behavior?
...ANSWER
Answered 2021-Dec-28 at 14:34This is a bug: https://github.com/spring-projects/spring-session/issues/1987
I provided an explanation and fix in the PR: https://github.com/spring-projects/spring-session/pull/1988
QUESTION
I've setup a simple Spring Security app and enabled web security but can't go to the default login page, it keeps raising Error 404. How to resolve this?
Here're my configurations.
application.properties
...ANSWER
Answered 2021-Dec-20 at 10:50spring-security auto-configures a /login
page ("view and controller"), but if we want it to work/serve, we must not:
QUESTION
I am trying to use LDAP for spring authentication and authorization. Even though I am successfully authenticating users, I couldn't get roles from LDAP yet.
...ANSWER
Answered 2021-Nov-24 at 12:43There is an issue with the second condition in the group search filter, it should be
(uniqueMember={0})
(thecn=
is part of the substituted dn). Also, the(cn=*)
is not necessary becausecn
is a mandatory attribute for allgroupOfUniqueNames
entries.Since the context source url contains a base DN (
dc=example,dc=org
) used for searching and authenticating users, you don't need to set this part in the user/group search parameters (which are relative to that base).userSearchFilter()
is not necessary when usinguserDnPatterns
(@see this post)
QUESTION
I am setting up a Spring Boot app that uses:
- OAuth2 Login
- Spring Session for authentication
- Redis for the session storage
Using this spring boot application.yaml to enable redis:
...ANSWER
Answered 2021-Oct-24 at 23:59So, it turns out that the culprit is the HttpSessionEventPublisher
. The sessionRepository (which we can see at the top of the stack trace complaining about the circular dependency) for Redis (RedisHttpSessionConfiguration
) extends SpringHttpSessionConfiguration
which injects a list of all HttpSessionListener
beans registered, which includes the HttpSessionEventPublisher
Put that in its own Config
class:
QUESTION
I am trying to create a registration page. Even though I am submitting the form, the data isn't being inserted in the postgresql user_table. Logging in works if I insert the data into the table manually. I'm unsure what I'm doing wrong.
register.html
...ANSWER
Answered 2021-Sep-27 at 23:56the annotation @Repository is missing in the interface UserRepository, also you should autowire this dependency by adding the annotation @Autowired in the field of dependency declaration in class TwitterController
QUESTION
my pom.xml file:
...ANSWER
Answered 2021-Sep-15 at 03:45You have told Maven that your project is only a POM artifact (which doesn't have code or need jars):
QUESTION
I've got a weird problem which I can't really understand.
I've a got a code to upload a file to AWS S3 bucket using AmazonS3 client. I've got a try-catch block where I catch any exception and in catch block I throw my defined exception which is handled by controller method @ExceptionHandler and should return thymeleaf template errorUpload.html.
...ANSWER
Answered 2021-Aug-23 at 15:12The error is indeed strange. It seems to me that you are using the old version of AWS SDK for Java (https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk-s3), so I would suggest you updating it to the new version (https://mvnrepository.com/artifact/software.amazon.awssdk/s3) and check if the issue persists.
For more and detailed information check AWS documentation on how to migrate https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/migration.html.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install spring-session
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page