Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1125)

Unified Diff: remoting/webapp/remoting.js

Issue 12905012: Webapp changes to support third party authentication (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: remoting/webapp/remoting.js
diff --git a/remoting/webapp/remoting.js b/remoting/webapp/remoting.js
index c487fa1a666bad14a1ac285d72c4be1186b94216..6a4823462d6754958f79c011d85b1923a7df076d 100644
--- a/remoting/webapp/remoting.js
+++ b/remoting/webapp/remoting.js
@@ -356,3 +356,14 @@ function isWindowed_(callback) {
console.error('chome.tabs is not available.');
}
}
+
+/**
+ * Generate a nonce, to be used as an xsrf protection token.
+ *
+ * @return {string} A URL-Safe Base64-encoded 128-bit random value. */
+remoting.generateXsrfToken = function() {
+ var random = new Uint8Array(16);
+ window.crypto.getRandomValues(random);
+ var base64Token = window.btoa(String.fromCharCode.apply(null, random));
+ return base64Token.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '');
+};

Powered by Google App Engine
This is Rietveld 408576698