From 3adf880eb3896e34ace1538d98e8b81d00411653 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: May 21 2015 17:24:47 +0000 Subject: Add an endpoint presenting the ssh hostkey and fingerprint set in the configuration This allows admin to specify in their configuration the ssh hostkey and fingerprint of the git server they are using. This configuration is then displayed to the user. Fixes https://pagure.io/pagure/issue/140 --- diff --git a/files/pagure.cfg.sample b/files/pagure.cfg.sample index 2c8fcac..d49cac5 100644 --- a/files/pagure.cfg.sample +++ b/files/pagure.cfg.sample @@ -87,6 +87,14 @@ GL_RC = None GL_BINDIR = None +# SSH Information + +### The ssh certificates of the git server to be provided to the user +### /!\ format is important +# SSH_CERTS = {'RSA': {'fingerprint': '', 'pubkey': ''}} + + + # Optional configuration ### Number of items displayed per page diff --git a/pagure/templates/doc_ssh_keys.html b/pagure/templates/doc_ssh_keys.html new file mode 100644 index 0000000..064c2eb --- /dev/null +++ b/pagure/templates/doc_ssh_keys.html @@ -0,0 +1,33 @@ +{% extends "master.html" %} + +{% block title %}Doc: SSH hostkeys/Fingerprints{% endblock %} +{%block tag %}home{% endblock %} + + +{% block content %} + +

SSH Hostkeys/Fingerprints

+ +SSH host keys and fingerprints can be use to ensure you are connecting to +pagure's server and not someone else's. + +Here below are the SSH Hostkey and the Fingerprint of this current pagure +instance: + +{% if config.get('SSH_CERTS') %} + +{% for cert in config.get('SSH_CERTS') %} +

{{ cert }} Fingerprint

+{{ config['SSH_CERTS'][cert]['fingerprint'] }} + +

{{ cert }} Hostkey

+{{ config['SSH_CERTS'][cert]['pubkey'] }} +{% endfor %} + +{% else %} +

No SSH certificates have been specified in the configuration file.

+

You should ask an admin to fill this information.

+{% endif %} + + +{% endblock %} diff --git a/pagure/ui/app.py b/pagure/ui/app.py index f8d00cb..94571ba 100644 --- a/pagure/ui/app.py +++ b/pagure/ui/app.py @@ -497,3 +497,13 @@ def confirm_email(token): APP.logger.exception(err) return flask.redirect(flask.url_for('.user_settings')) + + +@APP.route('/ssh_info') +def ssh_hostkey(): + """ Endpoint returning information about the SSH hostkey and fingerprint + of the current pagure instance. + """ + return flask.render_template( + 'doc_ssh_keys.html', + )