Skip to content

Commit

Permalink
solve shiro warning in springboot (#67)
Browse files Browse the repository at this point in the history
Co-authored-by: LiuYe <[email protected]>
  • Loading branch information
UncleLiuYe and LiuYe authored Jun 21, 2024
1 parent 64b1cf4 commit 95d5061
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public String handleException(AuthorizationException e, Model model) {
}

@Bean
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public Realm realm() {
TextConfigurationRealm realm = new TextConfigurationRealm();
realm.setUserDefinitions("joe.coder=password,user\n" + "jill.coder=password,admin");
Expand All @@ -83,6 +84,7 @@ public Realm realm() {
}

@Bean
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public ShiroFilterChainDefinition shiroFilterChainDefinition() {
DefaultShiroFilterChainDefinition chainDefinition = new DefaultShiroFilterChainDefinition();
// need to accept POSTs from the login form
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator() {

@Bean
@ConditionalOnMissingBean
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Override
public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(SecurityManager securityManager) {
return super.authorizationAttributeSourceAdvisor(securityManager);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@
import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
import org.apache.shiro.spring.web.config.AbstractShiroWebFilterConfiguration;
import org.apache.shiro.web.servlet.AbstractShiroFilter;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Role;

import javax.servlet.DispatcherType;
import java.util.List;
Expand All @@ -37,6 +39,7 @@
@Configuration
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
@ConditionalOnProperty(name = "shiro.web.enabled", matchIfMissing = true)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public class ShiroWebFilterConfiguration extends AbstractShiroWebFilterConfiguration {

/**
Expand Down Expand Up @@ -70,6 +73,7 @@ protected FilterRegistrationBean<AbstractShiroFilter> filterShiroFilterRegistrat
}

@Bean(name = "globalFilters")
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@ConditionalOnMissingBean
protected List<String> globalFilters() {
return super.globalFilters();
Expand Down

0 comments on commit 95d5061

Please sign in to comment.