springboot-security-oauth2
前端展示请配合 react-authority
在springboot-security 项目基础上,融合了部分oauth2的部分功能。
Oauth2-authorizedGrantType-client
在Spring security的基础上集成Oauth2的客户端认证模式,原权限部分不受影响。
基础权限 功能请访问springboot-security
![未登陆访问](https://raw.githubusercontent.com/ztgreat/springboot-security-oauth2/master/./Oauth2-authorizedGrantType-client/pics/%E6%9C%AA%E7%99%BB%E9%99%86%E8%AE%BF%E9%97%AE.png)
http://localhost:8080/oauth/token?grant_type=client_credentials&client_id=client_1&client_secret=123456
![获取Access_Token](https://raw.githubusercontent.com/ztgreat/springboot-security-oauth2/master/./Oauth2-authorizedGrantType-client/pics/%E8%8E%B7%E5%8F%96Access_Token.png)
![通过Access_Token访问](https://raw.githubusercontent.com/ztgreat/springboot-security-oauth2/master/./Oauth2-authorizedGrantType-client/pics/%E9%80%9A%E8%BF%87Access_Token%E8%AE%BF%E9%97%AE.png)
![登录](https://raw.githubusercontent.com/ztgreat/springboot-security-oauth2/master/./Oauth2-authorizedGrantType-client/pics/%E7%99%BB%E5%BD%95.png)
![登录后通过cookie访问](https://raw.githubusercontent.com/ztgreat/springboot-security-oauth2/master/./Oauth2-authorizedGrantType-client/pics/%E7%99%BB%E5%BD%95%E5%90%8E%E9%80%9A%E8%BF%87cookie%E8%AE%BF%E9%97%AE.png)
不要在同一台电脑上同时测试登录授权和通过Access_Token授权访问,否则授权信息会被覆盖。
Oauth2-authorizedGrantType-code
在Spring security的基础上集成Oauth2的授权码认证模式,原权限部分不受影响
基础权限 项目:springboot-security
配合前端展示:react-authority
http://localhost:8080/oauth/authorize?response_type=code&client_id=client_2&client_secret=123456&redirect_uri=http://baidu.com
![未登录获取授权码](https://raw.githubusercontent.com/ztgreat/springboot-security-oauth2/master/./Oauth2-authorizedGrantType-code/pics/%E6%9C%AA%E7%99%BB%E5%BD%95%E8%8E%B7%E5%8F%96%E6%8E%88%E6%9D%83%E7%A0%81.png)
账号:admin
密码:000000
![前端登录](https://raw.githubusercontent.com/ztgreat/springboot-security-oauth2/master/./Oauth2-authorizedGrantType-code/pics/%E5%89%8D%E7%AB%AF%E7%99%BB%E5%BD%95.png)
注意:这是前后端分离的前端页面
![授权页面](https://raw.githubusercontent.com/ztgreat/springboot-security-oauth2/master/./Oauth2-authorizedGrantType-code/pics/%E6%8E%88%E6%9D%83%E9%A1%B5%E9%9D%A2.png)
![获取授权码](https://raw.githubusercontent.com/ztgreat/springboot-security-oauth2/master/./Oauth2-authorizedGrantType-code/pics/%E8%8E%B7%E5%8F%96%E6%8E%88%E6%9D%83%E7%A0%81.png)
地址栏 code 便是授权码
http://localhost:8080/oauth/token?client_id=client_2&client_secret=123456&grant_type=authorization_code&redirect_uri=http://baidu.com&code=A3dv5E
![获取token](https://raw.githubusercontent.com/ztgreat/springboot-security-oauth2/master/./Oauth2-authorizedGrantType-code/pics/%E8%8E%B7%E5%8F%96token.png)
![获取数据](https://raw.githubusercontent.com/ztgreat/springboot-security-oauth2/master/./Oauth2-authorizedGrantType-code/pics/%E8%8E%B7%E5%8F%96%E6%95%B0%E6%8D%AE.png)
error 页面,以及授权页面都没有重写(实在不想写前端页面了),只是简单的把功能过了一遍,仅供参考,还有很多没有完善。
项目中都有响应的sql,方便测试