Git Product home page Git Product logo

springsecuritydemo's Introduction

springSecurityDemo

1.实现从数据库查询用户信息

  1. 自定义UserDetailsServiceImpl实现UserDetailsService
  2. usermapper 查询用户
  3. 返回一个loginUser(继承UserDetails)

2.自定义登录接口(jwt)

  1. 使用AuthenticationManager的authenticate方法来进行用户认证
  2. 认证获取用户信息-以id生成jwt返回,并且将用户信息存入redis

3.认证过滤器

  1. 自定义接口继承OncePerRequestFilter
  2. 读取token 解析token 取用户信息 封装成Authentication存入SecurityContextHolder
  3. 认证通过放行

4.退出登录

  1. 读取SecurityContextHolder中的用户信息
  2. 删除redis中的用户
  3. 返回结果

springsecuritydemo's People

Contributors

zecss avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.