Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

117
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda