Skip to content

Commit 7b27892

Browse files
committed
Merge remote-tracking branch 'origin/master'
# Conflicts: # src/main/java/org/b3log/symphony/service/OpenIdService.java
2 parents e935864 + 0d818ec commit 7b27892

File tree

9 files changed

+61
-79
lines changed

9 files changed

+61
-79
lines changed

src/main/java/org/b3log/symphony/processor/OpenIdProcessor.java

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,8 @@
4040
import org.json.JSONObject;
4141

4242
import java.net.URLEncoder;
43-
import java.util.Date;
44-
import java.util.LinkedHashMap;
45-
import java.util.Map;
43+
import java.util.*;
44+
import java.util.concurrent.TimeUnit;
4645

4746
@Singleton
4847
public class OpenIdProcessor {
@@ -85,6 +84,16 @@ public static void register() {
8584
Dispatcher.get("/openid/login", openIdProcessor::showLoginForm, loginCheck::handle,csrfMidware::fill);
8685
Dispatcher.post("/openid/confirm", openIdProcessor::confirm, loginCheck::handle,csrfMidware::fill);
8786
Dispatcher.post("/openid/verify", openIdProcessor::verify, csrfMidware::fill);
87+
88+
// 开启定时任务,清理过期的nonce
89+
Symphonys.SCHEDULED_EXECUTOR_SERVICE.scheduleAtFixedRate(() -> {
90+
try {
91+
clearExpiredNonce();
92+
} catch (final Exception e) {
93+
LOGGER.log(Level.ERROR, "清理nonce定时任务出错", e);
94+
} finally {
95+
}
96+
}, 0, 60 * 1000, TimeUnit.MILLISECONDS);
8897
}
8998

9099
/**
@@ -378,5 +387,24 @@ private void sendVerifyResult(final RequestContext context,Boolean result){
378387

379388
}
380389

390+
// 清理过期的nonce
391+
private static void clearExpiredNonce(){
392+
long now = System.currentTimeMillis();
393+
List<String> toRemove = new ArrayList<>();
394+
for (String nonce : respNonceMap.keySet()) {
395+
try {
396+
Date nonceTime = OpenIdUtil.extractNonceTimestamp(nonce);
397+
long delta = Math.abs(now - nonceTime.getTime());
398+
if (delta > 5 * 60 * 1000) {
399+
toRemove.add(nonce);
400+
}
401+
} catch (Exception e) {
402+
toRemove.add(nonce);
403+
}
404+
}
405+
for (String nonce : toRemove) {
406+
respNonceMap.remove(nonce);
407+
}
408+
}
381409

382410
}

src/main/java/org/b3log/symphony/processor/TopProcessor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ public static void register() {
127127
final TopProcessor topProcessor = beanManager.getReference(TopProcessor.class);
128128
Dispatcher.get("/api/top/any", topProcessor::getAnyTop, anonymousViewCheckMidware::handle);
129129
Dispatcher.get("/top", topProcessor::showTop, anonymousViewCheckMidware::handle);
130-
Dispatcher.get("/top/link", topProcessor::showLink, anonymousViewCheckMidware::handle);
131-
Dispatcher.get("/api/top/link", topProcessor::getLink, anonymousViewCheckMidware::handle);
130+
// Dispatcher.get("/top/link", topProcessor::showLink, anonymousViewCheckMidware::handle);
131+
// Dispatcher.get("/api/top/link", topProcessor::getLink, anonymousViewCheckMidware::handle);
132132
Dispatcher.get("/top/balance", topProcessor::showBalance, anonymousViewCheckMidware::handle);
133133
Dispatcher.get("/api/top/balance", topProcessor::getBalance, anonymousViewCheckMidware::handle);
134134
Dispatcher.get("/top/consumption", topProcessor::showConsumption, anonymousViewCheckMidware::handle);

src/main/java/org/b3log/symphony/service/OpenIdService.java

Lines changed: 0 additions & 46 deletions
This file was deleted.

src/main/resources/js/common.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1625,7 +1625,7 @@ var Util = {
16251625
}
16261626
if (userURL !== "") {
16271627
html += '' +
1628-
'<a target="_blank" href="' + Label.servePath + '/forward?goto=' + userURL + '" class="tooltipped-new tooltipped__n" rel="nofollow"\n' +
1628+
'<a target="_blank" href="' + userURL + '" class="tooltipped-new tooltipped__n" rel="nofollow"\n' +
16291629
' aria-label="' + userURL + '">\n' +
16301630
' <svg>\n' +
16311631
' <use xlink:href="#card-link"></use>\n' +

src/main/resources/skins/classic/top/index.ftl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,16 @@
3434
<h2 class="sub-head"><span>🏅</span> ${totalRankLabel}</h2>
3535
<div class="list">
3636
<ul>
37-
<li class="fn__flex">
38-
<svg class="avatar"><use xlink:href="#linkIcon"></use></svg>
39-
<div class="fn-flex-1">
40-
<h2>
41-
<a class="title"
42-
href="${servePath}/top/link">链接排行</a>
43-
</h2>
44-
<div class="ft-fade ft-smaller">链接排行榜</div>
45-
</div>
46-
</li>
37+
<#-- <li class="fn__flex">-->
38+
<#-- <svg class="avatar"><use xlink:href="#linkIcon"></use></svg>-->
39+
<#-- <div class="fn-flex-1">-->
40+
<#-- <h2>-->
41+
<#-- <a class="title"-->
42+
<#-- href="${servePath}/top/link">链接排行</a>-->
43+
<#-- </h2>-->
44+
<#-- <div class="ft-fade ft-smaller">链接排行榜</div>-->
45+
<#-- </div>-->
46+
<#-- </li>-->
4747
<li class="fn__flex">
4848
<svg class="avatar"><use xlink:href="#balanceIcon"></use></svg>
4949
<div class="fn-flex-1">

src/main/resources/skins/classic/top/link.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<#list topLinks as link>
3030
<li class="fn-flex-1 fn-clear">
3131
<h2 class="fn-left">
32-
<a rel="bookmark" href="${servePath}/forward?goto=${link.linkAddr}">
32+
<a rel="bookmark" href="${link.linkAddr}">
3333
${link_index + 1}. ${link.linkTitle}</a>
3434
</h2>
3535
<div class="ft-gray fn-right">

src/main/resources/skins/classic/top/macro-top.ftl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@
3838
<link rel="canonical" href="${servePath}/top/checkin">
3939
</@head>
4040
</#if>
41-
<#if type == "link">
42-
<@head title="${linkRankLabel} - ${symphonyLabel}">
43-
<link rel="canonical" href="${servePath}/top/link">
44-
</@head>
45-
</#if>
41+
<#-- <#if type == "link">-->
42+
<#-- <@head title="${linkRankLabel} - ${symphonyLabel}">-->
43+
<#-- <link rel="canonical" href="${servePath}/top/link">-->
44+
<#-- </@head>-->
45+
<#-- </#if>-->
4646
<#if type == "online">
4747
<@head title="在线时间排行 - ${symphonyLabel}">
4848
<link rel="canonical" href="${servePath}/top/online">

src/main/resources/skins/mobile/top/index.ftl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@
3333
<h2 class="sub-head"><span>🏅</span> ${totalRankLabel}</h2>
3434
<div class="list">
3535
<ul>
36-
<li class="fn__flex">
37-
<svg class="avatar"><use xlink:href="#linkIcon"></use></svg>
38-
<div class="fn-flex-1">
39-
<h2>
40-
<a class="title"
41-
href="${servePath}/top/link">链接排行</a>
42-
</h2>
43-
<div class="ft-fade ft-smaller">链接排行榜</div>
44-
</div>
45-
</li>
36+
<#-- <li class="fn__flex">-->
37+
<#-- <svg class="avatar"><use xlink:href="#linkIcon"></use></svg>-->
38+
<#-- <div class="fn-flex-1">-->
39+
<#-- <h2>-->
40+
<#-- <a class="title"-->
41+
<#-- href="${servePath}/top/link">链接排行</a>-->
42+
<#-- </h2>-->
43+
<#-- <div class="ft-fade ft-smaller">链接排行榜</div>-->
44+
<#-- </div>-->
45+
<#-- </li>-->
4646
<li class="fn__flex">
4747
<svg class="avatar"><use xlink:href="#balanceIcon"></use></svg>
4848
<div class="fn-flex-1">

src/main/resources/skins/mobile/top/link.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<#list topLinks as link>
3030
<li class="fn-flex-1">
3131
<h2>
32-
<a rel="bookmark" href="${servePath}/forward?goto=${link.linkAddr}">
32+
<a rel="bookmark" href="${link.linkAddr}">
3333
${link_index + 1}.${link.linkTitle}</a>
3434
<span class="ft-gray ft-smaller"> &nbsp;
3535
${link.linkClickCnt?c} ${clickLabel}

0 commit comments

Comments
 (0)