mirror of
https://gitlab.com/hagrid-keyserver/hagrid.git
synced 2023-02-13 20:55:02 -05:00
template updates for /manage and others
This commit is contained in:
parent
6b787be92f
commit
2cba968e62
13 changed files with 127 additions and 115 deletions
24
dist/public/assets/site.css
vendored
24
dist/public/assets/site.css
vendored
|
@ -113,6 +113,16 @@ a.brand {
|
|||
width: 40px;
|
||||
}
|
||||
|
||||
.publishedUid {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
max-width: 80%;
|
||||
text-align: left;
|
||||
}
|
||||
.publishedUid div {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.button {
|
||||
height: 36px;
|
||||
border: 1px solid;
|
||||
|
@ -147,22 +157,14 @@ a.brand {
|
|||
background-color: #fff;
|
||||
border-top: 5px solid #4aa3ff;
|
||||
box-shadow: 0 2px 6px hsla(0, 0%, 0%, 0.2);
|
||||
}
|
||||
|
||||
/* This is used to enlarge the card, but is also used to constrain the
|
||||
flow of text in /about. */
|
||||
.card > .spacer {
|
||||
text-align: left;
|
||||
width: 80vw;
|
||||
max-width: 800px;
|
||||
}
|
||||
|
||||
.card > .spacer2 {
|
||||
/* This is used to enlarge the card, but is also used to constrain the
|
||||
flow of text in /about. */
|
||||
.card > .about {
|
||||
text-align: left;
|
||||
width: 80vw;
|
||||
max-width: 700px;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
span.email {
|
||||
|
|
2
dist/templates/about/about.html.hbs
vendored
2
dist/templates/about/about.html.hbs
vendored
|
@ -1,5 +1,5 @@
|
|||
{{#> layout }}
|
||||
<div class="spacer">
|
||||
<div class="about">
|
||||
<center><h2>About | <a href="/about/privacy">Privacy Policy</a> | <a href="/about/api">API Docs</a></h2></center>
|
||||
|
||||
<p>
|
||||
|
|
2
dist/templates/about/api.html.hbs
vendored
2
dist/templates/about/api.html.hbs
vendored
|
@ -1,5 +1,5 @@
|
|||
{{#> layout }}
|
||||
<div class="spacer">
|
||||
<div class="about">
|
||||
<center><h2><a href="/about">About</a> | <a href="/about/privacy">Privacy Policy</a> | API Docs</h2></center>
|
||||
|
||||
<p>
|
||||
|
|
2
dist/templates/about/privacy.html.hbs
vendored
2
dist/templates/about/privacy.html.hbs
vendored
|
@ -1,5 +1,5 @@
|
|||
{{#> layout }}
|
||||
<div class="spacer">
|
||||
<div class="about">
|
||||
|
||||
<center><h2><a href="/about">About</a> | Privacy Policy | <a href="/about/api">API Docs</a></h2></center>
|
||||
|
||||
|
|
6
dist/templates/found.html.hbs
vendored
6
dist/templates/found.html.hbs
vendored
|
@ -1,7 +1,7 @@
|
|||
{{#> layout }}
|
||||
<div class="row">
|
||||
<p class="found-key">
|
||||
We found an entry for <span class="email">{{ query }}</span>:
|
||||
<p>
|
||||
We found an entry for <span class="email">{{ query }}</span>:
|
||||
</p>
|
||||
|
||||
<p>
|
||||
|
@ -9,7 +9,7 @@
|
|||
</p>
|
||||
|
||||
<p>
|
||||
For more convenience, you should use <tt>keys.openpgp.org</tt> as
|
||||
<strong>Hint:</strong> For better convenience, you should use <tt>keys.openpgp.org</tt> as
|
||||
keyserver <a href="/about/guide">in your OpenPGP software</a>.
|
||||
</p>
|
||||
</div>
|
||||
|
|
35
dist/templates/manage/manage.html.hbs
vendored
35
dist/templates/manage/manage.html.hbs
vendored
|
@ -1,21 +1,22 @@
|
|||
{{#> layout }}
|
||||
<div class="row">
|
||||
<form action="/manage" method="POST">
|
||||
<div class="manage">
|
||||
<input type="text" name="search_term" class="manageEmail" autofocus
|
||||
placeholder="Email address">
|
||||
<button type="submit" class="manageButton button">
|
||||
Manage
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<center><h2>Delete</h2></center>
|
||||
|
||||
<div class="row">
|
||||
<p>Please enter one of your email addesses.</p>
|
||||
</div>
|
||||
<p>
|
||||
Enter the address you want to delete. We will send you an e-mail with
|
||||
a verification link.
|
||||
</p>
|
||||
|
||||
<div class="row" style="text-align: left;">
|
||||
<strong><a href="/">« Back</a></strong>
|
||||
</div>
|
||||
<form action="/manage" method="POST">
|
||||
<div class="manage">
|
||||
<input type="text" name="search_term" class="manageEmail" autofocus
|
||||
placeholder="Email address">
|
||||
<button type="submit" class="manageButton button">
|
||||
Send
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<p>
|
||||
<strong>Note:</strong> You can also use any other address published for the same key.
|
||||
</p>
|
||||
{{/layout}}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{{#> layout }}
|
||||
<div class="row">
|
||||
<p>This management link is invalid or expired.
|
||||
<p>You can <a href="/manage">click here</a> to request a new one.
|
||||
</div>
|
||||
<center><h2>Delete</h2></center>
|
||||
|
||||
<p>
|
||||
This link is invalid or expired. You can <a href="/manage">click here</a> to request a new one.
|
||||
</p>
|
||||
{{/layout}}
|
||||
|
|
59
dist/templates/manage/manage_key.html.hbs
vendored
59
dist/templates/manage/manage_key.html.hbs
vendored
|
@ -1,28 +1,41 @@
|
|||
{{#> layout }}
|
||||
<div class="row">
|
||||
|
||||
<p>
|
||||
<a href="{{base_uri}}/vks/v1/by-fingerprint/{{ fpr }}">{{base_uri}}/vks/v1/by-fingerprint/{{ fpr }}</a>
|
||||
</p>
|
||||
|
||||
{{#if uid_status}}
|
||||
<p>
|
||||
This key is published for the following addresses:
|
||||
</p>
|
||||
|
||||
{{#each uid_status}}
|
||||
<div class="publishedUid" style="">
|
||||
<div>
|
||||
{{#if uid_unpublished}}
|
||||
<div class="flash">Unpublished address: <tt>{{uid_unpublished}}</tt></div>
|
||||
{{/if}}
|
||||
<div style="width: 80%; margin-left: auto; margin-right: auto; text-align: left;">
|
||||
{{#each uid_status}}
|
||||
<div>
|
||||
<div style="float: right;">
|
||||
<form action="/manage/unpublish" method="post">
|
||||
<input type="hidden" name="token" value="{{../token}}" />
|
||||
<input type="hidden" name="address" value="{{address}}" />
|
||||
<i class="fa fa-eye-slash"></i> <input type="submit" class="link" value="Unpublish">
|
||||
</form>
|
||||
</div>
|
||||
<p>
|
||||
{{#if published}}
|
||||
<i class="fa fa-envelope"></i> <tt>{{address}}</tt>
|
||||
{{else}}
|
||||
<tt>{{address}}</tt>
|
||||
{{/if}}
|
||||
</div>
|
||||
{{/each}}
|
||||
</div>
|
||||
<form action="/manage/unpublish" method="post">
|
||||
<input type="hidden" name="token" value="{{../token}}" />
|
||||
<input type="hidden" name="address" value="{{address}}" />
|
||||
<input type="submit" class="link" value="Unpublish">
|
||||
</form>
|
||||
</div>
|
||||
<p>
|
||||
<span class="email">{{address}}</span>
|
||||
</p>
|
||||
</div>
|
||||
{{/each}}
|
||||
|
||||
<p>
|
||||
To publish this key under another address, you need to <a href="/publish">upload</a> it again.
|
||||
</p>
|
||||
|
||||
{{else}}
|
||||
<p>
|
||||
This key is not published under any e-mail address!
|
||||
</p>
|
||||
|
||||
<p>
|
||||
To publish this key under another address, you need to <a href="/publish">upload</a> it again.
|
||||
</p>
|
||||
{{/if}}
|
||||
|
||||
{{/layout}}
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
{{#> layout }}
|
||||
<p>
|
||||
We have sent an email with further instructions to <tt>{{address}}</tt>.
|
||||
</p>
|
||||
<div style="text-align: left;">
|
||||
<strong><a href="/">« Back</a></strong>
|
||||
</div>
|
||||
<p>
|
||||
We have sent an email with further instructions to <span class="email">{{address}}</span>.
|
||||
</p>
|
||||
{{/layout}}
|
||||
|
|
52
dist/templates/publish.html.hbs
vendored
52
dist/templates/publish.html.hbs
vendored
|
@ -1,5 +1,4 @@
|
|||
{{#> layout }}
|
||||
<div class="spacer2">
|
||||
<center><h2>Upload</h2></center>
|
||||
|
||||
<p>After uploading your key we will send a verification link to each email
|
||||
|
@ -7,39 +6,31 @@
|
|||
Clicking that link will make your key searchable by that email address.
|
||||
</p>
|
||||
|
||||
<div class="row">
|
||||
<form action="/vks/v1/publish" method="POST" enctype="multipart/form-data">
|
||||
<div class="upload">
|
||||
<input type="hidden" name="csrf" value="{{csrf}}" />
|
||||
<input type="file" id="keytext" name="keytext" autofocus class="fileUpload" placeholder="Your public key"/>
|
||||
<button type="submit" class="uploadButton button smallButton">
|
||||
<i class="fa fa-upload"></i>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<form action="/vks/v1/publish" method="POST" enctype="multipart/form-data">
|
||||
<div class="upload">
|
||||
<input type="hidden" name="csrf" value="{{csrf}}" />
|
||||
<input type="file" id="keytext" name="keytext" autofocus class="fileUpload" placeholder="Your public key"/>
|
||||
<button type="submit" class="uploadButton button smallButton">
|
||||
<i class="fa fa-upload"></i>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
{{#if show_help}}
|
||||
<div class="row">
|
||||
<p>
|
||||
You can delete an uploaded key <a href="/manage">here</a>.
|
||||
</p>
|
||||
</div>
|
||||
<p>
|
||||
You can delete an uploaded key <a href="/manage">here</a>.
|
||||
</p>
|
||||
|
||||
<div class="row">
|
||||
<p>If you're using GnuPG you can use the following snippet to export your
|
||||
public key.<br />
|
||||
This will create a file called mykey.pgp that you can upload here.
|
||||
</p>
|
||||
<center><pre><code class="snippet">gpg --export your_address@example.org > mykey.pgp</code></pre></center>
|
||||
</div>
|
||||
<p>If you're using GnuPG you can use the following snippet to export your
|
||||
public key.<br />
|
||||
This will create a file called mykey.pgp that you can upload here.
|
||||
</p>
|
||||
<center><pre><code class="snippet">gpg --export your_address@example.org > mykey.pgp</code></pre></center>
|
||||
{{else}}
|
||||
<div class="row">
|
||||
<p>
|
||||
You can delete an uploaded key <a href="/manage">here</a>.
|
||||
Need help <a href="/publish?guide=true">exporting your key to a file</a>?
|
||||
</p>
|
||||
</div>
|
||||
<p>
|
||||
You can delete an uploaded key <a href="/manage">here</a>.
|
||||
Need help <a href="/publish?guide=true">exporting your key to a file</a>?
|
||||
</p>
|
||||
{{/if}}
|
||||
|
||||
<script>
|
||||
|
@ -58,5 +49,4 @@
|
|||
}
|
||||
}, false);
|
||||
</script>
|
||||
</div>
|
||||
{{/layout}}
|
||||
|
|
|
@ -10,8 +10,8 @@ use database::{Database, Query, Polymorphic};
|
|||
use database::types::{Email, Fingerprint, KeyID};
|
||||
|
||||
use web::{
|
||||
HagridState,
|
||||
MyResponse,
|
||||
State,
|
||||
key_to_response,
|
||||
upload,
|
||||
};
|
||||
|
@ -118,7 +118,7 @@ pub fn pks_add(db: rocket::State<Polymorphic>, cont_type: &ContentType,
|
|||
}
|
||||
|
||||
#[get("/pks/lookup")]
|
||||
pub fn pks_lookup(state: rocket::State<State>,
|
||||
pub fn pks_lookup(state: rocket::State<HagridState>,
|
||||
db: rocket::State<Polymorphic>,
|
||||
key: Hkp) -> MyResponse {
|
||||
let query_string = key.to_string();
|
||||
|
|
|
@ -4,16 +4,16 @@ use rocket::request::Form;
|
|||
|
||||
use failure::Fallible as Result;
|
||||
|
||||
use web::{MyResponse,templates::General};
|
||||
use database::{Database, Polymorphic};
|
||||
use database::types::Email;
|
||||
use web::{HagridState, MyResponse, templates::General};
|
||||
use database::{Database, Polymorphic, types::Email};
|
||||
use mail;
|
||||
use tokens;
|
||||
|
||||
mod templates {
|
||||
#[derive(Serialize)]
|
||||
pub struct ManageKey {
|
||||
// pub uid_unpublished: Option<String>,
|
||||
pub fpr: String,
|
||||
pub base_uri: String,
|
||||
pub uid_status: Vec<ManageKeyUidStatus>,
|
||||
pub token: String,
|
||||
pub commit: String,
|
||||
|
@ -52,13 +52,17 @@ pub fn vks_manage() -> Result<MyResponse> {
|
|||
|
||||
#[get("/manage/<token>")]
|
||||
pub fn vks_manage_key(
|
||||
state: rocket::State<HagridState>,
|
||||
db: State<Polymorphic>,
|
||||
token: String,
|
||||
token_service: rocket::State<tokens::Service>,
|
||||
) -> MyResponse {
|
||||
use database::types::Fingerprint;
|
||||
use std::convert::TryFrom;
|
||||
if let Ok(fingerprint) = token_service.check(&token) {
|
||||
match db.lookup(&database::Query::ByFingerprint(fingerprint)) {
|
||||
Ok(Some(tpk)) => {
|
||||
let fp = Fingerprint::try_from(tpk.fingerprint()).unwrap();
|
||||
let mut emails: Vec<Email> = tpk.userids()
|
||||
.map(|u| u.userid().to_string().parse::<Email>())
|
||||
.flatten()
|
||||
|
@ -72,8 +76,10 @@ pub fn vks_manage_key(
|
|||
}
|
||||
).collect();
|
||||
let context = templates::ManageKey {
|
||||
fpr: fp.to_string(),
|
||||
uid_status,
|
||||
token,
|
||||
base_uri: state.base_uri.clone(),
|
||||
version: env!("VERGEN_SEMVER").to_string(),
|
||||
commit: env!("VERGEN_SHA_SHORT").to_string(),
|
||||
};
|
||||
|
@ -138,17 +144,19 @@ pub fn vks_manage_post(
|
|||
|
||||
#[post("/manage/unpublish", data="<request>")]
|
||||
pub fn vks_manage_unpublish(
|
||||
state: rocket::State<HagridState>,
|
||||
db: rocket::State<Polymorphic>,
|
||||
token_service: rocket::State<tokens::Service>,
|
||||
request: Form<forms::ManageDelete>,
|
||||
) -> MyResponse {
|
||||
match vks_manage_unpublish_or_fail(db, token_service, request) {
|
||||
match vks_manage_unpublish_or_fail(state, db, token_service, request) {
|
||||
Ok(response) => response,
|
||||
Err(e) => MyResponse::ise(e),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn vks_manage_unpublish_or_fail(
|
||||
state: rocket::State<HagridState>,
|
||||
db: rocket::State<Polymorphic>,
|
||||
token_service: rocket::State<tokens::Service>,
|
||||
request: Form<forms::ManageDelete>,
|
||||
|
@ -156,5 +164,5 @@ pub fn vks_manage_unpublish_or_fail(
|
|||
let fpr = token_service.check(&request.token)?;
|
||||
let email = request.address.parse::<Email>()?;
|
||||
db.delete_userids_matching(&fpr, &email)?;
|
||||
Ok(vks_manage_key(db, request.token.to_owned(), token_service))
|
||||
Ok(vks_manage_key(state, db, request.token.to_owned(), token_service))
|
||||
}
|
||||
|
|
|
@ -169,7 +169,7 @@ mod templates {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct State {
|
||||
pub struct HagridState {
|
||||
/// The base directory.
|
||||
state_dir: PathBuf,
|
||||
|
||||
|
@ -185,7 +185,7 @@ pub struct State {
|
|||
x_accel_redirect: bool,
|
||||
}
|
||||
|
||||
fn key_to_response<'a>(state: rocket::State<State>,
|
||||
fn key_to_response<'a>(state: rocket::State<HagridState>,
|
||||
db: rocket::State<Polymorphic>,
|
||||
query_string: String,
|
||||
query: Query,
|
||||
|
@ -231,7 +231,7 @@ fn key_to_response<'a>(state: rocket::State<State>,
|
|||
MyResponse::ok("found", context)
|
||||
}
|
||||
|
||||
fn key_has_uids(state: &State, db: &Polymorphic, query: &Query)
|
||||
fn key_has_uids(state: &HagridState, db: &Polymorphic, query: &Query)
|
||||
-> Result<bool> {
|
||||
use sequoia_openpgp::Packet;
|
||||
use sequoia_openpgp::parse::{Parse, PacketParser, PacketParserResult};
|
||||
|
@ -251,7 +251,7 @@ fn key_has_uids(state: &State, db: &Polymorphic, query: &Query)
|
|||
}
|
||||
|
||||
#[get("/vks/v1/by-fingerprint/<fpr>")]
|
||||
fn vks_v1_by_fingerprint(state: rocket::State<State>,
|
||||
fn vks_v1_by_fingerprint(state: rocket::State<HagridState>,
|
||||
db: rocket::State<Polymorphic>,
|
||||
fpr: String) -> MyResponse {
|
||||
let query = match Fingerprint::from_str(&fpr) {
|
||||
|
@ -263,7 +263,7 @@ fn vks_v1_by_fingerprint(state: rocket::State<State>,
|
|||
}
|
||||
|
||||
#[get("/vks/v1/by-email/<email>")]
|
||||
fn vks_v1_by_email(state: rocket::State<State>,
|
||||
fn vks_v1_by_email(state: rocket::State<HagridState>,
|
||||
db: rocket::State<Polymorphic>,
|
||||
email: String) -> MyResponse {
|
||||
let query = match Email::from_str(&email) {
|
||||
|
@ -275,7 +275,7 @@ fn vks_v1_by_email(state: rocket::State<State>,
|
|||
}
|
||||
|
||||
#[get("/vks/v1/by-keyid/<kid>")]
|
||||
fn vks_v1_by_keyid(state: rocket::State<State>,
|
||||
fn vks_v1_by_keyid(state: rocket::State<HagridState>,
|
||||
db: rocket::State<Polymorphic>,
|
||||
kid: String) -> MyResponse {
|
||||
let query = match KeyID::from_str(&kid) {
|
||||
|
@ -306,7 +306,7 @@ fn publish_verify(db: rocket::State<Polymorphic>,
|
|||
}
|
||||
|
||||
#[get("/assets/<file..>")]
|
||||
fn files(file: PathBuf, state: rocket::State<State>) -> Option<NamedFile> {
|
||||
fn files(file: PathBuf, state: rocket::State<HagridState>) -> Option<NamedFile> {
|
||||
NamedFile::open(state.public_dir.join("assets").join(file)).ok()
|
||||
}
|
||||
|
||||
|
@ -371,7 +371,7 @@ fn rocket_factory(rocket: rocket::Rocket) -> Result<rocket::Rocket> {
|
|||
let state_dir: PathBuf = rocket.config().get_str("state_dir")?.into();
|
||||
let public_dir = state_dir.join("public");
|
||||
let base_uri = rocket.config().get_str("base-URI")?.to_string();
|
||||
let state = State {
|
||||
let state = HagridState {
|
||||
state_dir: state_dir,
|
||||
public_dir: public_dir,
|
||||
base_uri: base_uri.clone(),
|
||||
|
@ -525,7 +525,7 @@ pub mod tests {
|
|||
let mut response = client.get("/manage").dispatch();
|
||||
assert_eq!(response.status(), Status::Ok);
|
||||
assert_eq!(response.content_type(), Some(ContentType::HTML));
|
||||
assert!(response.body_string().unwrap().contains("email"));
|
||||
assert!(response.body_string().unwrap().contains("verification link"));
|
||||
|
||||
assert_consistency(client.rocket());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue