Skip to content

fix: add vanilla links detection #200

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .deploy/circleci/token.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ database.password=1nf0rm1x
database.INFORMIXSERVER=informixoltp_tcp
database.locale=en_us.utf8

# context.security.url - URL for JNDI lookup
# context.security.url - URL for JNDI lookup
context.security.url=localhost:11199

## Used by cache.properties
Expand All @@ -35,7 +35,7 @@ WINFORMULA_SERVER_NAME=tc.cloud.topcoder.com/winformula
CSF_SERVER_NAME=csf.dev.topcoder.com
CORP_SERVER_NAME=tc.cloud.topcoder.com/corp
SOFTWARE_SERVER_NAME=tcs.cloud.topcoder.com
FORUMS_SERVER_NAME=forums.dev.topcoder.com
FORUMS_SERVER_NAME=vanilla.topcoder-dev.com
HOST_URL=localhost:11199
FORUMS_HOST_URL=jnp://localhost:1199
CONTEST_HOST_URL=63.118.154.180:10099
Expand Down
2 changes: 1 addition & 1 deletion scripts/auto_pilot/ApplicationServer.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ WINFORMULA_SERVER_NAME=tc.cloud.topcoder.com/winformula
CSF_SERVER_NAME=csf.dev.topcoder.com
CORP_SERVER_NAME=tc.cloud.topcoder.com/corp
SOFTWARE_SERVER_NAME=tcs.cloud.topcoder.com
FORUMS_SERVER_NAME=forums.dev.topcoder.com
FORUMS_SERVER_NAME=vanilla.topcoder-dev.com
HOST_URL=localhost:11199
FORUMS_HOST_URL=localhost:1199
CONTEST_HOST_URL=63.118.154.180:10099
Expand Down
29 changes: 24 additions & 5 deletions src/main/java/com/cronos/onlinereview/util/ConfigHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,11 @@ public class ConfigHelper {
*/
private static final String VALID_ISSUERS = "valid_issuers";

/**
* <p>A <code>String</code> providing the name for challenge by legacy id v5 url property.</p>
*/
private static final String CHALLENGE_BY_LEGACY_ID_URL_V5 = "challenge_by_legacy_id_url_v5";

/**
* This member variable holds the submitter role id.
*/
Expand Down Expand Up @@ -1053,12 +1058,17 @@ public class ConfigHelper {
* JWT default expiration time (1 day)
*/
private static final int DEFAULT_EXPIRATION_TIME = 60 * 24;

/**
* New Auth URL for Iframe to refresh the RS256 token
*/
private static String newAuthUrl;

/**
* Challenge by Legacy Id URL
*/
private static String challengeByLegacyIdUrlV5;

static {
// Obtaining the instance of Configuration Manager
ConfigManager cfgMgr = new ConfigManager();
Expand Down Expand Up @@ -1681,10 +1691,11 @@ public class ConfigHelper {
} catch (Exception e) {
preSignedExpTimeMilis = 60 * 60 * 1000;
}

ConfigManager.Property newAuth = cfgMgr.getPropertyObject(ONLINE_REVIEW_CFG_NS, "new_auth");
newAuthUrl = newAuth.getValue("new_auth_url");

challengeByLegacyIdUrlV5 = cfgMgr.getString(ONLINE_REVIEW_CFG_NS, CHALLENGE_BY_LEGACY_ID_URL_V5);
} catch (Exception une) {
System.out.println(une.getMessage());
une.printStackTrace();
Expand Down Expand Up @@ -2559,12 +2570,20 @@ public static String getS3BucketDmz() {
public static long getPreSignedExpTimeMilis() {
return preSignedExpTimeMilis;
}

/**
* Get new auth url
* @return url
* Get new auth url
* @return url
*/
public static String getNewAuthUrl() {
return newAuthUrl;
}

/**
* Get challenge by legacy id url
* @return url
*/
public static String getChallengeByLegacyIdUrlV5() {
return challengeByLegacyIdUrlV5;
}
}
3 changes: 3 additions & 0 deletions src/main/resources/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2092,4 +2092,7 @@
<Property name="ApprovalPhaseDefaultReviewersNumber">
<Value>1</Value>
</Property>
<Property name="challenge_by_legacy_id_url_v5">
<Value>@topcoder_api_base_url_v5@/challenges?legacyId=</Value>
</Property>
</Config>
6 changes: 3 additions & 3 deletions token.properties.local
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ AOLICQ_SERVER_NAME=63.118.154.179
WINFORMULA_SERVER_NAME=tc.cloud.topcoder.com/winformula
CSF_SERVER_NAME=csf.dev.topcoder.com
CORP_SERVER_NAME=www.topcoder-dev.com/corp
SOFTWARE_SERVER_NAME=local.topcoder-dev.com:8443
FORUMS_SERVER_NAME=forums.dev.topcoder.com
SOFTWARE_SERVER_NAME=local.topcoder-dev.com:8080
FORUMS_SERVER_NAME=vanilla.topcoder-dev.com
HOST_URL=localhost:1099
FORUMS_HOST_URL=jnp://localhost:1099
CONTEST_HOST_URL=63.118.154.180:10099
Expand Down Expand Up @@ -115,7 +115,7 @@ DOMAIN_AUTH0 = topcoder-dev.auth0.com
#CSF_SERVER_NAME=csf.dev.topcoder.com
#CORP_SERVER_NAME=tc.cloud.topcoder.com/corp
#SOFTWARE_SERVER_NAME=tcs.cloud.topcoder.com
#FORUMS_SERVER_NAME=forums.dev.topcoder.com
#FORUMS_SERVER_NAME=vanilla.topcoder-dev.com
#HOST_URL=localhost:11199
#FORUMS_HOST_URL=jnp://localhost:1199
#CONTEST_HOST_URL=63.118.154.180:10099
Expand Down
2 changes: 1 addition & 1 deletion web/includes/project/project_info.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
</c:if>
<a class="breadcrumbLinks"
href="${viewContestLink}"><or:text key="viewProjectDetails.ViewContest" /></a> |
<a class="breadcrumbLinks"
<a class="breadcrumbLinks projectInfo__forumLink"
href="${forumLink}"><or:text key="viewProjectDetails.DevelopmentForum" /></a></td>
</tr>
</table>
Expand Down
28 changes: 24 additions & 4 deletions web/jsp/viewProjectDetails.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
--%>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page language="java" isELIgnored="false" %>
<%@ page import="java.text.DecimalFormat,com.topcoder.onlinereview.component.webcommon.ApplicationServer" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
Expand Down Expand Up @@ -77,17 +78,36 @@
);
}
</script>
<script type="text/javascript">
function updateForumLink(projectId) {
return fetch("<%=com.cronos.onlinereview.util.ConfigHelper.getChallengeByLegacyIdUrlV5()%>" + projectId)
.then((response) => response.json())
.then((data) => {
let with_forum = data.filter(item => 'discussions' in item);
let id = with_forum?.[0]?.id;
if (id !== undefined) {
let forumLinkEl = document.querySelector('.projectInfo__forumLink');
return forumLinkEl.href = "https://<%=ApplicationServer.FORUMS_SERVER_NAME%>/categories/" + id;
}
});
}

document.addEventListener("DOMContentLoaded", function(){
let projectId = ${project.id};
updateForumLink(projectId);
});
</script>
</head>

<body>
<div align="center">

<div class="maxWidthBody" align="left">

<jsp:include page="/includes/inc_header.jsp" />

<jsp:include page="/includes/project/project_tabs.jsp" />

<div id="mainMiddleContent">
<div style="position: relative; width: 100%;">
<jsp:include page="/includes/project/project_info.jsp" /><br />
Expand Down Expand Up @@ -115,7 +135,7 @@
</div>
</div>
</div>

<jsp:include page="/includes/inc_footer.jsp" />

</div>
Expand Down