Code Monkey home page Code Monkey logo

oauth-boot's Introduction

OAUTH-BOOT

spring-security ,spring-security-oauth2 ,string boot 学习


Update

更新说明

Current

  1. 授权码模式,密码模式,简化模式(未测试),客户端模式(未测试)
  2. JWT
  3. 自定义登录页面和授权页面
  4. 自定义异常处理
  5. 认证服务与资源服务分离

配置

boot:
  oauth:
    # token 存储方式,可选配置
    token-store-type: jwt #默认为 memory
    # token签名秘钥,可选配置,默认:OAUTHBOOT@IUY09&098#UIOKNJJ-YUIT.CLUB
    token-signing-key: 123qwe 
    # 登录处理url 可选配置
    login-process-url: /auth/authorize 

授权码模式

  1. 请求授权 http://ip:port/oauth/authorize?response_type=code&client_id=client&redirect_uri=http://localhost:9000&scope=select
  2. 如果没有登录会跳转到登录页面,登录后跳转到授权页面(是否会跳转到授权页面取决于是否将isAutoApprove字段的值 )
  3. 授权后得到一个授权码,拿着授权码即可申请token

密码模式

没有配置允许客户端表单登录的,将客户端id和密码base64编码放入请求头中,根据oauth2协议规定的密码模式正确填写参数即可申请token

依赖

框架/类库/数据库 版本号
java 11(Mac)/ 8(Win10)
spring-boot 2.0.5.RELEASE
spring-security 5.0.8.RELEASE
spring-security-oauth2-autoconfigure 2.0.6.RELEASE
mybatis-plus 3.0.4
数据库连接池(druid) 1.1.11
swagger-ui 2.9.2
hibernate-validator 6.0.13.Final
MySQL 5.7.22 MySQL Community Server
Redis 4.0.10

项目效果

  1. 自定义登录和授权页面效果图 自定义登录和授权页面效果图

建表语句在src/doc/table.sql中

相关的测试数据也在这个sql文件中,加密的密码统一为123qwe

请使用上述依赖所规定的版本

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.