Skip to content

Commit 676509c

Browse files
committed
Add an authenticator section in the configuration
Signed-off-by: Hugues de Valon <[email protected]>
1 parent 1c38ee8 commit 676509c

File tree

12 files changed

+105
-36
lines changed

12 files changed

+105
-36
lines changed

Cargo.lock

Lines changed: 30 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,19 @@ timeout = 200 # in milliseconds
5151
# socket file.
5252
#socket_path = "/run/parsec/parsec.sock"
5353

54+
# (Required) Authenticator configuration.
55+
# WARNING: the authenticator MUST NOT be changed if there are existing keys stored in Parsec.
56+
# In a future version, Parsec might support multiple authenticators, see parallaxsecond/parsec#271
57+
# for details.
58+
[authenticator]
59+
# (Required) Type of authenticator that will be used to authenticate clients' authentication
60+
# payloads.
61+
# Possible values: "Direct" and "UnixPeerCredentials".
62+
# WARNING: The "Direct" authenticator is only secure under specific requirements. Please make sure
63+
# to read the Recommendations on a Secure Parsec Deployment at
64+
# https://parallaxsecond.github.io/parsec-book/parsec_security/secure_deployment.html
65+
auth_type = "UnixPeerCredentials"
66+
5467
# (Required) Configuration for the components managing key info for providers.
5568
# Defined as an array of tables: https://github.com/toml-lang/toml#user-content-array-of-tables
5669
[[key_manager]]

e2e_tests/provider_cfg/all/config.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ listener_type = "DomainSocket"
1212
timeout = 200 # in milliseconds
1313
socket_path = "/tmp/parsec.sock"
1414

15+
[authenticator]
16+
auth_type = "Direct"
17+
1518
[[key_manager]]
1619
name = "on-disk-manager"
1720
manager_type = "OnDisk"

e2e_tests/provider_cfg/mbed-crypto/config.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ listener_type = "DomainSocket"
1414
timeout = 3000 # in milliseconds
1515
socket_path = "/tmp/parsec.sock"
1616

17+
[authenticator]
18+
auth_type = "Direct"
19+
1720
[[key_manager]]
1821
name = "on-disk-manager"
1922
manager_type = "OnDisk"

e2e_tests/provider_cfg/pkcs11/config.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ listener_type = "DomainSocket"
1414
timeout = 3000 # in milliseconds
1515
socket_path = "/tmp/parsec.sock"
1616

17+
[authenticator]
18+
auth_type = "Direct"
19+
1720
[[key_manager]]
1821
name = "on-disk-manager"
1922
manager_type = "OnDisk"

e2e_tests/provider_cfg/tpm/config.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ listener_type = "DomainSocket"
1414
timeout = 3000 # in milliseconds
1515
socket_path = "/tmp/parsec.sock"
1616

17+
[authenticator]
18+
auth_type = "Direct"
19+
1720
[[key_manager]]
1821
name = "on-disk-manager"
1922
manager_type = "OnDisk"

e2e_tests/tests/config/tomls/list_providers_1.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ listener_type = "DomainSocket"
88
timeout = 200 # in milliseconds
99
socket_path = "/tmp/parsec.sock"
1010

11+
[authenticator]
12+
auth_type = "Direct"
13+
1114
[[key_manager]]
1215
name = "on-disk-manager"
1316
manager_type = "OnDisk"

e2e_tests/tests/config/tomls/list_providers_2.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ listener_type = "DomainSocket"
88
timeout = 200 # in milliseconds
99
socket_path = "/tmp/parsec.sock"
1010

11+
[authenticator]
12+
auth_type = "Direct"
13+
1114
[[key_manager]]
1215
name = "on-disk-manager"
1316
manager_type = "OnDisk"

e2e_tests/tests/config/tomls/pkcs11_software.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ listener_type = "DomainSocket"
1414
timeout = 3000 # in milliseconds
1515
socket_path = "/tmp/parsec.sock"
1616

17+
[authenticator]
18+
auth_type = "Direct"
19+
1720
[[key_manager]]
1821
name = "on-disk-manager"
1922
manager_type = "OnDisk"

