Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
birger
users
Commits
d5c7bc9b
Commit
d5c7bc9b
authored
Apr 14, 2020
by
qua
Browse files
Pgpkeys: Show WKD-URL of key.
parent
e835156c
Changes
6
Hide whitespace changes
Inline
Side-by-side
Gemfile
View file @
d5c7bc9b
...
...
@@ -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
'
...
...
Gemfile.lock
View file @
d5c7bc9b
...
...
@@ -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
b
ootsnap (>= 1.1.0)
b
ase32
bootstrap (~> 4.4.1)
byebug
capybara (>= 2.15, < 4.0)
chromedriver-helper
coffee-rails (~> 4.2)
gpgme
i18n-tasks
jbuilder (~> 2.5)
jquery-rails
...
...
app/controllers/pgpkeys_controller.rb
View file @
d5c7bc9b
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
app/views/pgpkeys/index.html.erb
View file @
d5c7bc9b
...
...
@@ -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>
...
...
config/locales/de.yml
View file @
d5c7bc9b
...
...
@@ -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
:
...
...
config/locales/en.yml
View file @
d5c7bc9b
...
...
@@ -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
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment