zoukankan      html  css  js  c++  java
  • spring-oauth-server实践:客户端和服务端环境搭建

    客户端:http://localhost:8080/spring-oauth-client/index.jsp

    服务端:http://localhost:8080/spring-oauth-server/index.jsp

    access_token=942090fc-1aa0-4444-8127-57214680df3b

    验证业务:http://localhost:8080/spring-oauth-server/m/dashboard?access_token=942090fc-1aa0-4444-8127-57214680df3b

    一、客户端环境搭建

    1、客户端工程导入和配置

    2、客户端工程发布和访问

    del /q D: oolsTomcat8.0webappsspring-oauth-client.war
    del /q D: oolsTomcat8.0webappsspring-oauth-client

    copy D:workspace_SpringMybatisspring-oauth-client argetspring-oauth-client.war D: oolsTomcat8.0webappsspring-oauth-client.war

    http://localhost:8080/spring-oauth-client/index.jsp

    二、服务端环境搭建

    1、本机数据库安装

    2、服务端工程导入和配置

    3、服务端发布和访问

    del /q D: oolsTomcat8.0webappsspring-oauth-server.war
    del /q D: oolsTomcat8.0webappsspring-oauth-server

    copy D:workspace_SpringMybatisspring-oauth-server argetspring-oauth-server.war D: oolsTomcat8.0webappsspring-oauth-server.war

    http://localhost:8080/spring-oauth-server/index.jsp 

    三、客户端和服务端联调

    1、访问客户端

    http://localhost:8080/spring-oauth-client/index.jsp

    2、使用password模式申请access_token

    得到access_token

    3、找到目标业务和访问形式

    在服务端找到业务链接:http://localhost:8080/spring-oauth-server/m/dashboard?access_token=i_am_testing_access_token

    注意请求受保护的资源时传递 Access Token 有两种方式

    • 方式一在URL参数中添加access_token,即请求参数:<access_token,your_access_token>
    • 方式二在请求的Header中添加 Authorization, 其值为 beareryour_access_token, 即请求头:<Authorization, beareryour_access_token>

    4、携带access_token访问业务

    • 请求参数方式:

             http://localhost:8080/spring-oauth-server/m/dashboard?access_token=942090fc-1aa0-4444-8127-57214680df3b

    • 请求头方式:

             请求头:Authorization=bearer942090fc-1aa0-4444-8127-57214680df3b

             http://localhost:8080/spring-oauth-server/m/dashboard

         返回业务结果如下:

         

    四、访问非授权url或token失效的情况

    1、携带有效access_token

    http://localhost:8080/spring-oauth-server/m/dashboard?access_token=8fc3782b-5e24-4816-80e6-879cb4d3f1cd

    2、携带失效access_token

    http://localhost:8080/spring-oauth-server/m/dashboard?access_token=942090fc-1aa0-4444-8127-57214680df3b

    3、不携带access_token

    http://localhost:8080/spring-oauth-server/m/dashboard

    4、非授权url访问

    http://localhost:8080/spring-oauth-server/unity_user_info?access_token=8fc3782b-5e24-4816-80e6-879cb4d3f1cd

     

  • 相关阅读:
    java类,接口浅谈
    人月神话阅读笔记01
    学习进度条14
    学习进度条13
    每日站立会议10(完结)
    每日站立会议09
    每日站立会议08
    构建之法阅读笔记06(完)
    每日站立会议07
    每日站立会议06
  • 原文地址:https://www.cnblogs.com/lexiaofei/p/7223928.html
Copyright © 2011-2022 走看看