@@ -8,8 +8,8 @@ use biscuit_auth::{
8
8
use chrono:: offset:: Utc ;
9
9
use serde:: Serialize ;
10
10
use serde_json:: json;
11
- use std:: path:: PathBuf ;
12
11
use std:: { fmt:: Display , fs} ;
12
+ use std:: { path:: PathBuf , time:: Duration } ;
13
13
14
14
use crate :: cli:: * ;
15
15
use crate :: errors:: CliError :: * ;
@@ -127,17 +127,29 @@ impl Display for QueryResult {
127
127
struct AuthResult {
128
128
policies : Vec < String > ,
129
129
result : RResult < ( usize , String ) , Token > ,
130
+ iterations : u64 ,
131
+ elapsed : Duration ,
130
132
}
131
133
132
134
impl Display for AuthResult {
133
135
fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
134
136
match & self . result . clone ( ) . into_result ( ) {
135
137
Ok ( ( _, policy) ) => {
136
- writeln ! ( f, "✅ Authorizer check succeeded 🛡️" ) ?;
138
+ writeln ! (
139
+ f,
140
+ "✅ Authorizer check succeeded 🛡️ ({}μs, {} iterations)" ,
141
+ self . elapsed. as_micros( ) ,
142
+ self . iterations,
143
+ ) ?;
137
144
writeln ! ( f, "Matched allow policy: {}" , policy)
138
145
}
139
146
Err ( e) => {
140
- writeln ! ( f, "❌ Authorizer check failed 🛡️" ) ?;
147
+ writeln ! (
148
+ f,
149
+ "❌ Authorizer check failed 🛡️ ({}μs, {} iterations)" ,
150
+ self . elapsed. as_micros( ) ,
151
+ self . iterations,
152
+ ) ?;
141
153
match e {
142
154
Token :: FailedLogic ( l) => display_logic_error ( f, & self . policies , l) ,
143
155
Token :: RunLimit ( l) => display_run_limit ( f, l) ,
@@ -445,6 +457,8 @@ pub fn handle_inspect_inner(inspect: &Inspect) -> Result<InspectionResults> {
445
457
)
446
458
} )
447
459
. into ( ) ,
460
+ iterations : authorizer_builder. iterations ( ) ,
461
+ elapsed : authorizer_builder. execution_time ( ) ,
448
462
} ) ;
449
463
450
464
if let Some ( snapshot_file) = & inspect. dump_snapshot_to {
@@ -600,6 +614,8 @@ pub fn handle_inspect_snapshot_inner(
600
614
)
601
615
} )
602
616
. into ( ) ,
617
+ iterations : authorizer. iterations ( ) ,
618
+ elapsed : authorizer. execution_time ( ) ,
603
619
} ) ;
604
620
} else {
605
621
auth_result = None ;
0 commit comments