fuzz/config.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ listener_type = "DomainSocket"
55
timeout = 200 # in milliseconds
66
socket_path = "/tmp/parsec.sock"
77

8+
[authenticator]
9+
auth_type = "Direct"
10+
811
[[key_manager]]
912
name = "on-disk-manager"
1013
manager_type = "OnDisk"

src/authenticators/mod.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ use crate::front::listener::ConnectionMetadata;
1717
use parsec_interface::operations::list_authenticators;
1818
use parsec_interface::requests::request::RequestAuth;
1919
use parsec_interface::requests::Result;
20+
use serde::Deserialize;
21+
use zeroize::Zeroize;
2022

2123
/// String wrapper for app names
2224
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
@@ -64,3 +66,14 @@ impl std::fmt::Display for ApplicationName {
6466
write!(f, "{}", self.0)
6567
}
6668
}
69+
70+
/// Authenticator configuration structure
71+
#[derive(Copy, Clone, Deserialize, Debug, Zeroize)]
72+
#[zeroize(drop)]
73+
#[serde(tag = "auth_type")]
74+
pub enum AuthenticatorConfig {
75+
/// Direct authentication
76+
Direct,
77+
/// Unix Peer Credenditals authentication
78+
UnixPeerCredentials,
79+
}

src/utils/service_builder.rs

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
//! provided configuration.
77
use super::global_config::GlobalConfigBuilder;
88
use crate::authenticators::direct_authenticator::DirectAuthenticator;
9-
use crate::authenticators::Authenticate;
9+
use crate::authenticators::unix_peer_credentials_authenticator::UnixPeerCredentialsAuthenticator;
10+
use crate::authenticators::{Authenticate, AuthenticatorConfig};
1011
use crate::back::{
1112
backend_handler::{BackEndHandler, BackEndHandlerBuilder},
1213
dispatcher::DispatcherBuilder,
@@ -85,6 +86,7 @@ pub struct CoreSettings {
8586
pub struct ServiceConfig {
8687
pub core_settings: CoreSettings,
8788
pub listener: ListenerConfig,
89+
pub authenticator: AuthenticatorConfig,
8890
pub key_manager: Option<Vec<KeyInfoManagerConfig>>,
8991
pub provider: Option<Vec<ProviderConfig>>,
9092
}
@@ -130,11 +132,7 @@ impl ServiceBuilder {
130132
return Err(Error::new(ErrorKind::InvalidData, "need one provider").into());
131133
}
132134

133-
// The authenticators supported by the Parsec service.
134-
// NOTE: order here is important. The order in which the elements are added here is the
135-
// order in which they will be returned to any client requesting them!
136-
let mut authenticators: Vec<(AuthType, Authenticator)> = Vec::new();
137-
authenticators.push((AuthType::Direct, Box::from(DirectAuthenticator {})));
135+
let authenticators = build_authenticators(&config.authenticator);
138136

139137
let backend_handlers = build_backend_handlers(providers, &authenticators)?;
140138

@@ -364,3 +362,24 @@ fn get_key_info_manager(config: &KeyInfoManagerConfig) -> Result<KeyInfoManager>
364362

365363
Ok(Arc::new(RwLock::new(manager)))
366364
}
365+
366+
fn build_authenticators(config: &AuthenticatorConfig) -> Vec<(AuthType, Authenticator)> {
367+
// The authenticators supported by the Parsec service.
368+
// NOTE: order here is important. The order in which the elements are added here is the
369+
// order in which they will be returned to any client requesting them!
370+
// Currently only one authenticator is allowed by the Parsec service
371+
// See parallaxsecond/parsec#271
372+
let mut authenticators: Vec<(AuthType, Authenticator)> = Vec::new();
373+
374+
match config {
375+
AuthenticatorConfig::Direct => {
376+
authenticators.push((AuthType::Direct, Box::from(DirectAuthenticator {})))
377+
}
378+
AuthenticatorConfig::UnixPeerCredentials => authenticators.push((
379+
AuthType::UnixPeerCredentials,
380+
Box::from(UnixPeerCredentialsAuthenticator {}),
381+
)),
382+
};
383+
384+
authenticators
385+
}

0 commit comments

Comments
 (0)