Hi all,
I would like to add the JSOpenID javascript to apps.fp.o.
The JSOpenID.js is exactly the same as in github
(
https://github.com/fedora-infra/JSOpenID).
Could I get +1's?
From 80abd64f0f1e4771475b70eccd72a5f2160ab6c0 Mon Sep 17 00:00:00 2001
From: Patrick Uiterwijk <puiterwijk(a)redhat.com>
Date: Fri, 5 Dec 2014 14:50:45 +0000
Subject: [PATCH] Add apps.fp.o/global and add JSOpenID to that
---
modules/apps-fp-o/files/global/jsopenid.js | 83 ++++++++++++++++++++++++++++
modules/apps-fp-o/manifests/init.pp | 10 +++
2 files changed, 93 insertions(+), 0 deletions(-)
create mode 100644 modules/apps-fp-o/files/global/jsopenid.js
diff --git a/modules/apps-fp-o/files/global/jsopenid.js
b/modules/apps-fp-o/files/global/jsopenid.js
new file mode 100644
index 0000000..47d0f9c
--- /dev/null
+++ b/modules/apps-fp-o/files/global/jsopenid.js
@@ -0,0 +1,83 @@
+/**
+ * Copyright (c) 2014, Patrick Uiterwijk <puiterwijk(a)redhat.com>
+ * All rights reserved.
+ *
+ * This file is part of JSOpenID.
+ *
+ * JSOpenID is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * JSOpenID is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with JSOpenID. If not, see <
http://www.gnu.org/licenses/>.
+ */
+
+function respondToLogin(targetOrigin, success, data)
+{
+ // From an iframe, window.parent == parent window
+ // So if we don't have a window.parent, we're certainly not an iframe
+ if(window.parent != null)
+ {
+ // If we don't have this element in the parent window, this is not an auth
iframe
+ if(window.parent.document.getElementById('jsopenid_ifrm') != null)
+ {
+ window.parent.postMessage({"success": success,
+ "data": data},
+ targetOrigin);
+ }
+ }
+}
+
+function tryBackgroundLogin(login_url, callback_success, callback_failed)
+{
+ if(window.parent != null)
+ {
+ // Check if we are called recursively (from within a login attempt)
+ if(window.parent.document.getElementById('jsopenid_ifrm') != null)
+ {
+ return;
+ }
+ }
+
+ // Create the iframe we are going to use
+ ifrm = document.createElement('iframe');
+ ifrm.id = 'jsopenid_ifrm';
+ ifrm.src = login_url;
+ ifrm.style.width = 0;
+ ifrm.style.height = 0;
+ ifrm.style.visibility = "hidden";
+
+ // Set up for pingbacks
+ window.addEventListener('message', function(event)
+ {
+ // We don't check don't check event.origin, as it wouldn't add
anything worthwhile
+ // This would prevent a rogue website from saying "The user is now logged
in", but we should *never* trust this anyway
+ // This whole library is only for user convenience
+ if(event.source != ifrm.contentWindow)
+ {
+ // Ignoring response from someone unexpected
+ return;
+ }
+ document.body.removeChild(ifrm);
+ if(event.data["success"])
+ {
+ callback_success(event.data["data"]);
+ }
+ else
+ {
+ if(callback_failed != null)
+ {
+ callback_failed(event.data["data"]);
+ }
+ }
+ }, false);
+
+ // HIT IT!
+ document.body.appendChild(ifrm);
+}
diff --git a/modules/apps-fp-o/manifests/init.pp b/modules/apps-fp-o/manifests/init.pp
index 4736078..0b26e6e 100644
--- a/modules/apps-fp-o/manifests/init.pp
+++ b/modules/apps-fp-o/manifests/init.pp
@@ -35,4 +35,14 @@ define apps-fp-o::proxy(
subscribe => File["/usr/share/apps-fp-o/apps.yaml"],
refreshonly => true
}
+
+ file { "/usr/share/apps-fp-o/global/":
+ owner => "root",
+ group => "root",
+ ensure => present,
+ source => "puppet:///apps-fp-o/global/",
+ require => Package['apps-fp-o'],
+ recurse => true,
+ purge => true
+ }
}
--
1.7.2.1
With kind regards,
Patrick Uiterwijk
Associate Software Engineer, Red Hat