Skip to content

Commit b1d58e3

Browse files
authored
Fix token id format (#69)
* Fix token id format * Fix AI comments
1 parent d8c5d2e commit b1d58e3

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ regex = "1.11.1"
3333
futures-util = "0.3.31"
3434
env_filter = "0.1.3"
3535
josekit = "0.10.3"
36+
md5 = "0.8.0"
3637

3738
# Open Telemetry dependencies
3839
opentelemetry = "0.30.0"

src/services/audit/events/token_validation_event.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,29 @@ pub struct TokenValidationEvent {
99
}
1010

1111
impl TokenValidationEvent {
12-
pub fn internal(token_id: String, is_successful: bool, details: HashSet<String>) -> Self {
12+
pub fn internal(token: &str, is_successful: bool, details: HashSet<String>) -> Self {
13+
let token_hash = md5::compute(token);
1314
Self {
14-
token_id,
15+
token_id: format!("md5:{:x}", token_hash),
1516
result: make_result(is_successful),
1617
reason_errors: details,
1718
token_type: "internal".to_string(),
1819
}
1920
}
2021

21-
pub fn external(token_id: String, is_successful: bool, details: HashSet<String>) -> Self {
22+
pub fn external(token: &str, is_successful: bool, details: HashSet<String>) -> Self {
23+
let token_hash = md5::compute(token);
2224
Self {
23-
token_id,
25+
token_id: format!("md5:{:x}", token_hash),
26+
result: make_result(is_successful),
27+
reason_errors: details,
28+
token_type: "external".to_string(),
29+
}
30+
}
31+
32+
pub fn external_empty(is_successful: bool, details: HashSet<String>) -> Self {
33+
Self {
34+
token_id: "token-not-provided".to_string(),
2435
result: make_result(is_successful),
2536
reason_errors: details,
2637
token_type: "external".to_string(),

0 commit comments

Comments
 (0)