Logout button was added to Web UI.
A click on logout button executes session_logout command. If command
succeeds or xhr stutus is 401 (unauthorized - already logged out) page
is redirected to logout.html.
logout.html is a simple page with "You have been logged out" text and a
link to return back to main page.
https://fedorahosted.org/freeipa/ticket/2363
--
Petr Vobornik
From a99a2deaa45a9d400f7a15acee11d4e5e3e2a384 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20Voborn=C3=ADk?= <pvobo...@redhat.com>
Date: Fri, 24 Feb 2012 15:31:55 +0100
Subject: [PATCH] Added logout button
Logout button was added to Web UI.
Click on logout button executes session_logout command. If command succeeds or xhr stutus is 401 (unauthorized - already logged out) page is redirected to logout.html.
logout.html is a simple page with "You have been logged out" text and a link to return back to main page.
https://fedorahosted.org/freeipa/ticket/2363
---
freeipa.spec.in | 4 ++
install/ui/Makefile.am | 1 +
install/ui/index.html | 9 ++++--
install/ui/ipa.js | 46 +++++++++++++++++++++++++++++-
install/ui/logout.html | 30 +++++++++++++++++++
install/ui/test/data/ipa_init.json | 4 ++-
install/ui/test/data/session_logout.json | 7 ++++
install/ui/webui.js | 5 +++
ipalib/plugins/internal.py | 4 ++-
9 files changed, 104 insertions(+), 6 deletions(-)
create mode 100644 install/ui/logout.html
create mode 100644 install/ui/test/data/session_logout.json
diff --git a/freeipa.spec.in b/freeipa.spec.in
index 47d0f281fe97ca564269e9eea7e0f28d1e713d88..44e4828643da8ee4f4f715ffe4b7302e6c0b14f7 100644
--- a/freeipa.spec.in
+++ b/freeipa.spec.in
@@ -551,6 +551,7 @@ fi
%{_usr}/share/ipa/migration/migration.py*
%dir %{_usr}/share/ipa/ui
%{_usr}/share/ipa/ui/index.html
+%{_usr}/share/ipa/ui/logout.html
%{_usr}/share/ipa/ui/*.ico
%{_usr}/share/ipa/ui/*.css
%{_usr}/share/ipa/ui/*.js
@@ -667,6 +668,9 @@ fi
%ghost %attr(0644,root,apache) %config(noreplace) %{_sysconfdir}/ipa/ca.crt
%changelog
+* Wed Feb 29 2012 Petr Vobornik <pvobo...@redhat.com> - 2.2.0-13
+- Add Web UI logout page
+
* Mon Feb 27 2012 Rob Crittenden <rcrit...@redhat.com> - 2.2.0-12
- Add Requires to ipa-client on oddjob-mkhomedir
diff --git a/install/ui/Makefile.am b/install/ui/Makefile.am
index d87a0944ca47e1885a9a2781e6ed03e30c662fe6..a4d083ac029446747559c63b0e039790620afb6d 100644
--- a/install/ui/Makefile.am
+++ b/install/ui/Makefile.am
@@ -38,6 +38,7 @@ app_DATA = \
jquery.js \
jquery.ordered-map.js \
json2.js \
+ logout.html \
navigation.js \
net.js \
netgroup.js \
diff --git a/install/ui/index.html b/install/ui/index.html
index db314331ab515b41ea17a1f7550c7444941bedd4..6b1be869bbff53fcd8aead7519f7ed085304b4dc 100644
--- a/install/ui/index.html
+++ b/install/ui/index.html
@@ -66,14 +66,17 @@
<div id="header">
<span class="header-logo">
- <a href="#"><img src="images/ipa-logo.png" /><img src="images/ipa-banner.png" /></a>
+ <a href="#"><img src="images/ipa-logo.png" /><img src="images/ipa-banner.png" /></a>
</span>
<span class="header-right">
<span id="loggedinas" class="header-loggedinas">
- <a href="#"><span id="login_header">Logged in as</span>: <strong>u...@freeipa.org</strong></a>
+ <a href="#"><span id="login_header">Logged in as</span>: <strong>u...@freeipa.org</strong></a>
+ </span>
+ <span class="header-loggedinas">
+ | <a href="#logout" id="logout">Logout</a>
</span>
<span id="header-network-activity-indicator" class="network-activity-indicator">
- <img src="images/spinner-header.gif" />
+ <img src="images/spinner-header.gif" />
</span>
</span>
</div>
diff --git a/install/ui/ipa.js b/install/ui/ipa.js
index d1bb04210071c6651a8fc64f6d3b57d9ab30b752..0afa4f0970538f517d0d52d066178d1ade9b781a 100644
--- a/install/ui/ipa.js
+++ b/install/ui/ipa.js
@@ -295,7 +295,6 @@ IPA.get_credentials = function() {
status = xhr.status;
}
-
function success_handler(data, text_status, xhr) {
status = xhr.status;
}
@@ -313,6 +312,51 @@ IPA.get_credentials = function() {
return status;
};
+IPA.logout = function() {
+
+ function show_error(message) {
+ var dialog = IPA.message_dialog({
+ message: message,
+ title: IPA.messages.login.logout_error
+ });
+ dialog.open();
+ }
+
+ function redirect () {
+ window.location = 'logout.html';
+ }
+
+ function success_handler(data, text_status, xhr) {
+ if (data && data.error) {
+ show_error(data.error.message);
+ } else {
+ redirect();
+ }
+ }
+
+ function error_handler(xhr, text_status, error_thrown) {
+ if (xhr.status === 401) {
+ redirect();
+ } else {
+ show_error(text_status);
+ }
+ }
+
+ var command = {
+ method: 'session_logout',
+ params: [[], {}]
+ };
+
+ var request = {
+ url: IPA.json_url || IPA.json_path + '/session_logout.json',
+ data: JSON.stringify(command),
+ success: success_handler,
+ error: error_handler
+ };
+
+ $.ajax(request);
+};
+
/**
* Call an IPA command over JSON-RPC.
*
diff --git a/install/ui/logout.html b/install/ui/logout.html
new file mode 100644
index 0000000000000000000000000000000000000000..e356d2a5f9b59f0b516825fb039eaa4210dc5d98
--- /dev/null
+++ b/install/ui/logout.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>IPA: Identity Policy Audit</title>
+
+ <link rel="stylesheet" type="text/css" href="ipa.css" />
+
+</head>
+
+<body class="info-page">
+
+ <div class="container_1">
+
+ <div class="header-logo">
+ <img src="images/ipa-logo.png" /><img src="images/ipa-banner.png" />
+ </div>
+
+ <div class="textblockkrb">
+ <h1>You have been logged out</h1>
+ <p>
+ <a href="index.html">Return to main page.</a>
+ </p>
+ </div>
+
+ </div>
+
+</body>
+
+</html>
diff --git a/install/ui/test/data/ipa_init.json b/install/ui/test/data/ipa_init.json
index 29880b2eb7323ddb702bc4e3e040b8b5f671ad51..e5b4be1698bf2b78fe4daa569ca1fd17472cf203 100644
--- a/install/ui/test/data/ipa_init.json
+++ b/install/ui/test/data/ipa_init.json
@@ -110,7 +110,9 @@
},
"false": "False",
"login": {
- "header": "Logged In As"
+ "header": "Logged In As",
+ "logout": "Logout",
+ "logout_error": "Logout error"
},
"objects": {
"aci": {
diff --git a/install/ui/test/data/session_logout.json b/install/ui/test/data/session_logout.json
new file mode 100644
index 0000000000000000000000000000000000000000..13410c6e2b69ded0cf9bb74e974a641c4494525d
--- /dev/null
+++ b/install/ui/test/data/session_logout.json
@@ -0,0 +1,7 @@
+{
+ "error": null,
+ "id": null,
+ "result": {
+ "result": null
+ }
+}
\ No newline at end of file
diff --git a/install/ui/webui.js b/install/ui/webui.js
index b8394d289dfbb7b35c09f1589a0fc59690ddeb5c..5d32e79777c21e3d3f14bb7e0609d65c0dfc5ae9 100644
--- a/install/ui/webui.js
+++ b/install/ui/webui.js
@@ -170,6 +170,11 @@ $(function() {
$('#loggedinas a').fragment(
{'user-facet': 'details', 'user-pkey': IPA.whoami_pkey}, 2);
+ $('#logout').click(function() {
+ IPA.logout();
+ return false;
+ }).text(IPA.messages.login.logout);
+
IPA.nav = create_navigation();
IPA.nav.create();
IPA.nav.update();
diff --git a/ipalib/plugins/internal.py b/ipalib/plugins/internal.py
index c346b442899b6575faa3f88e029ba200a2aa1b4c..4ccbe5cd6c810e38d1d78824f7c0bd995f144c30 100644
--- a/ipalib/plugins/internal.py
+++ b/ipalib/plugins/internal.py
@@ -245,7 +245,9 @@ class i18n_messages(Command):
},
"false": _("False"),
"login": {
- "header": _("Logged In As")
+ "header": _("Logged In As"),
+ "logout": _("Logout"),
+ "logout_error": _("Logout error"),
},
"objects": {
"aci": {
--
1.7.7.6
_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel