Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
solo-1
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
Administrator
solo-1
Commits
800f34cd
Unverified
Commit
800f34cd
authored
Jul 13, 2019
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🐛
Fix #12813
parent
6cc32623
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
12 deletions
+10
-12
pom.xml
pom.xml
+1
-1
src/main/java/org/b3log/solo/processor/OAuthProcessor.java
src/main/java/org/b3log/solo/processor/OAuthProcessor.java
+9
-11
No files found.
pom.xml
View file @
800f34cd
...
@@ -73,7 +73,7 @@
...
@@ -73,7 +73,7 @@
</scm>
</scm>
<properties>
<properties>
<org.b3log.latke.version>
2.5.
0
</org.b3log.latke.version>
<org.b3log.latke.version>
2.5.
1
</org.b3log.latke.version>
<slf4j.version>
1.7.5
</slf4j.version>
<slf4j.version>
1.7.5
</slf4j.version>
<jsoup.version>
1.9.1
</jsoup.version>
<jsoup.version>
1.9.1
</jsoup.version>
...
...
src/main/java/org/b3log/solo/processor/OAuthProcessor.java
View file @
800f34cd
...
@@ -43,7 +43,7 @@ import org.json.JSONObject;
...
@@ -43,7 +43,7 @@ import org.json.JSONObject;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.
Map
;
import
java.util.
Set
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ConcurrentHashMap
;
/**
/**
...
@@ -54,7 +54,7 @@ import java.util.concurrent.ConcurrentHashMap;
...
@@ -54,7 +54,7 @@ import java.util.concurrent.ConcurrentHashMap;
* </ul>
* </ul>
*
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.
0.8, Mar 27
, 2019
* @version 1.0.
1.0, Jul 13
, 2019
* @since 2.9.5
* @since 2.9.5
*/
*/
@RequestProcessor
@RequestProcessor
...
@@ -68,7 +68,7 @@ public class OAuthProcessor {
...
@@ -68,7 +68,7 @@ public class OAuthProcessor {
/**
/**
* OAuth parameters - state.
* OAuth parameters - state.
*/
*/
private
static
final
Map
<
String
,
String
>
STATES
=
new
ConcurrentHashMap
<>
();
private
static
final
Set
<
String
>
STATES
=
ConcurrentHashMap
.
newKeySet
();
/**
/**
* Option query service.
* Option query service.
...
@@ -138,11 +138,10 @@ public class OAuthProcessor {
...
@@ -138,11 +138,10 @@ public class OAuthProcessor {
referer
=
Latkes
.
getServePath
();
referer
=
Latkes
.
getServePath
();
}
}
final
String
cb
=
Latkes
.
getServePath
()
+
"/oauth/github"
;
final
String
cb
=
Latkes
.
getServePath
()
+
"/oauth/github"
;
final
String
state
=
referer
+
":::"
+
RandomStringUtils
.
randomAlphanumeric
(
16
)
+
":::cb="
+
cb
+
":::"
;
String
state
=
referer
+
":::"
+
RandomStringUtils
.
randomAlphanumeric
(
16
)
+
":::cb="
+
cb
+
":::"
;
STATES
.
put
(
state
,
URLs
.
encode
(
state
)
);
STATES
.
add
(
state
);
final
String
path
=
loginAuthURL
+
"?client_id="
+
clientId
+
"&state="
+
state
final
String
path
=
loginAuthURL
+
"?client_id="
+
clientId
+
"&state="
+
URLs
.
encode
(
state
)
+
"&scope=public_repo,read:user,user:follow"
;
+
"&scope=public_repo,read:user,user:follow"
;
context
.
sendRedirect
(
path
);
context
.
sendRedirect
(
path
);
}
}
...
@@ -154,15 +153,14 @@ public class OAuthProcessor {
...
@@ -154,15 +153,14 @@ public class OAuthProcessor {
*/
*/
@RequestProcessing
(
value
=
"/oauth/github"
,
method
=
HttpMethod
.
GET
)
@RequestProcessing
(
value
=
"/oauth/github"
,
method
=
HttpMethod
.
GET
)
public
synchronized
void
authCallback
(
final
RequestContext
context
)
{
public
synchronized
void
authCallback
(
final
RequestContext
context
)
{
final
String
state
=
context
.
param
(
"state"
);
String
state
=
context
.
param
(
"state"
);
String
referer
=
STATES
.
get
(
state
);
if
(!
STATES
.
contains
(
state
))
{
if
(
StringUtils
.
isBlank
(
referer
))
{
context
.
sendError
(
HttpServletResponse
.
SC_BAD_REQUEST
);
context
.
sendError
(
HttpServletResponse
.
SC_BAD_REQUEST
);
return
;
return
;
}
}
STATES
.
remove
(
state
);
STATES
.
remove
(
state
);
referer
=
URLs
.
decode
(
referer
);
final
String
referer
=
URLs
.
decode
(
state
);
final
String
accessToken
=
context
.
param
(
"ak"
);
final
String
accessToken
=
context
.
param
(
"ak"
);
final
JSONObject
userInfo
=
GitHubs
.
getGitHubUserInfo
(
accessToken
);
final
JSONObject
userInfo
=
GitHubs
.
getGitHubUserInfo
(
accessToken
);
if
(
null
==
userInfo
)
{
if
(
null
==
userInfo
)
{
...
...
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