From c53c8c37a0bba3fac3a9c8caed8c7adc4980ec03 Mon Sep 17 00:00:00 2001 From: monkeyk7 Date: Sat, 21 Apr 2018 00:35:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20resource?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- others/oauth_test.txt | 14 +++++++------- .../webapp/WEB-INF/jsp/mobile/dashboard.jsp | 18 +++++++++++++----- .../webapp/WEB-INF/jsp/unity/dashboard.jsp | 19 ++++++++++++++----- 3 files changed, 34 insertions(+), 17 deletions(-) diff --git a/others/oauth_test.txt b/others/oauth_test.txt index 20fd0f1..8e9b1ce 100644 --- a/others/oauth_test.txt +++ b/others/oauth_test.txt @@ -3,24 +3,24 @@ 说明:只能使用admin或unity 账号登录才能有权限访问,若使用mobile账号登录将返回Access is denied http://localhost:8080/spring-oauth-server/oauth/authorize?client_id=unity-client&redirect_uri=http%3a%2f%2flocalhost%3a8080%2fspring-oauth-server%2funity%2fdashboard&response_type=code&scope=read -说明: 由于mobile-client只支持password,refresh_token, 所以不管用哪个账号登录后都将返回Illegal action +说明: 由于mobile-client只支持password,refresh_token, 所以不管用哪个账号登录后都将返回 OAuth Error http://localhost:8080/spring-oauth-server/oauth/authorize?client_id=mobile-client&redirect_uri=http%3a%2f%2flocalhost%3a8080%2fspring-oauth-server%2fm%2fdashboard&response_type=code&scope=read 响应的URL如: -http://localhost:8080/spring-oauth-server/unity/dashboard.htm?code=zLl170 +http://localhost:8080/spring-oauth-server/unity/dashboard?code=hGQ8qx 通过code换取access_token [POST] -http://localhost:8080/spring-oauth-server/oauth/token?client_id=unity-client&client_secret=unity&grant_type=authorization_code&code=zLl170&redirect_uri=http%3a%2f%2flocalhost%3a8080%2fspring-oauth-server%2funity%2fdashboard +http://localhost:8080/spring-oauth-server/oauth/token?client_id=unity-client&client_secret=unity&grant_type=authorization_code&code=hGQ8qx&redirect_uri=http%3a%2f%2flocalhost%3a8080%2fspring-oauth-server%2funity%2fdashboard 方式2:基于客户端 (注意参数中的username,password,对应用户的账号,密码) [POST] -http://localhost:8080/spring-oauth-server/oauth/token?client_id=mobile-client&client_secret=mobile&grant_type=password&scope=read,write&username=mobile&password=mobile +http://localhost:8080/spring-oauth-server/oauth/token?client_id=mobile-client&client_secret=mobile&grant_type=password&scope=read&username=mobile&password=mobile -说明:由于unity-client不支持password,所以若用unity-client通过password方式去授权,将返回invalid_grant -http://localhost:8080/spring-oauth-server/oauth/token?client_id=unity-client&client_secret=unity&grant_type=password&scope=read,write&username=mobile&password=mobile +说明:由于unity-client不支持password,所以若用unity-client通过password方式去授权,将返回 invalid_client +http://localhost:8080/spring-oauth-server/oauth/token?client_id=unity-client&client_secret=unity&grant_type=password&scope=read&username=mobile&password=mobile @@ -29,7 +29,7 @@ http://localhost:8080/spring-oauth-server/oauth/token?client_id=unity-client&cli 获取access_token后访问资源 [GET] -http://localhost:8080/spring-oauth-server/unity/dashboard.htm?access_token=3420d0e0-ed77-45e1-8370-2b55af0a62e8 +http://localhost:8080/spring-oauth-server/unity/dashboard?access_token=89767569-5b78-4b26-ae2d-d361aa3e6bf9 diff --git a/src/main/webapp/WEB-INF/jsp/mobile/dashboard.jsp b/src/main/webapp/WEB-INF/jsp/mobile/dashboard.jsp index 7e18ae7..c59f663 100644 --- a/src/main/webapp/WEB-INF/jsp/mobile/dashboard.jsp +++ b/src/main/webapp/WEB-INF/jsp/mobile/dashboard.jsp @@ -7,16 +7,24 @@ - Mobile dashboard + Mobile 资源 -Home +Home -

Hi Mobile.

+

Hi Unity + 你已成功访问 [mobile] 资源 +

-Principal: ${SPRING_SECURITY_CONTEXT.authentication.principal} +用户信息:
-Logout +${SPRING_SECURITY_CONTEXT.authentication.principal} +
+
+

+ 访问API +

+用户信息(JSON) \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/jsp/unity/dashboard.jsp b/src/main/webapp/WEB-INF/jsp/unity/dashboard.jsp index 3a8d54a..b38e5b7 100644 --- a/src/main/webapp/WEB-INF/jsp/unity/dashboard.jsp +++ b/src/main/webapp/WEB-INF/jsp/unity/dashboard.jsp @@ -4,19 +4,28 @@ --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> +<%@ taglib tagdir="/WEB-INF/tags" prefix="tags" %> - Unity dashboard + Unity 资源 -Home +Home -

Hi Unity.

+

Hi Unity + 你已成功访问 [unity] 资源 +

-Principal: ${SPRING_SECURITY_CONTEXT.authentication.principal} +用户信息:
-Logout +${SPRING_SECURITY_CONTEXT.authentication.principal} +
+
+

+ 访问API +

+用户信息(JSON) \ No newline at end of file