Merge pull request #464 from rasika/release-2.0.x

Fixing sso infinite redirection
revert-70aa11f8
Harshan Liyanage 8 years ago committed by GitHub
commit cd191bcfaf

@ -31,7 +31,7 @@
{{/if}} {{/if}}
<div class="panel-body"> <div class="panel-body">
<form id="signInForm" method="POST" action="{{@app.context}}/uuf/login"> <form id="signInForm" method="POST" action="{{loginActionUrl}}">
<div class="form-group"> <div class="form-group">
<label for="username">Username *</label> <label for="username">Username *</label>
<input type="text" name="username" class="form-control" placeholder="Enter your username" <input type="text" name="username" class="form-control" placeholder="Enter your username"
@ -42,6 +42,9 @@
<input type="password" name="password" class="form-control" placeholder="Enter your password" <input type="password" name="password" class="form-control" placeholder="Enter your password"
required="required" /> required="required" />
</div> </div>
{{#if sessionDataKey}}
<input type="hidden" name="sessionDataKey" value="{{sessionDataKey}}" />
{{/if}}
{{#if referer}} {{#if referer}}
<input type="hidden" name="referer" value="{{referer}}" /> <input type="hidden" name="referer" value="{{referer}}" />
{{/if}} {{/if}}

@ -0,0 +1,28 @@
function onRequest(context) {
var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"];
var authModuleConfigs = context.app.conf["authModule"];
var sessionDataKey = request.getParameter("sessionDataKey");
//if sso enabled and sessionDataKey is empty redirect
var ssoConfigs = authModuleConfigs["sso"];
if (ssoConfigs && (ssoConfigs["enabled"].toString() == "true") && !sessionDataKey) {
// SSO is enabled in Auth module.
var redirectUri = context.app.context + "/uuf/login";
var queryString = request.getQueryString();
if (queryString && (queryString.length > 0)) {
redirectUri = redirectUri + "?" + queryString;
}
response.sendRedirect(encodeURI(redirectUri));
exit();
}
var viewModel = {};
var loginActionUrl = context.app.context + "/uuf/login";
if (sessionDataKey) {
loginActionUrl = devicemgtProps["httpsURL"] + "/commonauth";
}
viewModel.sessionDataKey = sessionDataKey;
viewModel.loginActionUrl = loginActionUrl;
return viewModel;
}

@ -1,5 +1,6 @@
{ {
"version": "1.0.0", "version": "1.0.0",
"layout": "uuf.layout.sign-in",
"uri": "/login", "uri": "/login",
"extends": "uuf.page.sign-in" "isAnonymous": true
} }
Loading…
Cancel
Save