summaryrefslogtreecommitdiffstats
path: root/authentic/admin/settings.ptl
diff options
context:
space:
mode:
authorBenjamin Dauvergne <bdauvergne@entrouvert.com>2010-02-04 23:44:25 (GMT)
committerBenjamin Dauvergne <bdauvergne@entrouvert.com>2010-02-04 23:44:25 (GMT)
commitbcf4041e9527863cf288e704d3def7e5a45612e9 (patch)
tree5f08f71c771eaef59ea2699ca0a5c77ba4a21411 /authentic/admin/settings.ptl
parenta4f367004343560c225011955560290b9e8ec197 (diff)
downloadauthentic-old-bcf4041e9527863cf288e704d3def7e5a45612e9.zip
authentic-old-bcf4041e9527863cf288e704d3def7e5a45612e9.tar.gz
authentic-old-bcf4041e9527863cf288e704d3def7e5a45612e9.tar.bz2
Show certificates content in IDP configuration page
* authentic/admin/settings.ptl: show content of private and publick key files under the concerned fields.
Diffstat (limited to 'authentic/admin/settings.ptl')
-rw-r--r--authentic/admin/settings.ptl33
1 files changed, 29 insertions, 4 deletions
diff --git a/authentic/admin/settings.ptl b/authentic/admin/settings.ptl
index 193eb3e..bb8be27 100644
--- a/authentic/admin/settings.ptl
+++ b/authentic/admin/settings.ptl
@@ -33,6 +33,23 @@ from authentic import misc
from authentic.form import *
template_error_page = error_page
+
+def get_file_content(filename):
+ try:
+ return open(filename,'r').read()
+ except:
+ return None
+
+def get_text_file_preview(filename):
+ '''Return a preformatted HTML blocks displaying content
+ of filename, or None if filename is not accessible
+ '''
+ content = get_file_content(str(filename))
+ if content:
+ return htmltext("<pre>%s</pre>") % content
+ else:
+ return None
+
def error_page(error):
return template_error_page('settings', error)
@@ -1134,6 +1151,7 @@ class SettingsDirectory(Directory):
# Commit configuration changes
get_publisher().write_cfg()
+
def idp [html] (self):
get_publisher().reload_cfg()
base_url = get_cfg('idp', {}).get('base_url', None)
@@ -1181,10 +1199,17 @@ class SettingsDirectory(Directory):
form.add(StringWidget, 'organization_name', title=_('Organisation Name'), size=50,
value = get_cfg('idp', {}).get('organization_name', None))
- form.add(FileWidget, 'privatekey', title = _('Signing Private Key'))
- form.add(FileWidget, 'publickey', title = _('Signing Public Key'))
- form.add(FileWidget, 'encryption_privatekey', title = _('Encryption Private Key'))
- form.add(FileWidget, 'encryption_publickey', title = _('Encryption Public Key'))
+
+ dir = get_publisher().app_dir
+ privatekey_fn = os.path.join(dir, 'private-key.pem')
+ publickey_fn = os.path.join(dir, 'public-key.pem')
+ encryption_privatekey_fn = os.path.join(dir, 'encryption-private-key.pem')
+ encryption_publickey_fn = os.path.join(dir, 'encryption-public-key.pem')
+
+ form.add(FileWidget, 'privatekey', title = _('Signing Private Key'), hint = get_text_file_preview(privatekey_fn))
+ form.add(FileWidget, 'publickey', title = _('Signing Public Key'), hint = get_text_file_preview(publickey_fn))
+ form.add(FileWidget, 'encryption_privatekey', title = _('Encryption Private Key'), hint = get_text_file_preview(encryption_privatekey_fn))
+ form.add(FileWidget, 'encryption_publickey', title = _('Encryption Public Key'), hint = get_text_file_preview(encryption_publickey_fn))
form.add(StringWidget, 'common_domain',
title = _('Identity Provider Introduction, Common Domain'),