# springboot-security **Repository Path**: freeager/springboot-security ## Basic Information - **Project Name**: springboot-security - **Description**: springboot-security demo - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2018-05-08 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README 一、一个类实现org.springframework.security.core.userdetails.UserDetails 主要是 getAuthorities方法。 改方法返回一个列表,框架利用该列表查看用户是否具有某个权限。 二、一个类实现org.springframework.security.core.userdetails.UserDetailsService,该方法如果验证用户通过 返回上一步的对象。如果不通过就抛出 org.springframework.security.core.userdetails.UsernameNotFoundException 异常。 三、一个类继承org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter 该类用@Configuration标示为配置类;重写方法configure实现配置;返回一个UserDetailsService Bean实体(用@Bean标示)。 四、Controller利用@PreAuthorize("hasRole('XXXX')")实现方法权限控制: 需要在上一步的类增加@EnableGlobalMethodSecurity(prePostEnabled=true),并且重写configureGlobal方法;另外重写 authenticationManager方法(对该方法还需@Bean标示)。 五、MyPermissionEvaluator实现hasPermission 五、注意UserJPA类,好像可以不写Dao就能实现ORM。 可能配置相关application.yml: jpa: properties: hibernate: show_sql: true format_sql: true 六、注意MVCConfig实现了jsp的映射。 七、注意Chapter17Application配置了错误页面(401、404、500、403)