Page MenuHomePhorge

D3959.1765313279.diff
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

D3959.1765313279.diff

diff --git a/services/identity/Cargo.lock b/services/identity/Cargo.lock
--- a/services/identity/Cargo.lock
+++ b/services/identity/Cargo.lock
@@ -694,6 +694,7 @@
"futures-core",
"opaque-ke",
"prost",
+ "rand",
"rusoto_core",
"rusoto_dynamodb",
"sha2",
diff --git a/services/identity/Cargo.toml b/services/identity/Cargo.toml
--- a/services/identity/Cargo.toml
+++ b/services/identity/Cargo.toml
@@ -20,6 +20,7 @@
tracing = "0.1"
tracing-subscriber = "0.3"
chrono = "0.4.19"
+rand = "0.8"
[build-dependencies]
tonic-build = "0.6"
diff --git a/services/identity/src/token.rs b/services/identity/src/token.rs
--- a/services/identity/src/token.rs
+++ b/services/identity/src/token.rs
@@ -1,4 +1,8 @@
use chrono::{DateTime, Utc};
+use rand::{
+ distributions::{Alphanumeric, DistString},
+ CryptoRng, Rng,
+};
pub enum AuthType {
Password,
@@ -11,3 +15,14 @@
pub auth_type: Option<AuthType>,
pub valid: Option<bool>,
}
+
+impl AccessToken {
+ pub fn new(auth_type: AuthType, rng: &mut (impl Rng + CryptoRng)) -> Self {
+ AccessToken {
+ token: Some(Alphanumeric.sample_string(rng, 512)),
+ created: Some(Utc::now()),
+ auth_type: Some(auth_type),
+ valid: Some(true),
+ }
+ }
+}

File Metadata

Mime Type
text/plain
Expires
Tue, Dec 9, 8:47 PM (9 h, 9 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5857748
Default Alt Text
D3959.1765313279.diff (1 KB)

Event Timeline