我们常见的几个功能:

  1. 注册后直接登录,并且remember-me
    这种在网上找到很多注册后登录的,但是remember-me没有。
    其实解决方案还是看源码比较方便。
    a. 装载authenticationManager

    @Autowired

    private AuthenticationManager authenticationManager;

    b. 装载rememberMeServices,注意一定要AbstractRememberMeServices,因为它能修改alwaysremember属性
    @Autowired

    private AbstractRememberMeServices rememberMeServices;

    c.  自动登录并remember

UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken(

user.getMobile(), password);

Authentication authentication = authenticationManager.authenticate(authRequest);

rememberMeServices.setAlwaysRemember(true);

rememberMeServices.loginSuccess(request, response, authentication);

2. @PreAuthorize不work的情况

不是网上搜的加上 pre-post-annotations="enabled"就完事,一定要加在你的应用程序配置里,而不是spring-security.xml里

如果不太理解是哪个文件,那么<annotation-driven>在哪个文件,你就加在哪个文件

spring securiy使用总结的更多相关文章

  1. 更加优雅地配置Spring Securiy(使用Java配置和注解)

    Spring Security 借助一系列Servlet Filter 来提供安全性功能,但是借助Spring的小技巧,我们只需要配置一个Filer就可以了,DelegatingFilterProxy ...

  2. 常用加密算法简单整理以及spring securiy使用bcrypt加密

    一.哈希加密 1.md5加密 Message Digest Algorithm MD5(中文名为消息摘要算法第五版) https://baike.baidu.com/item/MD5/212708?f ...

  3. Spring Security配置

    更加优雅地配置Spring Securiy(使用Java配置和注解):https://www.cnblogs.com/xxzhuang/p/5960001.html 采用注解方式实现security: ...

  4. spring security源码分析心得

    看了半天的文档及源码,终于理出了spring-security的一些总体思路,spring security主要分认证(authentication)和授权(authority). 1.认证authe ...

  5. Spring Boot:整合Spring Security

    综合概述 Spring Security 是 Spring 社区的一个顶级项目,也是 Spring Boot 官方推荐使用的安全框架.除了常规的认证(Authentication)和授权(Author ...

  6. Spring Securtiy 认证流程(源码分析)

    当用 Spring Security 框架进行认证时,你可能会遇到这样的问题: 你输入的用户名或密码不管是空还是错误,它的错误信息都是 Bad credentials. 那么如果你想根据不同的情况给出 ...

  7. Spring Boot Actuator:健康检查、审计、统计和监控(转)

    Spring Boot Actuator可以帮助你监控和管理Spring Boot应用,比如健康检查.审计.统计和HTTP追踪等.所有的这些特性可以通过JMX或者HTTP endpoints来获得. ...

  8. 02 spring security 自定义用户认证流程

    1. 自定义登录页面 (1)首先在static目录下面创建login.html       注意: springboot项目默认可以访问resources/resources, resources/s ...

  9. Spring Boot Actuator:健康检查、审计、统计和监控

    Spring Boot Actuator可以帮助你监控和管理Spring Boot应用,比如健康检查.审计.统计和HTTP追踪等.所有的这些特性可以通过JMX或者HTTP endpoints来获得. ...

随机推荐

  1. Major and minor numbers

    The major nuber is the driver associated with the device, while the minor number is used by the kern ...

  2. IIS7或IIS7.5 ISAPI和CGI限制找不到的问题记录

    弄了一下午,才找到,选择最上面的节点,如下图,记录备用

  3. 3.通过js代码设置css样式

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  4. 转 delphi SelText,GetText,SetText用法

    转自:http://blog.163.com/wll_009/blog/static/1173731172009102452632968/ 这几个都跟选区有关的,就是选中一串字符串,选中的会变蓝色Se ...

  5. 简单学习JavaScript面向对象编程

    JavaScript是一种弱类型语言.有一种原型机制. 1.创建一个空对象:var bill = {}; 给这个对象添加属性和方法: bill.name = "Bill E Goat&quo ...

  6. stl 生产全排列 next_permutation

    #include<stdio.h>#include<algorithm>using namespace std;int main(){ int n,p[10]; scanf(& ...

  7. SpringMVc上传excel或csv文件

    1.JSP页面代码 <form enctype=""multipart/form-data" method="post"> <inp ...

  8. C# html转mht

    项目中引入cdosys.dll组件,位置:  C:\Windows\System32\cdosys.dll CDO.ADODB 这些类都来自于cdosys.dll组件 /// <summary& ...

  9. 虚拟机 centos 7 nginx安装

    1下载vmware 12,并安装.百度即可 2下载centos 7,将其安装在vmware 12中.百度即可,无复杂设置. 3设置vmware 中centos7能上网: a.右键计算机->管理- ...

  10. 十六、oracle 索引

    一.管理索引-原理介绍索引是用于加速数据存取的数据对象.合理的使用索引可以大大降低i/o次数,从而提高数据访问性能.索引有很多种我们主要介绍常用的几种:为什么添加了索引后,会加快查询速度呢? 二.创建 ...