@@ -82,6 +82,11 @@ static ACCEPTED_KEYS: Lazy<Vec<Value>> = Lazy::new(|| {
82
82
"actions" : [ "search" ] ,
83
83
"expiresAt" : ( OffsetDateTime :: now_utc( ) + Duration :: days( 1 ) ) . format( & Rfc3339 ) . unwrap( )
84
84
} ) ,
85
+ json!( {
86
+ "indexes" : [ "sal*" , "prod*" ] ,
87
+ "actions" : [ "search" ] ,
88
+ "expiresAt" : ( OffsetDateTime :: now_utc( ) + Duration :: days( 1 ) ) . format( & Rfc3339 ) . unwrap( )
89
+ } ) ,
85
90
]
86
91
} ) ;
87
92
@@ -104,6 +109,11 @@ static REFUSED_KEYS: Lazy<Vec<Value>> = Lazy::new(|| {
104
109
"actions" : [ "*" ] ,
105
110
"expiresAt" : ( OffsetDateTime :: now_utc( ) + Duration :: days( 1 ) ) . format( & Rfc3339 ) . unwrap( )
106
111
} ) ,
112
+ json!( {
113
+ "indexes" : [ "prod*" , "p*" ] ,
114
+ "actions" : [ "*" ] ,
115
+ "expiresAt" : ( OffsetDateTime :: now_utc( ) + Duration :: days( 1 ) ) . format( & Rfc3339 ) . unwrap( )
116
+ } ) ,
107
117
json!( {
108
118
"indexes" : [ "products" ] ,
109
119
"actions" : [ "search" ] ,
@@ -245,6 +255,10 @@ async fn search_authorized_simple_token() {
245
255
"searchRules" => json!( [ "sales" ] ) ,
246
256
"exp" => Value :: Null
247
257
} ,
258
+ hashmap! {
259
+ "searchRules" => json!( [ "sa*" ] ) ,
260
+ "exp" => Value :: Null
261
+ } ,
248
262
] ;
249
263
250
264
compute_authorized_search ! ( tenant_tokens, { } , 5 ) ;
@@ -351,11 +365,19 @@ async fn filter_search_authorized_filter_token() {
351
365
} ) ,
352
366
"exp" => json!( ( OffsetDateTime :: now_utc( ) + Duration :: hours( 1 ) ) . unix_timestamp( ) )
353
367
} ,
368
+ hashmap! {
369
+ "searchRules" => json!( {
370
+ "*" : { } ,
371
+ "sal*" : { "filter" : [ "color = blue" ] }
372
+ } ) ,
373
+ "exp" => json!( ( OffsetDateTime :: now_utc( ) + Duration :: hours( 1 ) ) . unix_timestamp( ) )
374
+ } ,
354
375
] ;
355
376
356
377
compute_authorized_search ! ( tenant_tokens, "color = yellow" , 1 ) ;
357
378
}
358
379
380
+ /// Tests that those Tenant Token are incompatible with the REFUSED_KEYS defined above.
359
381
#[ actix_rt:: test]
360
382
async fn error_search_token_forbidden_parent_key ( ) {
361
383
let tenant_tokens = vec ! [
@@ -383,6 +405,10 @@ async fn error_search_token_forbidden_parent_key() {
383
405
"searchRules" => json!( [ "sales" ] ) ,
384
406
"exp" => json!( ( OffsetDateTime :: now_utc( ) + Duration :: hours( 1 ) ) . unix_timestamp( ) )
385
407
} ,
408
+ hashmap! {
409
+ "searchRules" => json!( [ "sali*" , "s*" , "sales*" ] ) ,
410
+ "exp" => json!( ( OffsetDateTime :: now_utc( ) + Duration :: hours( 1 ) ) . unix_timestamp( ) )
411
+ } ,
386
412
] ;
387
413
388
414
compute_forbidden_search ! ( tenant_tokens, REFUSED_KEYS ) ;
0 commit comments