From 7f5772637d0056ebbf77683b64deef0e1164490a Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Aug 23 2017 18:19:32 +0000 Subject: Do not show the SSH url when the user isn't logged in --- diff --git a/pagure/api/project.py b/pagure/api/project.py index 904673d..2d0798b 100644 --- a/pagure/api/project.py +++ b/pagure/api/project.py @@ -184,9 +184,17 @@ def api_project_git_urls(repo, username=None, namespace=None): if repo is None: raise pagure.exceptions.APIError(404, error_code=APIERROR.ENOPROJECT) git_urls = {} - if pagure.APP.config.get('GIT_URL_SSH'): - git_urls['ssh'] = '{0}{1}.git'.format( - pagure.APP.config['GIT_URL_SSH'], repo.fullname) + + git_url_ssh = APP.config.get('GIT_URL_SSH') + if authenticated() and git_url_ssh: + try: + git_url_ssh = git_url_ssh.format( + username=flask.g.fas_user.username) + except (KeyError, IndexError): + pass + + if git_url_ssh: + git_urls['ssh'] = '{0}{1}.git'.format(git_url_ssh, repo.fullname) if pagure.APP.config.get('GIT_URL_GIT'): git_urls['git'] = '{0}{1}.git'.format( pagure.APP.config['GIT_URL_GIT'], repo.fullname) diff --git a/pagure/templates/repo_info.html b/pagure/templates/repo_info.html index e2c33d3..c81a3ed 100644 --- a/pagure/templates/repo_info.html +++ b/pagure/templates/repo_info.html @@ -158,6 +158,7 @@ git push -u origin master aria-expanded="false" aria-controls="moregiturls" id="more_gits">more{%endif%}
+ {% if authenticated and g.repo_committer %}
SSH
@@ -165,6 +166,7 @@ git push -u origin master git_url_ssh }}{{ repo.fullname }}.git" readonly>
+ {% endif %}
GIT
diff --git a/pagure/ui/repo.py b/pagure/ui/repo.py index 15cd712..d09d3c3 100644 --- a/pagure/ui/repo.py +++ b/pagure/ui/repo.py @@ -124,7 +124,7 @@ def view_repo(repo, username=None, namespace=None): repo=repo_db.name, identifier=branchname, filename='')) git_url_ssh = APP.config.get('GIT_URL_SSH') - if authenticated(): + if authenticated() and git_url_ssh: try: git_url_ssh = git_url_ssh.format( username=flask.g.fas_user.username)