Quick fix for issue where '-' in handle name is not accepted. See issue #83 for remaining work.

This commit is contained in:
Tim Bruijnzeels
2019-09-10 21:26:35 +02:00
parent 8a666a71c9
commit e710452eac
5 changed files with 22 additions and 8 deletions
+14 -1
View File
@@ -397,7 +397,17 @@ impl Options {
if let Some(m) = matches.subcommand_matches("cas") {
if let Some(m) = m.subcommand_matches("add") {
let handle = Handle::from(m.value_of("handle").unwrap());
let handle_str = m.value_of("handle").unwrap();
// TODO: Issue #83 Allow '\' and '/' as well as per RFC 8183
if !handle_str
.bytes()
.all(|b| b.is_ascii_alphanumeric() || b == b'_' || b == b'-')
{
return Err(Error::InvalidHandle);
}
let handle = Handle::from(handle_str);
let token = Token::from(m.value_of("token").unwrap());
let pub_mode = CertAuthPubMode::Embedded;
@@ -690,6 +700,9 @@ pub enum Error {
#[display(fmt = "{}", _0)]
InvalidRouteDelta(AuthorizationFmtError),
#[display(fmt = "The publisher handle may only contain -_A-Za-z0-9, (\\ /) see issue #83")]
InvalidHandle,
}
impl From<rfc8183::Error> for Error {
+1 -1
View File
@@ -1,2 +1,2 @@
pub mod server;
pub mod ssl;
pub mod ssl;
-3
View File
@@ -96,13 +96,10 @@ pub fn start(config: &Config) -> Result<(), Error> {
.data(web::Json::<PublishDelta>::configure(|cfg| {
cfg.limit(256 * 1024 * 1024)
}))
// Identity exchanges for remote publishers
.route("/rfc8181/{handle}", post().to(rfc8181))
// Provisioning for remote krill clients
.route("/rfc6492/{handle}", post().to(rfc6492))
// RRDP repository
.route("/rrdp/{path:.*}", get().to(serve_rrdp_files))
.route(
+1 -1
View File
@@ -6,8 +6,8 @@ extern crate rand;
extern crate rpki;
#[macro_use]
extern crate serde;
extern crate uuid;
extern crate krill_commons;
extern crate uuid;
pub mod publishers;
pub mod repo;
+6 -2
View File
@@ -141,7 +141,11 @@ impl PubServer {
fn verify_handle(&self, handle: &Handle) -> Result<(), Error> {
let name = handle.as_str();
if !name.bytes().all(|b| b.is_ascii_alphanumeric() || b == b'_') {
// TODO: Issue #83 Allow '\' and '/' as well as per RFC 8183
if !name
.bytes()
.all(|b| b.is_ascii_alphanumeric() || b == b'_' || b == b'-')
{
return Err(Error::InvalidHandle(name.to_string()));
}
@@ -246,7 +250,7 @@ pub enum Error {
IoError(io::Error),
#[display(
fmt = "The publisher handle may only contain a-ZA-Z0-9 and _. You sent: {}",
fmt = "The publisher handle may only contain -_A-Za-z0-9, (\\ /) see issue #83, got: {}",
_0
)]
InvalidHandle(String),