Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3113718
D3812.id12143.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
13 KB
Referenced Files
None
Subscribers
None
D3812.id12143.diff
View Options
diff --git a/services/identity/Cargo.lock b/services/identity/Cargo.lock
--- a/services/identity/Cargo.lock
+++ b/services/identity/Cargo.lock
@@ -13,9 +13,9 @@
[[package]]
name = "anyhow"
-version = "1.0.56"
+version = "1.0.57"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4361135be9122e0870de935d7c439aef945b9f9ddd4199a553b5270b49c82a27"
+checksum = "08f9b8508dccb7687a1d6c4ce66b2b0ecef467c94667de27d8d7fe1f8d2a9cdc"
[[package]]
name = "argon2"
@@ -122,6 +122,12 @@
"generic-array",
]
+[[package]]
+name = "bumpalo"
+version = "3.9.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a4a45a46ab1f2412e53d3a0ade76ffad2025804294569aae387231a0cd6e0899"
+
[[package]]
name = "byteorder"
version = "1.4.3"
@@ -185,6 +191,12 @@
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc"
+[[package]]
+name = "convert_case"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e"
+
[[package]]
name = "cpufeatures"
version = "0.2.2"
@@ -227,6 +239,19 @@
"zeroize",
]
+[[package]]
+name = "derive_more"
+version = "0.99.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321"
+dependencies = [
+ "convert_case",
+ "proc-macro2",
+ "quote",
+ "rustc_version",
+ "syn",
+]
+
[[package]]
name = "digest"
version = "0.9.0"
@@ -352,15 +377,17 @@
checksum = "9be70c98951c83b8d2f8f60d7065fa6d5146873094452a1008da8c2f1e4205ad"
dependencies = [
"cfg-if",
+ "js-sys",
"libc",
"wasi 0.10.2+wasi-snapshot-preview1",
+ "wasm-bindgen",
]
[[package]]
name = "h2"
-version = "0.3.12"
+version = "0.3.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "62eeb471aa3e3c9197aa4bfeabfe02982f6dc96f750486c0bb0009ac58b26d2b"
+checksum = "37a82c6d637fc9515a4694bbf1cb2457b79d81ce52b3108bdeea58b07dd34a57"
dependencies = [
"bytes",
"fnv",
@@ -371,7 +398,7 @@
"indexmap",
"slab",
"tokio",
- "tokio-util 0.6.9",
+ "tokio-util 0.7.1",
"tracing",
]
@@ -427,9 +454,9 @@
[[package]]
name = "http"
-version = "0.2.6"
+version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "31f4c6746584866f0feabcc69893c5b51beef3831656a968ed7ae254cdc4fd03"
+checksum = "ff8670570af52249509a86f5e3e18a08c60b177071826898fde8997cf5f6bfbb"
dependencies = [
"bytes",
"fnv",
@@ -449,9 +476,9 @@
[[package]]
name = "httparse"
-version = "1.6.0"
+version = "1.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9100414882e15fb7feccb4897e5f0ff0ff1ca7d1a86a23208ada4d7a18e6c6c4"
+checksum = "496ce29bb5a52785b44e0f7ca2847ae0bb839c9bd28f69acac9b99d461c0c04c"
[[package]]
name = "httpdate"
@@ -502,6 +529,7 @@
"argon2",
"clap",
"curve25519-dalek",
+ "derive_more",
"digest 0.9.0",
"futures-core",
"opaque-ke",
@@ -546,6 +574,15 @@
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35"
+[[package]]
+name = "js-sys"
+version = "0.3.57"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "671a26f820db17c2a2750743f1dd03bafd15b98c9f30c7c2628c024c05d73397"
+dependencies = [
+ "wasm-bindgen",
+]
+
[[package]]
name = "lazy_static"
version = "1.4.0"
@@ -554,9 +591,9 @@
[[package]]
name = "libc"
-version = "0.2.121"
+version = "0.2.125"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "efaa7b300f3b5fe8eb6bf21ce3895e1751d9665086af2d64b42f19701015ff4f"
+checksum = "5916d2ae698f6de9bfb891ad7a8d65c09d232dc58cc4ac433c7da3b2fd84bc2b"
[[package]]
name = "log"
@@ -569,9 +606,9 @@
[[package]]
name = "memchr"
-version = "2.4.1"
+version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a"
+checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
[[package]]
name = "mio"
@@ -621,6 +658,12 @@
"libc",
]
+[[package]]
+name = "once_cell"
+version = "1.10.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9"
+
[[package]]
name = "opaque-debug"
version = "0.3.0"
@@ -638,6 +681,7 @@
"digest 0.9.0",
"displaydoc",
"generic-array",
+ "getrandom 0.2.6",
"hkdf",
"hmac",
"rand",
@@ -700,9 +744,9 @@
[[package]]
name = "pin-project-lite"
-version = "0.2.8"
+version = "0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e280fbe77cc62c91527259e9442153f4688736748d24660126286329742b4c6c"
+checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116"
[[package]]
name = "pin-utils"
@@ -742,9 +786,9 @@
[[package]]
name = "proc-macro2"
-version = "1.0.36"
+version = "1.0.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029"
+checksum = "ec757218438d5fda206afc041538b2f6d889286160d649a86a24d37e1235afd1"
dependencies = [
"unicode-xid",
]
@@ -804,9 +848,9 @@
[[package]]
name = "quote"
-version = "1.0.17"
+version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "632d02bff7f874a36f33ea8bb416cd484b90cc66c1194b1a1110d067a7013f58"
+checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1"
dependencies = [
"proc-macro2",
]
@@ -885,6 +929,21 @@
"winapi",
]
+[[package]]
+name = "rustc_version"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366"
+dependencies = [
+ "semver",
+]
+
+[[package]]
+name = "semver"
+version = "1.0.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8cb243bdfdb5936c8dc3c45762a19d12ab4550cdc753bc247637d4ec35a040fd"
+
[[package]]
name = "sha2"
version = "0.9.9"
@@ -900,9 +959,9 @@
[[package]]
name = "slab"
-version = "0.4.5"
+version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9def91fd1e018fe007022791f865d0ccc9b3a0d5001e01aabb8b40e46000afb5"
+checksum = "eb703cfe953bccee95685111adeedb76fabe4e97549a58d16f03ea7b9367bb32"
[[package]]
name = "socket2"
@@ -928,9 +987,9 @@
[[package]]
name = "syn"
-version = "1.0.90"
+version = "1.0.92"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "704df27628939572cd88d33f171cd6f896f4eaca85252c6e0a72d8d8287ee86f"
+checksum = "7ff7c592601f11445996a06f8ad0c27f094a58857c2f89e97974ab9235b92c52"
dependencies = [
"proc-macro2",
"quote",
@@ -980,15 +1039,16 @@
[[package]]
name = "tokio"
-version = "1.17.0"
+version = "1.18.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2af73ac49756f3f7c01172e34a23e5d0216f6c32333757c2c61feb2bbff5a5ee"
+checksum = "dce653fb475565de9f6fb0614b28bca8df2c430c0cf84bcd9c843f15de5414cc"
dependencies = [
"bytes",
"libc",
"memchr",
"mio",
"num_cpus",
+ "once_cell",
"pin-project-lite",
"socket2",
"tokio-macros",
@@ -1052,6 +1112,7 @@
"futures-sink",
"pin-project-lite",
"tokio",
+ "tracing",
]
[[package]]
@@ -1131,9 +1192,9 @@
[[package]]
name = "tracing"
-version = "0.1.32"
+version = "0.1.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4a1bdf54a7c28a2bbf701e1d2233f6c77f473486b94bee4f9678da5a148dca7f"
+checksum = "5d0ecdcb44a79f0fe9844f0c4f33a342cbcbb5117de8001e6ba0dc2351327d09"
dependencies = [
"cfg-if",
"log",
@@ -1144,9 +1205,9 @@
[[package]]
name = "tracing-attributes"
-version = "0.1.20"
+version = "0.1.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2e65ce065b4b5c53e73bb28912318cb8c9e9ad3921f1d669eb0e68b4c8143a2b"
+checksum = "cc6b8ad3567499f98a1db7a752b07a7c8c7c7c34c332ec00effb2b0027974b7c"
dependencies = [
"proc-macro2",
"quote",
@@ -1155,9 +1216,9 @@
[[package]]
name = "tracing-core"
-version = "0.1.23"
+version = "0.1.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "aa31669fa42c09c34d94d8165dd2012e8ff3c66aca50f3bb226b68f216f2706c"
+checksum = "f54c8ca710e81886d498c2fd3331b56c93aa248d49de2222ad2742247c60072f"
dependencies = [
"lazy_static",
]
@@ -1192,9 +1253,9 @@
[[package]]
name = "unicode-xid"
-version = "0.2.2"
+version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
+checksum = "957e51f3646910546462e67d5f7599b9e4fb8acdd304b087a6494730f9eebf04"
[[package]]
name = "version_check"
@@ -1230,6 +1291,60 @@
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
+[[package]]
+name = "wasm-bindgen"
+version = "0.2.80"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "27370197c907c55e3f1a9fbe26f44e937fe6451368324e009cba39e139dc08ad"
+dependencies = [
+ "cfg-if",
+ "wasm-bindgen-macro",
+]
+
+[[package]]
+name = "wasm-bindgen-backend"
+version = "0.2.80"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "53e04185bfa3a779273da532f5025e33398409573f348985af9a1cbf3774d3f4"
+dependencies = [
+ "bumpalo",
+ "lazy_static",
+ "log",
+ "proc-macro2",
+ "quote",
+ "syn",
+ "wasm-bindgen-shared",
+]
+
+[[package]]
+name = "wasm-bindgen-macro"
+version = "0.2.80"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "17cae7ff784d7e83a2fe7611cfe766ecf034111b49deb850a3dc7699c08251f5"
+dependencies = [
+ "quote",
+ "wasm-bindgen-macro-support",
+]
+
+[[package]]
+name = "wasm-bindgen-macro-support"
+version = "0.2.80"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "99ec0dc7a4756fffc231aab1b9f2f578d23cd391390ab27f952ae0c9b3ece20b"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+ "wasm-bindgen-backend",
+ "wasm-bindgen-shared",
+]
+
+[[package]]
+name = "wasm-bindgen-shared"
+version = "0.2.80"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d554b7f530dee5964d9a9468d95c1f8b8acae4f282807e7d27d4b03099a46744"
+
[[package]]
name = "which"
version = "4.2.5"
diff --git a/services/identity/Cargo.toml b/services/identity/Cargo.toml
--- a/services/identity/Cargo.toml
+++ b/services/identity/Cargo.toml
@@ -8,12 +8,13 @@
prost = "0.9"
futures-core = "0.3"
tokio = { version = "1.0", features = ["macros", "rt-multi-thread"] }
-opaque-ke = "1.2.0"
+opaque-ke = { version = "1.2.0", features = ["std"] }
argon2 = "0.3"
curve25519-dalek = "3"
sha2 = "0.9"
digest = "0.9"
clap = { version = "3.1.12", features = ["derive"] }
+derive_more = "0.99"
[build-dependencies]
tonic-build = "0.6"
diff --git a/services/identity/src/config.rs b/services/identity/src/config.rs
new file mode 100644
--- /dev/null
+++ b/services/identity/src/config.rs
@@ -0,0 +1,32 @@
+use opaque_ke::{errors::PakeError, keypair::Key};
+use std::{env, fs, io, path::Path};
+
+#[derive(Default, Debug)]
+pub struct Config {
+ server_secret_key: Option<Key>,
+}
+
+impl Config {
+ pub fn load() -> Result<Self, Error> {
+ let mut path = env::current_dir()?;
+ path.push("secrets");
+ path.push("secret_key");
+ let key = get_key_from_file(path)?;
+ Ok(Self {
+ server_secret_key: Some(key),
+ })
+ }
+}
+
+#[derive(Debug, derive_more::Display, derive_more::From, derive_more::Error)]
+pub enum Error {
+ #[display(...)]
+ Pake(PakeError),
+ #[display(...)]
+ IO(io::Error),
+}
+
+fn get_key_from_file<P: AsRef<Path>>(path: P) -> Result<Key, Error> {
+ let bytes = fs::read(path)?;
+ Key::from_bytes(&bytes).map_err(|e| Error::Pake(e))
+}
diff --git a/services/identity/src/main.rs b/services/identity/src/main.rs
--- a/services/identity/src/main.rs
+++ b/services/identity/src/main.rs
@@ -1,10 +1,12 @@
use clap::{Parser, Subcommand};
use tonic::transport::Server;
+mod config;
mod keygen;
mod opaque;
mod service;
+use config::Config;
use keygen::generate_and_persist_keypair;
use service::{IdentityServiceServer, MyIdentityService};
@@ -40,8 +42,8 @@
}
Commands::Server => {
let addr = IDENTITY_SERVICE_SOCKET_ADDR.parse()?;
- let identity_service = MyIdentityService::default();
-
+ let config = Config::load()?;
+ let identity_service = MyIdentityService::new(config);
Server::builder()
.add_service(IdentityServiceServer::new(identity_service))
.serve(addr)
diff --git a/services/identity/src/service.rs b/services/identity/src/service.rs
--- a/services/identity/src/service.rs
+++ b/services/identity/src/service.rs
@@ -2,6 +2,8 @@
use std::pin::Pin;
use tonic::{Request, Response, Status};
+use crate::config::Config;
+
pub use proto::identity_service_server::IdentityServiceServer;
use proto::{
identity_service_server::IdentityService, LoginRequest, LoginResponse, RegistrationRequest,
@@ -12,8 +14,10 @@
tonic::include_proto!("identity");
}
-#[derive(Debug, Default)]
-pub struct MyIdentityService {}
+#[derive(Debug, derive_more::Constructor)]
+pub struct MyIdentityService {
+ pub config: Config,
+}
#[tonic::async_trait]
impl IdentityService for MyIdentityService {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 1, 6:27 PM (21 h, 43 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2400507
Default Alt Text
D3812.id12143.diff (13 KB)
Attached To
Mode
D3812: [Identity] Add config for Identity service
Attached
Detach File
Event Timeline
Log In to Comment