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
329817e3
Commit
329817e3
authored
Aug 07, 2019
by
Quxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
x
parent
d3e00a64
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
1 deletion
+54
-1
OAuthApi.java
src/main/java/com/egolm/sso/oauth/OAuthApi.java
+54
-1
No files found.
src/main/java/com/egolm/sso/oauth/OAuthApi.java
View file @
329817e3
...
...
@@ -30,8 +30,61 @@ import com.alibaba.fastjson.JSONObject;
* <p>1. getOAuthConfig 获取OAuth系统配置信息</p>
* <p>2.getHttpServletRequest 获取HttpServletRequest对象, 用户获取Session保存OAuthToken信息, 也用于获取和解析授权后OAuth回调中的Token信息</p>
* <p>3.getHttpServletResponse 获取HttpServletResponse对象, 用于直接重定向到OAuth授权页面, 如果业务不需要直接重定向, 也可以通过 getAuthorizationUrl 方法获取OAuth的授权地址, 由用户主动点击跳转到 OAuth授权页面</p>
* <p>以下为接口实现案例</p>
* <p>Example():</p>
* <pre>
public class OAuthApiImpl implements OAuthApi {
private OAuthConfig config;
<span>@</span>Autowired
HttpServletRequest request;
<span>@</span>Autowired
HttpServletResponse response;
<span>@</span>Value("${client_id}") private String clientId;
<span>@</span>Value("${client_secret}") private String clientSecret;
<span>@</span>Value("${callback_url}") private String callbackUrl;
<span>@</span>Value("${authorize_url}") private String authorizeUrl;
<span>@</span>Value("${access_token_url}") private String accessTokenUrl;
<span>@</span>Override
public OAuthConfig getOAuthConfig() {
if(config == null) {
synchronized (this) {
if(config == null) {
config = new OAuthConfig();
config.setAccessTokenUrl(accessTokenUrl);
config.setAuthorizeUrl(authorizeUrl);
config.setCallbackUrl(callbackUrl);
config.setClientId(clientId);
config.setClientSecret(clientSecret);
}
}
}
return config;
}
<span>@</span>Override
public HttpServletRequest getHttpServletRequest() {
return request;
}
<span>@</span>Override
public HttpServletResponse getHttpServletResponse() {
return response;
}
}
* </pre>
*
*
*
*
* Example:
* <p>以下为接口调用案例</p>
* <p>Example():</p>
* <pre>
* public class LoginController {
*
...
...
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