ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

从实战的角度谈微服务(七):对于spring security的使用

2022-02-22 18:04:23  阅读:207  来源: 互联网

标签:spring token client 谈微 9001 webapp security type localhost


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)

浏览器访问

http://localhost:9001/oauth/authorize?client_id=webapp&response_type=token&scope=all&redirect_uri=http://www.baidu.com

方式四:授权码模式(authorization_code)

获取code

http://localhost:9001/oauth/authorize?client_id=webapp&response_type=code&scope=all&redirect_uri=http://www.baidu.com

获取令牌

接口:

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"
}

标签:spring,token,client,谈微,9001,webapp,security,type,localhost
来源: https://www.cnblogs.com/lovechengyu/p/15924263.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有