On the same server deployment 2 springboot shiro project, log on to the first project, the second project will be redirected login page, the name of the sessionId set is not the same, but if don't work
@ Configuration
@ DependsOn (value="https://bbs.csdn.net/topics/applicationContextProvider")
Public class ShiroConfig {
@ Bean
Public ShiroFilterFactoryBean shirFilter (DefaultWebSecurityManager securityManager) {
ShiroFilterFactoryBean ShiroFilterFactoryBean=new ShiroFilterFactoryBean ();
ShiroFilterFactoryBean. SetLoginUrl ("/login ");
ShiroFilterFactoryBean. SetSuccessUrl ("/index ");
ShiroFilterFactoryBean. SetUnauthorizedUrl ("/403 ");
//database storage filter interface information
ApplicationContextProvider OpenApiSetService OpenApiSetService=(OpenApiSetService) getBean (" OpenApiSetService ");
Map FilterMap=openApiSetService. LoadFilterChainDefinitions ();
ShiroFilterFactoryBean. SetFilterChainDefinitionMap (filterMap);
ShiroFilterFactoryBean. SetSecurityManager (securityManager);
Return shiroFilterFactoryBean;
}
@ Bean
Public ShiroRealm ShiroRealm () {
ShiroRealm ShiroRealm=new ShiroRealm ();
ShiroRealm. Elegantly-named setName (MPM "");
ShiroRealm. SetCacheManager (cacheManager ());
Return shiroRealm;
}
@ Bean
Public FilterRegistrationBean securityFilterChain (AbstractShiroFilter securityFilter) {
FilterRegistrationBean registration=new FilterRegistrationBean (securityFilter);
Registration. Elegantly-named setName (" shiroFilter ");
Registration. SetDispatcherTypes (DispatcherType. REQUEST, DispatcherType. FORWARD);
Return the registration;
}
@ Bean
Public DefaultWebSecurityManager securityManager () {
DefaultWebSecurityManager securityManager=new DefaultWebSecurityManager ();
SecurityManager. SetRealm (shiroRealm ());
SecurityManager. SetCacheManager (cacheManager ());
SecurityManager. SetRememberMeManager (cookieRememberMeManager ());
Return the securityManager;
}
@ Bean
@ ConditionalOnMissingBean
Public DefaultAdvisorAutoProxyCreator DefaultAdvisorAutoProxyCreator () {
DefaultAdvisorAutoProxyCreator DefaultAdvisorAutoProxyCreator=new DefaultAdvisorAutoProxyCreator ();
DefaultAdvisorAutoProxyCreator. SetProxyTargetClass (true);
Return defaultAdvisorAutoProxyCreator;
}
@ Bean
Public AuthorizationAttributeSourceAdvisor AuthorizationAttributeSourceAdvisor (DefaultWebSecurityManager securityManager) {
AuthorizationAttributeSourceAdvisor AuthorizationAttributeSourceAdvisor
=new AuthorizationAttributeSourceAdvisor ();
authorizationAttributeSourceAdvisor.setSecurityManager(securityManager);
return authorizationAttributeSourceAdvisor;
}
@ Bean
Public EhCacheManager cacheManager () {
EhCacheManager EhCacheManager=new EhCacheManager ();
EhCacheManager. SetCacheManagerConfigFile (" classpath: ehcache. XML ");
Return ehCacheManager;
}
@ Bean (" sessionIdCookie ")
Public SimpleCookie SimpleCookie () {
SimpleCookie SimpleCookie=new SimpleCookie (" sid ");
SimpleCookie. SetHttpOnly (true);
SimpleCookie. SetMaxAge (604800);
Return simpleCookie;
}
@ Bean
Public CookieRememberMeManager CookieRememberMeManager () {
CookieRememberMeManager CookieRememberMeManager=new CookieRememberMeManager ();
CookieRememberMeManager. SetCipherKey (Base64. Decode (" 4 avvhmflus0kta3kprsdag=="));
CookieRememberMeManager. SetCookie (simpleCookie ());
Return cookieRememberMeManager;
}
}