0%

web存储

使用web存储,数据可以保存在客户端,以键值对存在,只允许该网页访问使用

localStorage

用于长久保存整个网站的数据,保存的数据没有过期时间,直到手动去除

1
2
3
4
5
6
7
8
9
10
// 保存数据
localStorage.setItem(key,value)
// 读取数据
localStorage.getItem(key)
// 删除单个数据
localStorage.removeItem(key)
// 删除所有数据
localStorage.clear()
// 得到某个索引的key
localStorage.key(index)
阅读全文 »

超链接定位

1
2
3
4
5
6
7
<!-- 跳转到id为tips的链接处
如果锚点与超链接不在一个文件内,需要加上锚所在文件的名称 如report.html#tips
-->
<a href="#tips">链接</a>

<!-- 相当于一个锚点 -->
<a id="tips">定位</a>

Nginx配置状态检查地址

1
2
3
location /nginx_status {
stub_status on;
}

springSecurity注解使用

在使用springboot的时候,大家更习惯于使用注解来进行配置,那么springSecurity注解怎么使用呢

首先开启注解

1
2
3
4
@EnableGlobalMethodSecurity(// Spring Security 开启注解
securedEnabled=true, // 开启@Secured注解,会创建切点,代理@Secured注解的方法
prePostEnabled = true // 开启@PreAuthorize和@PostAuthorize注解
)
阅读全文 »

springSecurity流程

认证流程

  • 登录请求进入UsernamePasswordAuthenticationFilter,父类是AbstractAuthenticationProcessingFilter,执行AbstractAuthenticationProcessingFilter的doFilter方法

    1
    authResult = attemptAuthentication(request, response);
  • 确认一下该请求是否需要认证,如果需要认证且此时还没有进行认证,则尝试进行认证,调用UsernamePasswordAuthenticationFilter的attemptAuthentication方法,将从请求中获取的用户名和密码封装成UsernamePasswordAuthenticationToken对象(认证状态为未认证)

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken(
    username, password);

    public UsernamePasswordAuthenticationToken(Object principal, Object credentials) {
    super(null);
    this.principal = principal;
    this.credentials = credentials;
    // 设置为未认证
    setAuthenticated(false);
    }
  • 通过AuthenticationManager(实现类是ProviderManager)委托AuthenticationProvider(实现类是DaoAuthenticationProvider)关联UserDetailsService进行认证过程

阅读全文 »