mirror of
https://github.com/NLnetLabs/krill.git
synced 2026-09-18 07:27:42 +02:00
Restructuring modules
This commit is contained in:
+3
-4
@@ -15,9 +15,8 @@ use rpki::x509::ValidationError;
|
||||
use toml;
|
||||
use crate::file;
|
||||
use crate::file::{CurrentFile, RecursorError};
|
||||
use crate::publishing::info::{MyRepoInfo, ParentInfo};
|
||||
use crate::remote::builder::{IdCertBuilder, SignedMessageBuilder};
|
||||
use crate::remote::id::MyIdentity;
|
||||
use crate::remote::id::{MyIdentity, MyRepoInfo, ParentInfo};
|
||||
use crate::remote::oob::{PublisherRequest, RepositoryResponse};
|
||||
use crate::remote::publication::pubmsg::{Message, MessageError, ReplyMessage};
|
||||
use crate::remote::publication::reply::{ErrorReply, ListReply};
|
||||
@@ -610,8 +609,8 @@ impl From<RecursorError> for Error {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use test;
|
||||
use publishing::pubserver::PubServer;
|
||||
use daemon::api::auth::Authorizer;
|
||||
use crate::daemon::api::auth::Authorizer;
|
||||
use crate::daemon::pubserver::PubServer;
|
||||
|
||||
fn test_server(work_dir: &PathBuf, xml_dir: &PathBuf) -> PubServer {
|
||||
// Start up a server
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
//! Authorization for the API
|
||||
|
||||
use std::sync::Arc;
|
||||
use std::sync::{RwLock, RwLockReadGuard};
|
||||
use std::sync::{Arc, RwLock, RwLockReadGuard};
|
||||
use actix_web::{HttpResponse, HttpRequest, Result};
|
||||
use actix_web::middleware::{Middleware, Started};
|
||||
use crate::publishing::pubserver::PubServer;
|
||||
use actix_web::http::HeaderMap;
|
||||
use actix_web::middleware::{Middleware, Started};
|
||||
use crate::daemon::pubserver::PubServer;
|
||||
|
||||
pub struct CheckAuthorisation;
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
//! Support for the Json API
|
||||
|
||||
use std::sync::Arc;
|
||||
use crate::daemon::publishers::Publisher;
|
||||
use crate::ext_serde;
|
||||
use crate::publishing::publisher::Publisher;
|
||||
use crate::rpki::uri;
|
||||
|
||||
//------------ Link ----------------------------------------------------------
|
||||
|
||||
@@ -16,9 +16,9 @@ use crate::daemon::api::auth::{Authorizer, CheckAuthorisation};
|
||||
use crate::daemon::api::data::{PublisherDetails, PublisherList};
|
||||
use crate::daemon::config::Config;
|
||||
use crate::daemon::http::ssl;
|
||||
use crate::publishing::publisher_store;
|
||||
use crate::publishing::pubserver;
|
||||
use crate::publishing::pubserver::PubServer;
|
||||
use crate::daemon::publishers;
|
||||
use crate::daemon::pubserver;
|
||||
use crate::daemon::pubserver::PubServer;
|
||||
use crate::remote::sigmsg::SignedMessage;
|
||||
|
||||
const NOT_FOUND: &'static [u8] = include_bytes!("../../../static/html/404.html");
|
||||
@@ -236,7 +236,7 @@ impl PubServerApp {
|
||||
.body(res.encode_vec())
|
||||
},
|
||||
Err(pubserver::Error::PublisherStoreError
|
||||
(publisher_store::Error::UnknownPublisher(_))) => {
|
||||
(publishers::Error::UnknownPublisher(_))) => {
|
||||
Self::p404(req)
|
||||
},
|
||||
Err(e) => {
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
pub mod api;
|
||||
pub mod http;
|
||||
pub mod config;
|
||||
pub mod pubserver;
|
||||
pub mod publishers;
|
||||
pub mod responder;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
//! Responsible for storing and retrieving Publisher information.
|
||||
//! Types for tracking configured publishers.
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::fs;
|
||||
use std::fs::File;
|
||||
@@ -7,12 +8,112 @@ use std::io::BufReader;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
use rpki::uri;
|
||||
use crate::ext_serde;
|
||||
use crate::remote::id::IdCert;
|
||||
use crate::remote::oob::{PublisherRequest, PublisherRequestError};
|
||||
use crate::publishing::publisher::Publisher;
|
||||
use crate::storage::keystore::{self, Info, Key, KeyStore};
|
||||
use crate::storage::caching_ks::CachingDiskKeyStore;
|
||||
|
||||
//------------ Publisher -----------------------------------------------------
|
||||
|
||||
/// This type defines Publisher CAs that are allowed to publish.
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct Publisher {
|
||||
// The optional tag in the request. None maps to empty string.
|
||||
tag: String,
|
||||
|
||||
name: String,
|
||||
|
||||
#[serde(
|
||||
deserialize_with = "ext_serde::de_rsync_uri",
|
||||
serialize_with = "ext_serde::ser_rsync_uri")]
|
||||
base_uri: uri::Rsync,
|
||||
|
||||
#[serde(
|
||||
deserialize_with = "ext_serde::de_http_uri",
|
||||
serialize_with = "ext_serde::ser_http_uri")]
|
||||
service_uri: uri::Http,
|
||||
|
||||
#[serde(
|
||||
deserialize_with = "ext_serde::de_id_cert",
|
||||
serialize_with = "ext_serde::ser_id_cert")]
|
||||
id_cert: IdCert
|
||||
}
|
||||
|
||||
impl Publisher {
|
||||
pub fn new(
|
||||
tag: Option<String>,
|
||||
name: String,
|
||||
base_uri: uri::Rsync,
|
||||
service_uri: uri::Http,
|
||||
id_cert: IdCert
|
||||
) -> Self {
|
||||
|
||||
let tag = match tag {
|
||||
None => "".to_string(),
|
||||
Some(t) => t
|
||||
};
|
||||
|
||||
Publisher {
|
||||
tag,
|
||||
name,
|
||||
base_uri,
|
||||
service_uri,
|
||||
id_cert
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns a new Publisher that is the same as this Publisher, except
|
||||
/// that it has an updated IdCert
|
||||
pub fn with_new_id_cert(&self, id_cert: IdCert) -> Self {
|
||||
Publisher {
|
||||
tag: self.tag.clone(),
|
||||
name: self.name.clone(),
|
||||
base_uri: self.base_uri.clone(),
|
||||
service_uri: self.service_uri.clone(),
|
||||
id_cert
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Publisher {
|
||||
pub fn tag(&self) -> Option<String> {
|
||||
let tag = &self.tag;
|
||||
if tag.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(tag.clone())
|
||||
}
|
||||
}
|
||||
|
||||
pub fn name(&self) -> &String {
|
||||
&self.name
|
||||
}
|
||||
|
||||
pub fn base_uri(&self) -> &uri::Rsync {
|
||||
&self.base_uri
|
||||
}
|
||||
|
||||
pub fn service_uri(&self) -> &uri::Http {
|
||||
&self.service_uri
|
||||
}
|
||||
|
||||
pub fn id_cert(&self) -> &IdCert {
|
||||
&self.id_cert
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for Publisher {
|
||||
fn eq(&self, other: &Publisher) -> bool {
|
||||
self.name == other.name &&
|
||||
self.base_uri == other.base_uri &&
|
||||
self.service_uri == other.service_uri &&
|
||||
self.id_cert.to_bytes() == other.id_cert.to_bytes()
|
||||
}
|
||||
}
|
||||
|
||||
impl Eq for Publisher {}
|
||||
|
||||
|
||||
//------------ PublisherList -------------------------------------------------
|
||||
|
||||
@@ -303,7 +404,7 @@ pub enum Error {
|
||||
IoError(io::Error),
|
||||
|
||||
#[fail(display =
|
||||
"The '/' in publisher_handle ({}) is not supported - because we \
|
||||
"The '/' in publisher_handle ({}) is not supported - because we \
|
||||
are deriving the base directory for a publisher from this. This \
|
||||
behaviour may be updated in future.", _0)]
|
||||
ForwardSlashInHandle(String),
|
||||
@@ -558,5 +659,5 @@ mod tests {
|
||||
).is_err());
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,8 +8,7 @@ use rpki::uri;
|
||||
use rpki::x509::ValidationError;
|
||||
use crate::daemon::api::auth::Authorizer;
|
||||
use crate::daemon::responder::{self, Responder};
|
||||
use crate::publishing::publisher::Publisher;
|
||||
use crate::publishing::publisher_store::{self, PublisherStore};
|
||||
use crate::daemon::publishers::{self, Publisher, PublisherStore};
|
||||
use crate::repo::file_store;
|
||||
use crate::repo::repository::{self, Repository};
|
||||
use crate::repo::rrdp;
|
||||
@@ -248,7 +247,7 @@ pub enum Error {
|
||||
ResponderError(responder::Error),
|
||||
|
||||
#[fail(display="{}", _0)]
|
||||
PublisherStoreError(publisher_store::Error),
|
||||
PublisherStoreError(publishers::Error),
|
||||
|
||||
#[fail(display="{}", _0)]
|
||||
RepositoryError(repository::Error),
|
||||
@@ -266,8 +265,8 @@ impl From<responder::Error> for Error {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<publisher_store::Error> for Error {
|
||||
fn from(e: publisher_store::Error) -> Self {
|
||||
impl From<publishers::Error> for Error {
|
||||
fn from(e: publishers::Error) -> Self {
|
||||
Error::PublisherStoreError(e)
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ use bcder::encode::Values;
|
||||
use rpki::signing::PublicKeyAlgorithm;
|
||||
use rpki::signing::signer::{Signer, CreateKeyError, KeyUseError};
|
||||
use rpki::uri;
|
||||
use crate::publishing::publisher::Publisher;
|
||||
use crate::daemon::publishers::Publisher;
|
||||
use crate::remote::id::MyIdentity;
|
||||
use crate::remote::oob::RepositoryResponse;
|
||||
use crate::remote::publication::pubmsg::Message;
|
||||
@@ -43,9 +43,6 @@ pub struct Responder {
|
||||
// key value store for server specific stuff
|
||||
store: CachingDiskKeyStore,
|
||||
|
||||
|
||||
// TODO: Store in keystore?
|
||||
|
||||
// The URI that publishers need to access to publish (see config)
|
||||
service_uri: uri::Http,
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ extern crate untrusted;
|
||||
|
||||
pub mod client;
|
||||
pub mod daemon;
|
||||
pub mod publishing;
|
||||
pub mod remote;
|
||||
pub mod repo;
|
||||
pub mod signing;
|
||||
|
||||
@@ -1,108 +0,0 @@
|
||||
use ext_serde;
|
||||
use rpki::uri;
|
||||
use crate::remote::id::IdCert;
|
||||
|
||||
|
||||
//------------ ParentInfo ----------------------------------------------------
|
||||
|
||||
/// This type stores details about a parent publication server: in
|
||||
/// particular, its identity and where it may be contacted.
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct ParentInfo {
|
||||
publisher_handle: String,
|
||||
|
||||
#[serde(
|
||||
deserialize_with = "ext_serde::de_id_cert",
|
||||
serialize_with = "ext_serde::ser_id_cert")]
|
||||
id_cert: IdCert,
|
||||
|
||||
#[serde(
|
||||
deserialize_with = "ext_serde::de_http_uri",
|
||||
serialize_with = "ext_serde::ser_http_uri")]
|
||||
service_uri: uri::Http,
|
||||
}
|
||||
|
||||
impl ParentInfo {
|
||||
pub fn new(
|
||||
publisher_handle: String,
|
||||
id_cert: IdCert,
|
||||
service_uri: uri::Http,
|
||||
) -> Self {
|
||||
ParentInfo {
|
||||
publisher_handle,
|
||||
id_cert,
|
||||
service_uri,
|
||||
}
|
||||
}
|
||||
|
||||
/// The Identity Certificate used by the parent.
|
||||
pub fn id_cert(&self) -> &IdCert {
|
||||
&self.id_cert
|
||||
}
|
||||
|
||||
/// The service URI where the client should send requests.
|
||||
pub fn service_uri(&self) -> &uri::Http {
|
||||
&self.service_uri
|
||||
}
|
||||
|
||||
/// The name the publication server prefers to go by
|
||||
pub fn publisher_handle(&self) -> &String {
|
||||
&self.publisher_handle
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for ParentInfo {
|
||||
fn eq(&self, other: &ParentInfo) -> bool {
|
||||
self.id_cert.to_bytes() == other.id_cert.to_bytes() &&
|
||||
self.service_uri == other.service_uri &&
|
||||
self.publisher_handle == other.publisher_handle
|
||||
}
|
||||
}
|
||||
|
||||
impl Eq for ParentInfo {}
|
||||
|
||||
|
||||
//------------ MyRepoInfo ----------------------------------------------------
|
||||
|
||||
/// This type stores details about the repository URIs available to a
|
||||
/// publisher.
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct MyRepoInfo {
|
||||
#[serde(
|
||||
deserialize_with = "ext_serde::de_rsync_uri",
|
||||
serialize_with = "ext_serde::ser_rsync_uri")]
|
||||
sia_base: uri::Rsync,
|
||||
|
||||
#[serde(
|
||||
deserialize_with = "ext_serde::de_http_uri",
|
||||
serialize_with = "ext_serde::ser_http_uri")]
|
||||
notify_sia: uri::Http
|
||||
}
|
||||
|
||||
impl MyRepoInfo {
|
||||
pub fn new(
|
||||
sia_base: uri::Rsync,
|
||||
notify_sia: uri::Http
|
||||
) -> Self {
|
||||
MyRepoInfo { sia_base, notify_sia }
|
||||
}
|
||||
|
||||
/// The base rsync directory under which the publisher may publish.
|
||||
// XXX TODO: Read whether standards allow sub-dirs
|
||||
pub fn sia_base(&self) -> &uri::Rsync {
|
||||
&self.sia_base
|
||||
}
|
||||
|
||||
pub fn notify_sia(&self) -> &uri::Http {
|
||||
&self.notify_sia
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for MyRepoInfo {
|
||||
fn eq(&self, other: &MyRepoInfo) -> bool {
|
||||
self.sia_base == other.sia_base &&
|
||||
self.notify_sia == other.notify_sia
|
||||
}
|
||||
}
|
||||
|
||||
impl Eq for MyRepoInfo {}
|
||||
@@ -1,4 +0,0 @@
|
||||
pub mod info;
|
||||
pub mod publisher;
|
||||
pub mod publisher_store;
|
||||
pub mod pubserver;
|
||||
@@ -1,105 +0,0 @@
|
||||
//! Responsible for storing and retrieving Publisher information.
|
||||
use ext_serde;
|
||||
use rpki::uri;
|
||||
use crate::remote::id::IdCert;
|
||||
|
||||
|
||||
//------------ Publisher -----------------------------------------------------
|
||||
|
||||
/// This type defines Publisher CAs that are allowed to publish.
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct Publisher {
|
||||
// The optional tag in the request. None maps to empty string.
|
||||
tag: String,
|
||||
|
||||
name: String,
|
||||
|
||||
#[serde(
|
||||
deserialize_with = "ext_serde::de_rsync_uri",
|
||||
serialize_with = "ext_serde::ser_rsync_uri")]
|
||||
base_uri: uri::Rsync,
|
||||
|
||||
#[serde(
|
||||
deserialize_with = "ext_serde::de_http_uri",
|
||||
serialize_with = "ext_serde::ser_http_uri")]
|
||||
service_uri: uri::Http,
|
||||
|
||||
#[serde(
|
||||
deserialize_with = "ext_serde::de_id_cert",
|
||||
serialize_with = "ext_serde::ser_id_cert")]
|
||||
id_cert: IdCert
|
||||
}
|
||||
|
||||
impl Publisher {
|
||||
pub fn new(
|
||||
tag: Option<String>,
|
||||
name: String,
|
||||
base_uri: uri::Rsync,
|
||||
service_uri: uri::Http,
|
||||
id_cert: IdCert
|
||||
) -> Self {
|
||||
|
||||
let tag = match tag {
|
||||
None => "".to_string(),
|
||||
Some(t) => t
|
||||
};
|
||||
|
||||
Publisher {
|
||||
tag,
|
||||
name,
|
||||
base_uri,
|
||||
service_uri,
|
||||
id_cert
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns a new Publisher that is the same as this Publisher, except
|
||||
/// that it has an updated IdCert
|
||||
pub fn with_new_id_cert(&self, id_cert: IdCert) -> Self {
|
||||
Publisher {
|
||||
tag: self.tag.clone(),
|
||||
name: self.name.clone(),
|
||||
base_uri: self.base_uri.clone(),
|
||||
service_uri: self.service_uri.clone(),
|
||||
id_cert
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Publisher {
|
||||
pub fn tag(&self) -> Option<String> {
|
||||
let tag = &self.tag;
|
||||
if tag.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(tag.clone())
|
||||
}
|
||||
}
|
||||
|
||||
pub fn name(&self) -> &String {
|
||||
&self.name
|
||||
}
|
||||
|
||||
pub fn base_uri(&self) -> &uri::Rsync {
|
||||
&self.base_uri
|
||||
}
|
||||
|
||||
pub fn service_uri(&self) -> &uri::Http {
|
||||
&self.service_uri
|
||||
}
|
||||
|
||||
pub fn id_cert(&self) -> &IdCert {
|
||||
&self.id_cert
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for Publisher {
|
||||
fn eq(&self, other: &Publisher) -> bool {
|
||||
self.name == other.name &&
|
||||
self.base_uri == other.base_uri &&
|
||||
self.service_uri == other.service_uri &&
|
||||
self.id_cert.to_bytes() == other.id_cert.to_bytes()
|
||||
}
|
||||
}
|
||||
|
||||
impl Eq for Publisher {}
|
||||
@@ -7,6 +7,7 @@ use rpki::cert::{SubjectPublicKeyInfo, Validity};
|
||||
use rpki::cert::ext::{AuthorityKeyIdentifier, BasicCa, SubjectKeyIdentifier};
|
||||
use rpki::signing::SignatureAlgorithm;
|
||||
use rpki::signing::signer::KeyId;
|
||||
use rpki::uri;
|
||||
use rpki::x509::{Name, SignedData, Time, ValidationError};
|
||||
use crate::ext_serde;
|
||||
|
||||
@@ -67,6 +68,111 @@ impl PartialEq for MyIdentity {
|
||||
impl Eq for MyIdentity {}
|
||||
|
||||
|
||||
//------------ ParentInfo ----------------------------------------------------
|
||||
|
||||
/// This type stores details about a parent publication server: in
|
||||
/// particular, its identity and where it may be contacted.
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct ParentInfo {
|
||||
publisher_handle: String,
|
||||
|
||||
#[serde(
|
||||
deserialize_with = "ext_serde::de_id_cert",
|
||||
serialize_with = "ext_serde::ser_id_cert")]
|
||||
id_cert: IdCert,
|
||||
|
||||
#[serde(
|
||||
deserialize_with = "ext_serde::de_http_uri",
|
||||
serialize_with = "ext_serde::ser_http_uri")]
|
||||
service_uri: uri::Http,
|
||||
}
|
||||
|
||||
impl ParentInfo {
|
||||
pub fn new(
|
||||
publisher_handle: String,
|
||||
id_cert: IdCert,
|
||||
service_uri: uri::Http,
|
||||
) -> Self {
|
||||
ParentInfo {
|
||||
publisher_handle,
|
||||
id_cert,
|
||||
service_uri,
|
||||
}
|
||||
}
|
||||
|
||||
/// The Identity Certificate used by the parent.
|
||||
pub fn id_cert(&self) -> &IdCert {
|
||||
&self.id_cert
|
||||
}
|
||||
|
||||
/// The service URI where the client should send requests.
|
||||
pub fn service_uri(&self) -> &uri::Http {
|
||||
&self.service_uri
|
||||
}
|
||||
|
||||
/// The name the publication server prefers to go by
|
||||
pub fn publisher_handle(&self) -> &String {
|
||||
&self.publisher_handle
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for ParentInfo {
|
||||
fn eq(&self, other: &ParentInfo) -> bool {
|
||||
self.id_cert.to_bytes() == other.id_cert.to_bytes() &&
|
||||
self.service_uri == other.service_uri &&
|
||||
self.publisher_handle == other.publisher_handle
|
||||
}
|
||||
}
|
||||
|
||||
impl Eq for ParentInfo {}
|
||||
|
||||
|
||||
//------------ MyRepoInfo ----------------------------------------------------
|
||||
|
||||
/// This type stores details about the repository URIs available to a
|
||||
/// publisher.
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct MyRepoInfo {
|
||||
#[serde(
|
||||
deserialize_with = "ext_serde::de_rsync_uri",
|
||||
serialize_with = "ext_serde::ser_rsync_uri")]
|
||||
sia_base: uri::Rsync,
|
||||
|
||||
#[serde(
|
||||
deserialize_with = "ext_serde::de_http_uri",
|
||||
serialize_with = "ext_serde::ser_http_uri")]
|
||||
notify_sia: uri::Http
|
||||
}
|
||||
|
||||
impl MyRepoInfo {
|
||||
pub fn new(
|
||||
sia_base: uri::Rsync,
|
||||
notify_sia: uri::Http
|
||||
) -> Self {
|
||||
MyRepoInfo { sia_base, notify_sia }
|
||||
}
|
||||
|
||||
/// The base rsync directory under which the publisher may publish.
|
||||
// XXX TODO: Read whether standards allow sub-dirs
|
||||
pub fn sia_base(&self) -> &uri::Rsync {
|
||||
&self.sia_base
|
||||
}
|
||||
|
||||
pub fn notify_sia(&self) -> &uri::Http {
|
||||
&self.notify_sia
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for MyRepoInfo {
|
||||
fn eq(&self, other: &MyRepoInfo) -> bool {
|
||||
self.sia_base == other.sia_base &&
|
||||
self.notify_sia == other.notify_sia
|
||||
}
|
||||
}
|
||||
|
||||
impl Eq for MyRepoInfo {}
|
||||
|
||||
|
||||
//------------ IdCert --------------------------------------------------------
|
||||
|
||||
/// An Identity Certificate.
|
||||
|
||||
Reference in New Issue
Block a user