BigW Consortium Gitlab

Commit 817d9558 by Kevin O'Connor Committed by Alexis Reigel

Prototype key verification

parent 4eebd8e1
...@@ -58,6 +58,9 @@ gem 'validates_hostname', '~> 1.0.6' ...@@ -58,6 +58,9 @@ gem 'validates_hostname', '~> 1.0.6'
# Browser detection # Browser detection
gem 'browser', '~> 2.2' gem 'browser', '~> 2.2'
# GPG
gem 'gpgme'
# LDAP Auth # LDAP Auth
# GitLab fork with several improvements to original library. For full list of changes # GitLab fork with several improvements to original library. For full list of changes
# see https://github.com/intridea/omniauth-ldap/compare/master...gitlabhq:master # see https://github.com/intridea/omniauth-ldap/compare/master...gitlabhq:master
......
...@@ -332,6 +332,8 @@ GEM ...@@ -332,6 +332,8 @@ GEM
multi_json (~> 1.11) multi_json (~> 1.11)
os (~> 0.9) os (~> 0.9)
signet (~> 0.7) signet (~> 0.7)
gpgme (2.0.13)
mini_portile2 (~> 2.1)
grape (0.19.2) grape (0.19.2)
activesupport activesupport
builder builder
...@@ -983,6 +985,7 @@ DEPENDENCIES ...@@ -983,6 +985,7 @@ DEPENDENCIES
gollum-rugged_adapter (~> 0.4.4) gollum-rugged_adapter (~> 0.4.4)
gon (~> 6.1.0) gon (~> 6.1.0)
google-api-client (~> 0.8.6) google-api-client (~> 0.8.6)
gpgme
grape (~> 0.19.2) grape (~> 0.19.2)
grape-entity (~> 0.6.0) grape-entity (~> 0.6.0)
grape-route-helpers (~> 2.0.0) grape-route-helpers (~> 2.0.0)
......
...@@ -234,6 +234,18 @@ class Commit ...@@ -234,6 +234,18 @@ class Commit
@statuses[ref] = pipelines.latest_status(ref) @statuses[ref] = pipelines.latest_status(ref)
end end
def signature
return @signature if defined?(@signature)
sig, signed = @raw.extract_signature(project.repository.raw_repository)
if sig && signed
GPGME::Crypto.new.verify(sig, signed_text: signed) do |sign|
@signature = sign
end
end
@signature ||= nil
end
def revert_branch_name def revert_branch_name
"revert-#{short_id}" "revert-#{short_id}"
end end
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
= clipboard_button(text: @commit.id, title: _("Copy commit SHA to clipboard")) = clipboard_button(text: @commit.id, title: _("Copy commit SHA to clipboard"))
%span.hidden-xs authored %span.hidden-xs authored
#{time_ago_with_tooltip(@commit.authored_date)} #{time_ago_with_tooltip(@commit.authored_date)}
= render partial: 'signature', object: @commit.signature
%span= s_('ByAuthor|by') %span= s_('ByAuthor|by')
= author_avatar(@commit, size: 24) = author_avatar(@commit, size: 24)
%strong %strong
......
- if signature
%a.btn.disabled.btn-xs{ class: ('btn-success' if signature.valid?) }
%i.fa.fa-key{ class: ('fa-inverse' if signature.valid?) }
= signature.valid? ? 'Verified': 'Unverified'
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
.commit-actions.flex-row.hidden-xs .commit-actions.flex-row.hidden-xs
- if commit.status(ref) - if commit.status(ref)
= render_commit_status(commit, ref: ref) = render_commit_status(commit, ref: ref)
= render partial: 'projects/commit/signature', object: commit.signature
= link_to commit.short_id, project_commit_path(project, commit), class: "commit-sha btn btn-transparent" = link_to commit.short_id, project_commit_path(project, commit), class: "commit-sha btn btn-transparent"
= clipboard_button(text: commit.id, title: _("Copy commit SHA to clipboard")) = clipboard_button(text: commit.id, title: _("Copy commit SHA to clipboard"))
= link_to_browse_code(project, commit) = link_to_browse_code(project, commit)
...@@ -319,6 +319,10 @@ module Gitlab ...@@ -319,6 +319,10 @@ module Gitlab
end end
end end
def extract_signature(repo)
Rugged::Commit.extract_signature(repo.rugged, sha)
end
def stats def stats
Gitlab::Git::CommitStats.new(self) Gitlab::Git::CommitStats.new(self)
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment