2020-07-09 18:05:11 +05:30
|
|
|
package com.baeldung.intro;
|
2019-10-31 20:43:47 -05:00
|
|
|
|
|
|
|
import org.apache.shiro.realm.Realm;
|
|
|
|
import org.apache.shiro.spring.web.config.DefaultShiroFilterChainDefinition;
|
|
|
|
import org.apache.shiro.spring.web.config.ShiroFilterChainDefinition;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.springframework.boot.SpringApplication;
|
|
|
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
2020-07-09 18:05:11 +05:30
|
|
|
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
|
2019-10-31 20:43:47 -05:00
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Created by smatt on 21/08/2017.
|
|
|
|
*/
|
2020-07-09 18:05:11 +05:30
|
|
|
@SpringBootApplication(exclude = SecurityAutoConfiguration.class)
|
2019-10-31 20:43:47 -05:00
|
|
|
public class ShiroSpringApplication {
|
|
|
|
|
|
|
|
private static final transient Logger log = LoggerFactory.getLogger(ShiroSpringApplication.class);
|
|
|
|
|
|
|
|
public static void main(String... args) {
|
|
|
|
SpringApplication.run(ShiroSpringApplication.class, args);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
public Realm realm() {
|
|
|
|
return new MyCustomRealm();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Bean
|
2020-07-09 18:05:11 +05:30
|
|
|
public ShiroFilterChainDefinition filterChainDefinition() {
|
2019-10-31 20:43:47 -05:00
|
|
|
DefaultShiroFilterChainDefinition filter
|
|
|
|
= new DefaultShiroFilterChainDefinition();
|
|
|
|
|
|
|
|
filter.addPathDefinition("/secure", "authc");
|
|
|
|
filter.addPathDefinition("/**", "anon");
|
|
|
|
|
|
|
|
return filter;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|