Skip to content
This repository was archived by the owner on Jan 23, 2025. It is now read-only.

Commit 402fa26

Browse files
author
jamesdotcom
committed
Merge pull request #118 from skyhit/add_standard_username_and_password_login_for_local_and_vm_env
add standard username and password logic for dev (local and VM)
2 parents 6c3c72f + 47409ca commit 402fa26

File tree

7 files changed

+32
-3
lines changed

7 files changed

+32
-3
lines changed

conf/Direct.properties

+2
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@ LDAP_AUTH0_CONNECTION_NAME = @LDAP_AUTH0_CONNECTION_NAME@
1818
REDIRECT_URL_AUTH0 = /reg2/callback.action
1919
REG_SERVER_NAME= @REG_SERVER_NAME@
2020

21+
#Parameter whether we use login processor or not
22+
USE_LOGIN_PROCESSOR = @useLoginProcessor@

jboss_files/lib/tcwebcommon.jar

55.4 KB
Binary file not shown.

src/java/main/com/topcoder/direct/services/view/processor/security/MockLoginProcessor.java

+8
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
import com.topcoder.web.common.SimpleRequest;
2424
import com.topcoder.web.common.SimpleResponse;
2525
import com.topcoder.web.common.security.LightAuthentication;
26+
import com.topcoder.web.common.security.SSOCookieService;
27+
import com.topcoder.web.common.security.SSOCookieServiceImpl;
2628
import com.topcoder.web.common.security.SessionPersistor;
2729
import org.apache.struts2.ServletActionContext;
2830
import org.w3c.dom.Document;
@@ -193,6 +195,12 @@ public void processRequest(LoginAction action) {
193195
new SimpleResponse(ServletActionContext.getResponse()));
194196
auth.login(new SimpleUser(tcSubject.getUserId(), username, password), action.getFormData().isRemember());
195197

198+
//We need to set SSO cookie, BUT password in MockXmlAuthenticator.xml must be same with
199+
//the one in database
200+
SSOCookieService ssoCookieService = new SSOCookieServiceImpl();
201+
ssoCookieService.setSSOCookie(ServletActionContext.getResponse(), tcSubject.getUserId(),
202+
action.getFormData().isRemember());
203+
196204
// generate the jwt cookie
197205
DirectJWTSigner jwtSigner = new DirectJWTSigner(DirectProperties.CLIENT_SECRET_AUTH0);
198206

src/java/main/com/topcoder/direct/services/view/util/DirectProperties.java

+6
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,12 @@ public final class DirectProperties {
132132
*/
133133
public static String LDAP_AUTH0_CONNECTION_NAME;
134134

135+
/**
136+
* Paramater whether we use loginProcessor or not
137+
*
138+
*/
139+
public static String USE_LOGIN_PROCESSOR;
140+
135141
/**
136142
* <p>
137143
* Initializes non-final static fields for this class with values for the same-named properties from the resource

src/web/WEB-INF/index.jsp

+6-3
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949

5050

5151
<script type="text/javascript">
52+
var use_login_processor = <%=DirectProperties.USE_LOGIN_PROCESSOR%>;
5253
5354
function isEnterKeyPressed(e) {
5455
if (window.event) return (window.event.keyCode == 13);
@@ -58,7 +59,7 @@
5859
5960
function submitOnEnter(e) {
6061
if (!isEnterKeyPressed(e)) return true;
61-
submitAuth0LoginForm();
62+
doSubmitLoginForm();
6263
return false;
6364
}
6465
@@ -144,6 +145,7 @@
144145
<!-- End .headerInner -->
145146
</div>
146147
<!-- End #header -->
148+
<s:form action="home" namespace="/" id="LoginForm" method="post">
147149
<div class="loginBox">
148150
<div class="loginBoxInner">
149151
<h2>Login to your account</h2>
@@ -156,15 +158,16 @@
156158

157159
<p class="password inputF"><input type="password" placeholder="Password" onkeypress="submitOnEnter(event);" id="LoginForm_formData_password" name="formData.password" maxlength="50"><span></span></p>
158160

159-
<a class="login" href="javascript:;" onclick="submitAuth0LoginForm();">Login</a>
161+
<a class="login" href="javascript:;" onclick="doSubmitLoginForm();">Login</a>
160162

161163
<p class="additonalAction jqtransform">
162164
<span class="signForget"><a href="http://<%=ServerConfiguration.NEW_SERVER_NAME%>/?action=callback" target="_blank">Sign Up</a> | <a href="http://www.topcoder.com/password-recovery/" target="_blank">Forgot Password
163165
?</a></span>
164166
<input type="checkbox" name="formData.remember" id="remember_me"><label>Remember me</label>
165167
</p>
166168

167-
</div>
169+
</div>
170+
</s:form>
168171
<div class="socialNetwork">
169172
<a href="javascript:;" class="salesforceIcon socialLogin" title="Login with Salesforce"></a>
170173
<a href="javascript:;" class="githubIcon socialLogin" title="Login with GitHub"></a>

src/web/scripts/scripts.js

+8
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,14 @@ var submitLoginForm = function() {
7070
document.LoginForm.submit();
7171
}
7272

73+
var doSubmitLoginForm = function() {
74+
if (use_login_processor){
75+
submitLoginForm();
76+
}else{
77+
submitAuth0LoginForm();
78+
}
79+
80+
}
7381
$(document).ready(function () {
7482

7583
var wrapperH = $('#landingPage #wrapper').height() + 25;

token.properties.example

+2
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@
202202
##########################
203203
# typical windows configuration
204204
@loginProcessor@=com.topcoder.direct.services.view.processor.security.EJBLoginProcessor
205+
# set to 'true' if you want to use @loginProcessor@ as authentication system
206+
@useLoginProcessor@=false
205207

206208
# typical VM configuration
207209
#@loginProcessor@=com.topcoder.direct.services.view.processor.security.LoginProcessor

0 commit comments

Comments
 (0)