1
0
Fork 0
mirror of https://gitlab.com/hagrid-keyserver/hagrid.git synced 2023-02-13 20:55:02 -05:00

Rename functions, templates, paths to publish key bindings.

- This change consistently names things related to key publishing.

  - It also moves it out of the /vks/v1 prefix.  Iff we decide to
    make (parts of) it machine-usable, we can (partially) move it back
    in.
This commit is contained in:
Justus Winter 2019-03-12 14:47:46 +01:00
parent 5f684b7d26
commit 00296ee6f7
No known key found for this signature in database
GPG key ID: 686F55B4AB2B3386
10 changed files with 31 additions and 27 deletions

View file

@ -1,7 +1,7 @@
{{#> layout }}
{{> search-form}}
<div class="row">
<p>You can also <a href="/vks/v1/publish">upload</a> or <a href="/delete">delete</a> your key.</p>
<p>You can also <a href="/publish">upload</a> or <a href="/delete">delete</a> your key.</p>
</div>
<div class="row">

View file

@ -22,7 +22,7 @@
{{domain}}, follow this link:
</p>
<p>
<a href="https://{{domain}}/vks/v1/verify/{{token}}">https://{{domain}}/vks/v1/verify/{{token}}</a>
<a href="https://{{domain}}/publish/{{token}}">https://{{domain}}/publish/{{token}}</a>
</p>
<p>
If you don't want to make the key available when searching for

View file

@ -8,7 +8,7 @@ If it was not you, or this is not your key, please ignore this email.
To make your key available when searching for "{{userid}}" on
{{domain}}, follow this link:
https://{{domain}}/vks/v1/verify/{{token}}
https://{{domain}}/publish/{{token}}
If you don't want to make the key available when searching for
"{{userid}}", please ignore this email.

View file

@ -2,7 +2,7 @@
<p>After uploading your key we will send a verification link to each email address we find inside. Clicking that link will make your key searchable by that email address.</p>
<div class="row">
<form action="/vks/v1/publish/submit" method=POST enctype=multipart/form-data>
<form action="/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"/>

View file

@ -83,3 +83,7 @@ location /vks/v1/ {
location = /delete {
proxy_pass http://127.0.0.1:8080;
}
location = /publish {
proxy_pass http://127.0.0.1:8080;
}

View file

@ -301,10 +301,10 @@ fn vks_v1_by_keyid(state: rocket::State<State>,
key_to_response(state, db, kid, query, true)
}
#[get("/vks/v1/verify/<token>")]
fn verify(state: rocket::State<State>,
db: rocket::State<Polymorphic>,
token: String) -> MyResponse {
#[get("/publish/<token>")]
fn publish_verify(state: rocket::State<State>,
db: rocket::State<Polymorphic>,
token: String) -> MyResponse {
match db.verify_token(&token) {
Ok(Some((userid, fpr))) => {
let context = templates::Verify {
@ -316,7 +316,7 @@ fn verify(state: rocket::State<State>,
commit: env!("VERGEN_SHA_SHORT").to_string(),
};
MyResponse::ok("verify", context)
MyResponse::ok("publish-result", context)
}
Ok(None) => MyResponse::not_found(Some("generic-error"), None),
Err(e) => MyResponse::ise(e),
@ -436,9 +436,9 @@ fn rocket_factory(rocket: rocket::Rocket) -> Result<rocket::Rocket> {
delete,
delete_post,
delete_confirm,
upload::vks_publish,
upload::vks_publish_submit,
verify,
upload::publish,
upload::publish_post,
publish_verify,
// HKP
hkp::pks_lookup,
hkp::pks_add,
@ -464,8 +464,8 @@ fn rocket_factory(rocket: rocket::Rocket) -> Result<rocket::Rocket> {
let from = rocket.config().get_str("from")?.to_string();
let confirm_html = template_dir.join("deletion-email-html.hbs");
let confirm_txt = template_dir.join("deletion-email-txt.hbs");
let verify_html = template_dir.join("verify-email-html.hbs");
let verify_txt = template_dir.join("verify-email-txt.hbs");
let verify_html = template_dir.join("publish-email-html.hbs");
let verify_txt = template_dir.join("publish-email-txt.hbs");
let mut handlebars = Handlebars::new();
handlebars.register_template_file("confirm-html", confirm_html)?;
@ -602,7 +602,7 @@ pub mod tests {
let response = vks_publish_submit(&client, &tpk_serialized);
assert_eq!(response.status(), Status::SeeOther);
assert_eq!(response.headers().get_one("Location"),
Some("/vks/v1/publish?ok"));
Some("/publish?ok"));
// Prior to email confirmation, we should not be able to look
// it up by email address.
@ -662,7 +662,7 @@ pub mod tests {
let response = vks_publish_submit(&client, &tpk_serialized);
assert_eq!(response.status(), Status::SeeOther);
assert_eq!(response.headers().get_one("Location"),
Some("/vks/v1/publish?ok"));
Some("/publish?ok"));
// Prior to email confirmation, we should not be able to look
// them up by email address.
@ -832,7 +832,7 @@ pub mod tests {
fn check_mails_and_verify_email(client: &Client, filemail_path: &Path) {
let confirm_re =
regex::bytes::Regex::new("https://domain(/vks/v1/verify[^ \t\n]*)")
regex::bytes::Regex::new("https://domain(/publish/[^ \t\n]*)")
.unwrap();
let confirm_mail = pop_mail(filemail_path).unwrap().unwrap();
let confirm_bytes = confirm_mail.message();
@ -897,7 +897,7 @@ pub mod tests {
body.extend_from_slice(header);
body.extend_from_slice(data);
body.extend_from_slice(footer);
client.post("/vks/v1/publish/submit")
client.post("/publish")
.header(ct)
.body(&body[..])
.dispatch()

View file

@ -42,8 +42,8 @@ mod template {
}
}
#[get("/vks/v1/publish")]
pub fn vks_publish(
#[get("/publish")]
pub fn publish(
flash: Option<FlashMessage>
) -> Template {
if let Some(flash) = flash {
@ -56,7 +56,7 @@ pub fn vks_publish(
commit: env!("VERGEN_SHA_SHORT").to_string(),
};
Template::render("vks_publish_ok", context)
Template::render("publish_ok", context)
}
_ => show_error(flash.msg().to_owned())
}
@ -66,7 +66,7 @@ pub fn vks_publish(
commit: env!("VERGEN_SHA_SHORT").to_string(),
};
Template::render("vks_publish", context)
Template::render("publish", context)
}
}
@ -77,17 +77,17 @@ fn show_error(error: String) -> Template {
commit: env!("VERGEN_SHA_SHORT").to_string(),
};
Template::render("vks_publish_err", context)
Template::render("publish_err", context)
}
#[post("/vks/v1/publish/submit", data = "<data>")]
pub fn vks_publish_submit(
#[post("/publish", data = "<data>")]
pub fn publish_post(
db: rocket::State<Polymorphic>, cont_type: &ContentType, data: Data,
mail_service: rocket::State<mail::Service>, state: rocket::State<State>,
) -> Flash<Redirect> {
match handle_upload(db, cont_type, data, Some(mail_service), state) {
Ok(ok) => ok,
Err(err) => Flash::error(Redirect::to("/vks/v1/publish?err"), err.to_string()),
Err(err) => Flash::error(Redirect::to("/publish?err"), err.to_string()),
}
}
@ -209,5 +209,5 @@ where
}
let json = serde_json::to_string(&results).unwrap();
Ok(Flash::success(Redirect::to("/vks/v1/publish?ok"), json))
Ok(Flash::success(Redirect::to("/publish?ok"), json))
}