Commit d5c7bc9b authored by qua's avatar qua
Browse files

Pgpkeys: Show WKD-URL of key.

parent e835156c
......@@ -34,6 +34,10 @@ gem 'jbuilder', '~> 2.5'
gem 'rqrcode'
gem 'rotp'
# for pgpkeys
gem 'base32'
gem 'gpgme'
gem 'ruby-saml', '~> 1.9.0'
gem 'unidecoder'
......
......@@ -50,6 +50,7 @@ GEM
ast (2.4.0)
autoprefixer-rails (9.7.4)
execjs
base32 (0.3.2)
bindex (0.8.1)
bootsnap (1.4.4)
msgpack (~> 1.0)
......@@ -91,6 +92,8 @@ GEM
ffi (1.11.1)
globalid (0.4.2)
activesupport (>= 4.2.0)
gpgme (2.0.20)
mini_portile2 (~> 2.3)
hashdiff (1.0.0)
highline (2.0.2)
http-cookie (1.0.3)
......@@ -266,12 +269,13 @@ PLATFORMS
ruby
DEPENDENCIES
bootsnap (>= 1.1.0)
base32
bootstrap (~> 4.4.1)
byebug
capybara (>= 2.15, < 4.0)
chromedriver-helper
coffee-rails (~> 4.2)
gpgme
i18n-tasks
jbuilder (~> 2.5)
jquery-rails
......
class PgpkeysController < ApplicationController
def index
@pgpkey_description = get_key(current_user)
@pgpkey_wkd_url = calculate_wkd_url(current_user)
rescue => exc
log_exception(exc)
flash[:verbatim] = exception_to_flash_message(exc)
......@@ -68,4 +69,16 @@ class PgpkeysController < ApplicationController
nil
end
end
def calculate_wkd_url(emailaddress)
local_part, domain = emailaddress.split('@', 2)
wkd_url_fragment = wkd_hash(local_part)
"https://openpgpkey.#{domain}/.well-known/openpgpkey/#{domain}/hu/#{wkd_url_fragment}"
end
def wkd_hash(string)
# Table for z-base-32 encoding.
Base32.table = "ybndrfg8ejkmcpqxot1uwisza345h769"
Base32.encode(Digest::SHA1.digest(string.downcase))
end
end
......@@ -10,6 +10,10 @@
<%= form_tag(pgpkeys_path, method: "delete") do %>
<b><%= current_user %></b>
<pre class="pt-2"><%= @pgpkey_description %></pre>
<p class='text-secondary'>
<%= t('pgpkeys_retrievable_from') %>
<span class='text-monospace'><%= @pgpkey_wkd_url %></span>
</p>
<%= submit_tag(t(:delete), class: "btn btn-danger") %>
<% end %>
</li>
......
......@@ -182,6 +182,7 @@ de:
pgpkeys_upload_key: 'Lade einen neuen oder anderen Schlüssel hoch:'
pgpkeys_submit_button: Absenden
pgpkeys_error_message: 'Der Server antwortete: %{error_message}'
pgpkeys_retrievable_from: 'Abrufbar unter'
activerecord:
errors:
......
......@@ -183,6 +183,7 @@ en:
pgpkeys_upload_key: 'Upload a new or different key:'
pgpkeys_submit_button: Send
pgpkeys_error_message: 'The server responded with: %{error_message}'
pgpkeys_retrievable_from: 'Retrievable from'
activerecord:
errors:
......
Supports Markdown
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