Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
S
sso
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
曲欣亮
sso
Commits
0beaa6d8
Commit
0beaa6d8
authored
Aug 07, 2019
by
Quxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
x
parent
3a508867
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
16 deletions
+11
-16
OAuthApi.java
src/main/java/com/egolm/sso/oauth/OAuthApi.java
+11
-16
No files found.
src/main/java/com/egolm/sso/oauth/OAuthApi.java
View file @
0beaa6d8
...
...
@@ -24,17 +24,20 @@ import com.alibaba.fastjson.JSON;
import
com.alibaba.fastjson.JSONObject
;
/**
*
* <p>SSO 权限校验接口, 权限获取和业务接口调用已经全部封装在接口默认方法中, 使用者只需实现此接口并实现接口中的抽象方法即可.</p>
* <p>需要实现的抽象方法如下:</p>
* <p>1. getOAuthConfig 获取OAuth系统配置信息</p>
* <p>2.getHttpServletRequest 获取HttpServletRequest对象, 用户获取Session保存OAuthToken信息, 也用于获取和解析授权后OAuth回调中的Token信息</p>
* <p>3.getHttpServletResponse 获取HttpServletResponse对象, 用于直接重定向到OAuth授权页面, 如果业务不需要直接重定向, 也可以通过 getAuthorizationUrl 方法获取OAuth的授权地址, 由用户主动点击跳转到 OAuth授权页面</p>
*
* Example:
* <pre>
* @Controller
* @RequestMapping
* public class LoginController {
*
* @Autowired
* OAuthApi oAuthApi;
*
* @GetMapping
* private ModelAndView index() {
* public ModelAndView index() {
* OAuthConfig config = oAuthApi.getOAuthConfig();
* ModelAndView mav = new ModelAndView();
* mav.addObject("loginUrl", oAuthApi.getAuthorizationUrl()); //设置登陆授权URL, 用户可以在页面点击此URL,进入OAuth系统授权
...
...
@@ -43,13 +46,11 @@ import com.alibaba.fastjson.JSONObject;
* return mav;
* }
*
* @GetMapping("toLogin")
* private void toLogin() {
* public void toLogin() {
* oAuthApi.doRedirectOAuthLogin(); //直接转到OAuth系统授权,和用户主动在页面点击授权URL效果一样,都是跳转到一样的地址
* }
*
* @RequestMapping(value="callback", method= {RequestMethod.GET, RequestMethod.POST})
* private ModelAndView doLogin() {
* public ModelAndView doLogin() {
* oAuthApi.callback(); //授权成功后,授权系统通过重定向的方式回调业务系统,并附带授权参数信息,此代码用于解析授权系统的回调参数
* OAuthToken token = oAuthApi.getOAuthToken();
* ModelAndView mav = new ModelAndView();
...
...
@@ -58,8 +59,7 @@ import com.alibaba.fastjson.JSONObject;
* return mav;
* }
*
* @RequestMapping(value="doLogout", method= {RequestMethod.GET, RequestMethod.POST})
* private ModelAndView doLogout(HttpServletResponse response) throws IOException {
* public ModelAndView doLogout(HttpServletResponse response) throws IOException {
* oAuthApi.removeOAuthToken();
* ModelAndView mav = new ModelAndView();
* mav.setViewName("redirect:/");
...
...
@@ -69,11 +69,6 @@ import com.alibaba.fastjson.JSONObject;
* }
* </pre>
*
* SSO 权限校验接口, 权限获取和业务接口调用已经全部封装在接口默认方法中, 使用者只需实现此接口并实现接口中的抽象方法即可.
* 需要实现的抽象方法如下:
* 1. getOAuthConfig 获取OAuth系统配置信息
* 2.getHttpServletRequest 获取HttpServletRequest对象, 用户获取Session保存OAuthToken信息, 也用于获取和解析授权后OAuth回调中的Token信息
* 3.getHttpServletResponse 获取HttpServletResponse对象, 用于直接重定向到OAuth授权页面, 如果业务不需要直接重定向, 也可以通过 getAuthorizationUrl 方法获取OAuth的授权地址, 由用户主动点击跳转到 OAuth授权页面
*
* @author Quxl
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment