Skip to content

Is it possible change the access level of RedisSession in class RedisIndexedSessionRepository to public #2586

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
herodotus-ecosystem opened this issue Oct 29, 2023 · 1 comment
Assignees
Labels
status: duplicate A duplicate of another issue type: bug A general bug

Comments

@herodotus-ecosystem
Copy link

herodotus-ecosystem commented Oct 29, 2023

I want to use Spring Session in the Spring Security and Spring Authorization Server environments. Currently, I achieve this by configuring the following beans

@Bean
@ConditionalOnMissingBean
public <S extends Session> SessionRegistry sessionRegistry(FindByIndexNameSessionRepository<S> sessionRepository) {
	SpringSessionBackedSessionRegistry<S> springSessionBackedSessionRegistry = new SpringSessionBackedSessionRegistry<>(sessionRepository);
	log.trace("[Herodotus] |- Bean [Spring Session Backed Session Registry] Auto Configure.");
	return springSessionBackedSessionRegistry;
}

This code can make Spring Security run normally without any issues.

My problem is that the above code has some flaws, which are in the idea, as shown in the following figure, Prompt error "No beans of 'FindByIndexNameSessionRepository' type found"

image

  • From the perspective of class inheritance, there is no problem with this approach now, and the code can also run normally.
  • However, from the configuration perspective of Spring beans, there is indeed a small issue, as only RedisIndexedSessionRepository (in org.springframework.session.data.redis.config.annotation.web.http.RedisIndexedHttpSessionConfiguration) beans were injected into the Spring session without FindByIndexNameSessionRepository beans, so the IDE prompts that FindByIndexNameSessionRepository beans cannot be found, which is also correct.

if change the access level of RedisSession in class RedisIndexedSessionRepository to public, can turn the code into the following way

@Bean
@ConditionalOnMissingBean
public SessionRegistry sessionRegistry(RedisIndexedSessionRepository sessionRepository) {
	SpringSessionBackedSessionRegistry<RedisIndexedSessionRepository.RedisSession> springSessionBackedSessionRegistry = new SpringSessionBackedSessionRegistry<>(sessionRepository);
	log.trace("[Herodotus] |- Bean [Spring Session Backed Session Registry] Auto Configure.");
	return springSessionBackedSessionRegistry;
}

This seems more reasonable, and there will be no error prompts in the IDE.

However, RedisSession is currently inaccessible in RedisIndexedSessionRepository, so it cannot be configured using the above code.

@herodotus-ecosystem herodotus-ecosystem added status: waiting-for-triage An issue we've not yet triaged type: bug A general bug labels Oct 29, 2023
@marcusdacoregio marcusdacoregio self-assigned this Oct 30, 2023
@marcusdacoregio marcusdacoregio removed the status: waiting-for-triage An issue we've not yet triaged label Oct 30, 2023
@marcusdacoregio
Copy link
Contributor

Hi, @herodotus-cloud. This is a duplicate of #2258.

Since there isn't a bug with your approach, I'll close this to keep the discussion on the other issue.

@marcusdacoregio marcusdacoregio added the status: duplicate A duplicate of another issue label Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants