Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

114
Views
Using apache Shiro with Spring MVC non xml project

I have a project in which i am using Spring mvc 4 and i need to include there apache shiro security. I've tried to search over the web for a solution for my problem but didn't managed to fins something. Although there is a guide at Shiro's web site, but this example is only for xml configured Spring project, and my project doesn't contain any xml at all, and when i am trying to configure Shiro with annotation only it fails. When i run this project i have an access to all of my end points, and non of them is being restricted by Shiro. I guess that my configuration is wrong but i am unable to figure out which part of it is wrong. I am not allowed to use Spring boot (i know that there is examples for that). here is my configuration class:

@Configuration
@EnableWebMvc
@ComponentScan(basePackages = "com.myproject.menu")
public class AppConfiguration extends WebMvcConfigurerAdapter{


@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
    registry.addResourceHandler("/**").addResourceLocations("/");
}

@Bean(name="shiroFilter")
public ShiroFilterFactoryBean shiroFilter (){
    ShiroFilterFactoryBean shiroFilter = new ShiroFilterFactoryBean();
    shiroFilter.setLoginUrl("/MenuTest/login");
    shiroFilter.setFilterChainDefinitions("/MenuTest/init=anon");
    shiroFilter.setFilterChainDefinitions("/MenuTest/**=authc");
    shiroFilter.setSecurityManager(realm());
    return shiroFilter;
}

private DefaultWebSecurityManager realm(){
    DefaultWebSecurityManager realm = new DefaultWebSecurityManager();
    return realm;
}
}

Thx in advance!

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Take a look at the 1.4.0 (RC2) release. There is updated Spring and Spring-Boot support.

And examples in the source tree: https://github.com/apache/shiro/tree/master/samples/spring-mvc

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!