Code Monkey home page Code Monkey logo

spring-security-login's Introduction

SpringBoot整合SpringSecurity简单实现登入登出从零搭建

  1. 这是SpringSecurity实现登录和登出的一个简单示例,基于 Spring Boot 1.5.6

    基本实现 : 用户信息存储在数据库中,登陆时从数据库中查询匹配用户信息。用户登入登出,默认session失效重新登陆。

    avatar

    点击登录,登录失败会留在当前页面重新登录,成功则进入index.html,登录如果成功,可以看到后台打印登录成功的日志:

    avatar

    页面进入index.html:

    avatar

    点击注销 ,则回重新跳转到login.html,后台也会打印登出成功的日志 :

    avatar

  2. 在你运行该应用之前 :

    1. 请修改你自己的数据库配置: /application.yml

    2. 请为这个例子准备一个用户表: user.sql

    3. 请在数据库中插入一条包含测试用户名和密码(密码是加密的)的用户记录,加密的密码请参考测试类TestEncoder :

           @Test
           public void encoder() {
               String password = "admin";
               BCryptPasswordEncoder encoder = new BCryptPasswordEncoder(4);
               String enPassword = encoder.encode(password);
               System.out.println(enPassword);
           }
    4. 访问 : localhost:8083/login

  3. 本例博客说明链接 : https://www.cnblogs.com/ealenxie/p/9293768.html

spring-security-login's People

Contributors

ealenxie avatar

Watchers

James Cloos 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.