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
3a508867
Commit
3a508867
authored
Aug 07, 2019
by
Quxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
x
parent
eae7c1d2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
0 deletions
+44
-0
OAuthApi.java
src/main/java/com/egolm/sso/oauth/OAuthApi.java
+44
-0
No files found.
src/main/java/com/egolm/sso/oauth/OAuthApi.java
View file @
3a508867
...
@@ -24,6 +24,50 @@ import com.alibaba.fastjson.JSON;
...
@@ -24,6 +24,50 @@ import com.alibaba.fastjson.JSON;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
/**
/**
* Example:
* <pre>
* @Controller
* @RequestMapping
* public class LoginController {
*
* @Autowired
* OAuthApi oAuthApi;
*
* @GetMapping
* private ModelAndView index() {
* OAuthConfig config = oAuthApi.getOAuthConfig();
* ModelAndView mav = new ModelAndView();
* mav.addObject("loginUrl", oAuthApi.getAuthorizationUrl()); //设置登陆授权URL, 用户可以在页面点击此URL,进入OAuth系统授权
* mav.addObject("config", config);
* mav.setViewName("index.html");
* return mav;
* }
*
* @GetMapping("toLogin")
* private void toLogin() {
* oAuthApi.doRedirectOAuthLogin(); //直接转到OAuth系统授权,和用户主动在页面点击授权URL效果一样,都是跳转到一样的地址
* }
*
* @RequestMapping(value="callback", method= {RequestMethod.GET, RequestMethod.POST})
* private ModelAndView doLogin() {
* oAuthApi.callback(); //授权成功后,授权系统通过重定向的方式回调业务系统,并附带授权参数信息,此代码用于解析授权系统的回调参数
* OAuthToken token = oAuthApi.getOAuthToken();
* ModelAndView mav = new ModelAndView();
* mav.addObject("token", token);
* mav.setViewName("system.html");
* return mav;
* }
*
* @RequestMapping(value="doLogout", method= {RequestMethod.GET, RequestMethod.POST})
* private ModelAndView doLogout(HttpServletResponse response) throws IOException {
* oAuthApi.removeOAuthToken();
* ModelAndView mav = new ModelAndView();
* mav.setViewName("redirect:/");
* return mav;
* }
*
* }
* </pre>
*
*
* SSO 权限校验接口, 权限获取和业务接口调用已经全部封装在接口默认方法中, 使用者只需实现此接口并实现接口中的抽象方法即可.
* SSO 权限校验接口, 权限获取和业务接口调用已经全部封装在接口默认方法中, 使用者只需实现此接口并实现接口中的抽象方法即可.
* 需要实现的抽象方法如下:
* 需要实现的抽象方法如下:
...
...
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