从实战的角度谈微服务(七):对于spring security的使用
gcs-spring
介绍
代码地址:(https://gitee.com/lovecheng/gcs-spring.git)
spring框架学习
获取令牌
方式一:客户端模式(client_credentials)
接口:
POST localhost:9001/oauth/token
参数:
client_id:webapp
client_secret:123456
grant_type:client_credentials
返回结果
{
"access_token": "9f985b2c-02a3-4222-b4fd-306f27412134",
"token_type": "bearer",
"refresh_token": "30ad49b0-6255-4fed-a1c8-93b1026bf53b",
"expires_in": 7200,
"scope": "all"
}
方式二:密码模式(password)
接口:
POST localhost:9001/oauth/token
参数:
client_id:webapp
client_secret:123456
grant_type:password
username:root
password:123456
方式三:简化模式(implicit)
浏览器访问
方式四:授权码模式(authorization_code)
获取code
获取令牌
接口:
POST localhost:9001/oauth/token
参数:
client_id:webapp
client_secret:123456
grant_type:authorization_code
code:cd5ybn
redirect_uri:http://www.baidu.com
方式五: 刷新令牌
接口:
POST localhost:9001/oauth/token
参数:
client_id:webapp
client_secret:123456
grant_type:refresh_token
refresh_token:30ad49b0-6255-4fed-a1c8-93b1026bf53b
令牌验证
接口
POST localhost:9001/oauth/token
参数
token:9f985b2c-02a3-4222-b4fd-306f27412134
结果
{
"aud": [
"order"
],
"user_name": "root",
"scope": [
"all"
],
"active": true,
"exp": 1645097273,
"authorities": [
"ROLE_vip2",
"ROLE_vip3",
"ROLE_vip1"
],
"client_id": "webapp"
}
本篇内容是参考网络教程学习过程中的笔记
开发工作着,生活快乐着,留下总结,相互交流,共同进步
开发工作着,生活快乐着,留下总结,相互交流,共同进步
分类:
微服务实战
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 零经验选手,Compose 一天开发一款小游戏!
· 一起来玩mcp_server_sqlite,让AI帮你做增删改查!!