Unverified Commit 2a5fa871 by Jessica Forrester Committed by GitHub

Merge pull request #282 from liggitt/allow-multi-login

Allow serial login flows to co-exist
parents be7b0058 dc0b4bc0
...@@ -3513,7 +3513,14 @@ angular.module('openshiftCommonServices') ...@@ -3513,7 +3513,14 @@ angular.module('openshiftCommonServices')
var makeState = function(then) { var makeState = function(then) {
var nonce = String(new Date().getTime()) + "-" + getRandomInts(8).join(""); var nonce = String(new Date().getTime()) + "-" + getRandomInts(8).join("");
try { try {
window.localStorage[nonceKey] = nonce; if (window.localStorage[nonceKey] && window.localStorage[nonceKey].length > 10) {
// Reuse an existing nonce if we have one, so that when multiple tabs get kicked to a login screen,
// any of them can succeed, not just the last login flow that was started. The nonce gets cleared when the login flow completes.
nonce = window.localStorage[nonceKey];
} else {
// Otherwise store the new nonce for comparison in parseState()
window.localStorage[nonceKey] = nonce;
}
} catch(e) { } catch(e) {
authLogger.log("RedirectLoginService.makeState, localStorage error: ", e); authLogger.log("RedirectLoginService.makeState, localStorage error: ", e);
} }
......
...@@ -5564,7 +5564,14 @@ angular.module('openshiftCommonServices') ...@@ -5564,7 +5564,14 @@ angular.module('openshiftCommonServices')
var makeState = function(then) { var makeState = function(then) {
var nonce = String(new Date().getTime()) + "-" + getRandomInts(8).join(""); var nonce = String(new Date().getTime()) + "-" + getRandomInts(8).join("");
try { try {
window.localStorage[nonceKey] = nonce; if (window.localStorage[nonceKey] && window.localStorage[nonceKey].length > 10) {
// Reuse an existing nonce if we have one, so that when multiple tabs get kicked to a login screen,
// any of them can succeed, not just the last login flow that was started. The nonce gets cleared when the login flow completes.
nonce = window.localStorage[nonceKey];
} else {
// Otherwise store the new nonce for comparison in parseState()
window.localStorage[nonceKey] = nonce;
}
} catch(e) { } catch(e) {
authLogger.log("RedirectLoginService.makeState, localStorage error: ", e); authLogger.log("RedirectLoginService.makeState, localStorage error: ", e);
} }
......
...@@ -2493,7 +2493,7 @@ return randomValues; ...@@ -2493,7 +2493,7 @@ return randomValues;
}, nonceKey = "RedirectLoginService.nonce", makeState = function(then) { }, nonceKey = "RedirectLoginService.nonce", makeState = function(then) {
var nonce = String(new Date().getTime()) + "-" + getRandomInts(8).join(""); var nonce = String(new Date().getTime()) + "-" + getRandomInts(8).join("");
try { try {
window.localStorage[nonceKey] = nonce; window.localStorage[nonceKey] && window.localStorage[nonceKey].length > 10 ? nonce = window.localStorage[nonceKey] :window.localStorage[nonceKey] = nonce;
} catch (e) { } catch (e) {
authLogger.log("RedirectLoginService.makeState, localStorage error: ", e); authLogger.log("RedirectLoginService.makeState, localStorage error: ", e);
} }
......
...@@ -74,7 +74,14 @@ angular.module('openshiftCommonServices') ...@@ -74,7 +74,14 @@ angular.module('openshiftCommonServices')
var makeState = function(then) { var makeState = function(then) {
var nonce = String(new Date().getTime()) + "-" + getRandomInts(8).join(""); var nonce = String(new Date().getTime()) + "-" + getRandomInts(8).join("");
try { try {
window.localStorage[nonceKey] = nonce; if (window.localStorage[nonceKey] && window.localStorage[nonceKey].length > 10) {
// Reuse an existing nonce if we have one, so that when multiple tabs get kicked to a login screen,
// any of them can succeed, not just the last login flow that was started. The nonce gets cleared when the login flow completes.
nonce = window.localStorage[nonceKey];
} else {
// Otherwise store the new nonce for comparison in parseState()
window.localStorage[nonceKey] = nonce;
}
} catch(e) { } catch(e) {
authLogger.log("RedirectLoginService.makeState, localStorage error: ", e); authLogger.log("RedirectLoginService.makeState, localStorage error: ", e);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment