@@ -422,8 +422,8 @@ following JSON structure, indicating whether the request is allowed, and any reg
422
422
{
423
423
"name" : " chr1" ,
424
424
"format" : " BAM" ,
425
- "start" : 100 ,
426
- "end" : 1000
425
+ "start" : 1000 ,
426
+ "end" : 2000
427
427
}
428
428
]
429
429
}
@@ -439,18 +439,18 @@ An [example][auth-example] configuration file is available in the examples direc
439
439
With this authorization logic, the server will respond with a ` 403 Forbidden ` error if any of the requested reference
440
440
names are not allowed according to the restrictions. For example, if using the above JSON restrictions, a user
441
441
requesting ` ?referenceName=chr1&format=BAM&start=500&end=1500 ` will receive a ` 403 ` error, even though part of the range
442
- is satisfiable (i.e. according to the restrictions, from ` start=500 ` to ` end=1000 ` ). In order to address this issue, the
442
+ is satisfiable (i.e. according to the restrictions, from ` start=1000 ` to ` end=1500 ` ). In order to address this issue, the
443
443
following flag can be enabled under the ` auth ` table:
444
444
445
445
| Option | Description | Type | Default |
446
446
| -------------------| --------------------------------------------------------------------------------------------------| ---------| ---------|
447
447
| ` suppress_errors ` | Return any available regions according to restrictions, even if the full request is not allowed. | Boolean | ` false ` |
448
448
| ` add_hint ` | Add a hint to the ticket response that indicates which regions the client is allowed to view. | Boolean | ` true ` |
449
449
450
- To enable this option, htsget-rs needs to be compiled with ` --features experimental ` as suppressed errors may lead to
451
- less regions being returned than requested , which may not follow the htsget protocol. When this option is used, the
452
- above example with the request: ` ?referenceName=chr1&format=BAM&start=500&end=1500 ` , would return reads between ` start=500 `
453
- and ` end=1000 ` for the reference name. Additionally, there will be another field present in the JSON response which hints
450
+ To enable this option, htsget-rs needs to be compiled with ` --features experimental ` as suppressed errors lead to as
451
+ many regions as possible being returned , which may not follow the htsget protocol. When this option is used, the
452
+ above example with the request: ` ?referenceName=chr1&format=BAM&start=500&end=1500 ` , would return reads between ` start=1000 `
453
+ and ` end=1500 ` for the reference name. Additionally, there will be another field present in the JSON response which hints
454
454
to clients that the full range was not satisfied because of authorization restrictions:
455
455
456
456
``` json
@@ -462,22 +462,43 @@ to clients that the full range was not satisfied because of authorization restri
462
462
{
463
463
"name" : " chr1" ,
464
464
"format" : " BAM" ,
465
- "start" : 100 ,
466
- "end" : 1000
465
+ "start" : 1000 ,
466
+ "end" : 2000
467
467
}
468
468
]
469
469
}
470
470
}
471
471
```
472
472
473
473
The ` allowed ` field echos the rule defined in the restrictions, and allows clients to plan for a partially returned
474
- response. This field can be removed by setting ` add_hint = false ` in the ` auth ` table.
474
+ response. This field can be removed by setting ` add_hint = false ` in the ` auth ` table.
475
+
476
+ The following diagram shows how the suppressed response behaves given restrictions based on the start and end restrictions
477
+ and the requested range. The response shows the data that the user will receive.
478
+
479
+ ```
480
+ Restriction: 1000----------2000
481
+ Request: 500------------1500
482
+ Resulting response: 1000---1500
483
+
484
+ Restriction: 1000----------2000
485
+ Request: 1500------------2500
486
+ Resulting response: 1500---2000
487
+
488
+ Restriction: 1000----------2000
489
+ Request: 500-----1000
490
+ Resulting response: empty header only
491
+ ```
492
+
493
+ If ` suppress_errors = true ` was not used, all the above requests would result in an error instead.
475
494
476
495
Note that when using ` suppress_errors = true ` , when a client is not authorization to view any of the requested regions,
477
- a non-error response is still returned with an empty reads/variants set. For example, if the client was not authorized
478
- to view ` chr1 ` at all, the response would return urls that correspond to a valid file (with the file header and EOF block),
479
- but no actual reads data. Authorization error responses are still returned if the JWT is invalid or the client is not
480
- allowed to view the requested ` <id> ` path.
496
+ a non-error response is still returned with an empty response containing the file header. For example, if the
497
+ client was not authorized to view ` chr1 ` at all, the response would return urls that correspond to a valid file
498
+ (with the file header and EOF block), but no actual reads data. Authorization error responses are still returned if the
499
+ JWT is invalid or the client is not allowed to view the requested ` <id> ` path. Parameters are only checked for validity
500
+ after authorizing the request, so invalid requests may return an unauthorized or forbidden response instead of a bad
501
+ request if the user lacks authorization.
481
502
482
503
[ auth-json ] : docs/schemas/auth.schema.json
483
504
[ auth-example ] : docs/examples/auth.toml
0 commit comments