8000 GitHub - HugoY1996/Oauth2
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

HugoY1996/Oauth2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Oauth2 客户端、认证服务、资源服务整合实例

集成协议

  1. password
  2. client_credentials
  3. authorization_code

创建数据库

  • 本实例使用的数据库是postgresql
  • 配置数据库
spring:
  datasource:
    url: jdbc:postgresql://localhost:5432/oauth2
    driver-class-name: org.postgresql.Driver
    username: postgres
    password: 123456
  • 导入数据,使用脚本文件 Oauth24Springboot/oauth2.sql、Oauth24Springboot/security.sql
  • 启动程序
  1. com.bestaone.springboot.oauth2.client.Application
  2. com.bestaone.springboot.oauth2.aurhserver.Application
  3. com.bestaone.springboot.oauth2.resource.Application

模块介绍

  • clien模块 验证authorization_code的客户端代码演示

  • auth-server 提供认证的功能

  • resource-server 资源服务,需要携带授权凭证才可访问

验证

authorization_code 认证流程

  • 将三个项目都启动
  • 访问 http://localhost:8080
  • 这里实现了用户名/密码登录,手机号码/短信验证码登录,均需要填写图形验证码
  • 首页是client项目的,登录认证是在auth server,登录后获取的Profile数据是从resource server中获取的

注意:如果授权环节不出现,可以清除下数据库的数据

password 认证流程

client_credentials 认证流程

authorization_code 认证流程(废弃,暂时不删除,有可能有参考价值)

验证scope

截图

  • 客户端首页
    image

  • 跳转到认证服务器登录
    image

  • 登录验证后询问授权
    image

  • 认证服务器认证授权成功后重定向到客户端
    image

  • password认证协议
    image

  • client_credentials认证协议
    image

  • 使用token访问api
    image

问题

  • 我将spring-boot升级到了2.0.0.M3版本,当升级到2.0.0.M7版本时出现问题,目前暂时没有排查 (已修复)
  • 将认证服务和资源服务合并在一起的时候,验证authorization_code功能时,登录时报错“不支持 POST”,初步定为是 auth server 的SecurityConfig的HttpSecurity http未设置好

参考

http://rensanning.iteye.com/blog/2386766

About

No description, website, or topics provided.

Resources

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0