How to configure Shiro with Spring Boot

后端 未结 2 1111
遇见更好的自我
遇见更好的自我 2021-02-04 19:19

I have a Spring MVC web application that uses Shiro authentication using Spring configuration rather than a shiro.ini.

I want to transition to a Spring Boot application.

2条回答
  •  旧巷少年郎
    2021-02-04 19:44

    lenicliu gave great information, since I can't comment on his answer because I don't have enough reputation. I would like to add all the imports I had to make for his code to actually compile (maybe useful for noobies on Shiro, like me).

    import java.util.HashMap;
    import java.util.Map;
    import javax.servlet.Filter;
    import org.apache.shiro.realm.text.PropertiesRealm;
    import org.apache.shiro.spring.LifecycleBeanPostProcessor;
    import org.apache.shiro.web.filter.authc.AnonymousFilter;
    import org.apache.shiro.web.filter.authc.FormAuthenticationFilter;
    import org.apache.shiro.web.filter.authc.LogoutFilter;
    import org.apache.shiro.web.filter.authc.UserFilter;
    import org.apache.shiro.web.filter.authz.RolesAuthorizationFilter;
    import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
    import org.apache.shiro.web.mgt.WebSecurityManager;
    

提交回复
热议问题