From 9ca95af309290e9d5ff6d2f3fbc349713ea98fbf Mon Sep 17 00:00:00 2001 From: lishengzhao Date: Fri, 15 May 2015 15:54:36 +0800 Subject: [PATCH] 00007 Security implement different privilege --- others/database/initial_data.ddl | 4 ++-- others/oauth_test.txt | 2 +- src/main/webapp/login.jsp | 34 ++++++++++++++++++++++++++++++-- 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/others/database/initial_data.ddl b/others/database/initial_data.ddl index 8d1d98e..d6e6d22 100644 --- a/others/database/initial_data.ddl +++ b/others/database/initial_data.ddl @@ -23,7 +23,7 @@ insert into user_privilege(user_id,privilege) values (23,'MOBILE'); -- initial oauth client details test data --- 'unity-client' support browser,mobile-device visit +-- 'unity-client' support browser, js(flash) visit -- 'mobile-client' only support mobile-device visit truncate oauth_client_details; insert into oauth_client_details @@ -31,7 +31,7 @@ insert into oauth_client_details web_server_redirect_uri,authorities, access_token_validity, refresh_token_validity, additional_information, create_time, archived, trusted) values -('unity-client','unity-resource', 'unity', 'read,write','password,authorization_code,refresh_token,implicit', +('unity-client','unity-resource', 'unity', 'read,write','authorization_code,refresh_token,implicit', null,'ROLE_CLIENT',null, null,null, now(), 0, 0), ('mobile-client','mobile-resource', 'mobile', 'read,write','password,refresh_token', diff --git a/others/oauth_test.txt b/others/oauth_test.txt index 7532ee9..59f31c2 100644 --- a/others/oauth_test.txt +++ b/others/oauth_test.txt @@ -10,7 +10,7 @@ http://localhost:8080/oauth/token?client_id=unity-client&client_secret=unity&gra 方式2:基于客户端 (注意参数中的username,password,对应用户的账号,密码) [GET] -http://localhost:8080/oauth/token?client_id=mobile-client&client_secret=mobile&grant_type=password&scope=read,write&username=admin&password=admin +http://localhost:8080/oauth/token?client_id=mobile-client&client_secret=mobile&grant_type=password&scope=read,write&username=mobile&password=mobile diff --git a/src/main/webapp/login.jsp b/src/main/webapp/login.jsp index aa740fe..4ad70e1 100644 --- a/src/main/webapp/login.jsp +++ b/src/main/webapp/login.jsp @@ -15,13 +15,43 @@
- +

- +
+
+

You can use the users to login as follow:

+ + + + + + + + + + + + + + + + + + + + + + + + + +
UsernamePasswordPrivileges
adminadminAll privileges, allow visit [Mobile] and [Unity] resources
unityunityOnly allow visit [Unity] resource, support grant_type: + authorization_code,refresh_token,implicit
mobilemobileOnly allow visit [Mobile] resource, support grant_type: password,refresh_token
+
\ No newline at end of file