Skip to content

Only show SSH clone URL if signed in (#2169) #2170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 15, 2017
Merged

Conversation

stklcode
Copy link
Contributor

@stklcode stklcode commented Jul 15, 2017

This PR targets issue #2169

For cloning via SSH a user needs to provide a public key. If this is the case, this user has an account or is added by a member. Anonymous visitors hence do not need to see the SSH URL.

This is a hard-coded soliton (as voted by @lafriks), equivalent to GitHub's behavior. If a configurable solution is desired instead, I got another diofferent branch (stklcode/gitea@d7cbf5d) ready.

This solution introduces a config flag SSH_EXPOSE_ANONYMOUS (default false) to hide by default and opt-in to the old behavior.

@lafriks
Copy link
Member

lafriks commented Jul 15, 2017

If you have configurable solution than submit that

@tboerger tboerger added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jul 15, 2017
If this flag (default True) is set to false, the SSH clone URL will only be exposed if the current user is signed in.
@stklcode
Copy link
Contributor Author

Done. Updated my branch and the above description.

conf/app.ini Outdated
@@ -154,7 +156,7 @@ LFS_START_SERVER = false
; Where your lfs files put on, default is data/lfs.
LFS_CONTENT_PATH = data/lfs
; LFS authentication secret, changed this to yourself.
LFS_JWT_SECRET =
LFS_JWT_SECRET =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not change unneeded spaces

conf/app.ini Outdated
@@ -126,6 +126,8 @@ SSH_KEY_TEST_PATH =
SSH_KEYGEN_PATH = ssh-keygen
; Enable SSH Authorized Key Backup when rewriting all keys, default is true
SSH_BACKUP_AUTHORIZED_KEYS = true
; Enable exposure of SSH clone URL to anonymous visitors, default is true
SSH_EXPOSE_ANONYMOUS = true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think default should be false to match GitHub and also for security reason not to expose unneeded URL's

}{
Disabled: false,
StartBuiltinServer: false,
Domain: "",
Port: 22,
KeygenPath: "ssh-keygen",
ExposeAnonymous: true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lafriks
Copy link
Member

lafriks commented Jul 15, 2017

Also integration test would be nice to check that

To match GitHub and for security reasons, SSH URL exposure is disabled by default.
In addition to that. minor code changes have been applied.

Signed-off-by: Stefan Kalscheuer <[email protected]>
@lafriks
Copy link
Member

lafriks commented Jul 15, 2017

I hope you don't mind that I added integration tests, thanks for your first PR 👍

@lafriks lafriks added this to the 1.2.0 milestone Jul 15, 2017
@lafriks lafriks added the topic/ui Change the appearance of the Gitea UI label Jul 15, 2017
conf/app.ini Outdated
@@ -126,6 +126,8 @@ SSH_KEY_TEST_PATH =
SSH_KEYGEN_PATH = ssh-keygen
; Enable SSH Authorized Key Backup when rewriting all keys, default is true
SSH_BACKUP_AUTHORIZED_KEYS = true
; Enable exposure of SSH clone URL to anonymous visitors, default is true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change also comment that default is false

<button class="ui basic clone button" id="repo-clone-ssh" data-link="{{.CloneLink.SSH}}">
SSH
</button>
{{end}}
{{if not $.DisableHTTP}}
<input id="repo-clone-url" value="{{$.CloneLink.HTTPS}}" readonly>
{{else}}
{{else if or $.IsSigned $.ExposeAnonSSH}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also change condition to be same as for button to take into account that ssh is not disabled

<button class="ui basic clone button" id="repo-clone-ssh" data-link="{{.CloneLink.SSH}}">
SSH
</button>
{{end}}
{{if not $.DisableHTTP}}
<input id="repo-clone-url" value="{{$.CloneLink.HTTPS}}" readonly>
{{else}}
{{else if or $.IsSigned $.ExposeAnonSSH}}
<input id="repo-clone-url" value="{{$.CloneLink.SSH}}" readonly>
{{end}}
<button class="ui basic icon button poping up clipboard" id="clipboard-btn" data-original="{{.i18n.Tr "repo.copy_link"}}" data-success="{{.i18n.Tr "repo.copy_link_success"}}" data-error="{{.i18n.Tr "repo.copy_link_error"}}" data-content="{{.i18n.Tr "repo.copy_link"}}" data-variation="inverted tiny" data-clipboard-target="#repo-clone-url">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also do not show copy button if both http and ssh clone are disabled or is not signed in and because of that clone url is not visible

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The button has been shown before, if both were disabled. But you're right, definitely a reasonable change.

@@ -18,14 +18,14 @@
{{if UseHTTPS}}HTTPS{{else}}HTTP{{end}}
</button>
{{end}}
{{if not $.DisableSSH}}
{{if and (not $.DisableSSH) (or $.IsSigned $.ExposeAnonSSH)}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For bare repository check is not needed as there is already check to show clone url only if user is IsRepositoryAdmin

@lafriks
Copy link
Member

lafriks commented Jul 15, 2017

Great job 👍 LGTM

@tboerger tboerger added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Jul 15, 2017
@Bwko
Copy link
Member

Bwko commented Jul 15, 2017

LGTM

@tboerger tboerger added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Jul 15, 2017
@lunny lunny merged commit 0b17757 into go-gitea:master Jul 15, 2017
@lunny lunny added the type/enhancement An improvement of existing functionality label Aug 25, 2017
@go-gitea go-gitea locked and limited conversation to collaborators Nov 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. topic/ui Change the appearance of the Gitea UI type/enhancement An improvement of existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants