Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow optional headers on access_url (resolves issue #239) #248

Merged
merged 7 commits into from
Apr 19, 2019
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 24 additions & 5 deletions docs/asciidoc/front_matter.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,27 @@ For convenience, we define a recommended syntax for fully referencing DRS-access

The DRS API specification is written in OpenAPI and embodies a RESTful service philosophy. It uses JSON in requests and responses and standard HTTP/HTTPS for information transport.

== Authorization & Authentication (WORK IN PROGRESS)

Users must supply credentials that establish their identity and authorization in order to use a DRS endpoint. We recommend that DRS implementations use an OAuth2 https://oauth.net/2/bearer-tokens/[bearer token], although they can choose other mechanisms if appropriate. DRS callers can use the `auth_instructions_url` from the https://ga4gh.github.io/data-repository-service-schemas/#/DataRepositoryService/GetServiceInfo[service-info endpoint] to learn how to obtain and use a bearer token for a particular implementation.

The DRS implementation is responsible for checking that a user is authorized to submit requests. The particular authorization policy is up to the DRS implementer.
== Authorization & Authentication

=== Making DRS Requests

The DRS implementation is responsible for defining and enforcing an authorization policy that determines which users are allowed to make which requests. We recommend that DRS implementations use an OAuth2 https://oauth.net/2/bearer-tokens/[bearer token], although they can choose other mechanisms if appropriate. DRS callers can use the `auth_instructions_url` from the https://ga4gh.github.io/data-repository-service-schemas/#/DataRepositoryService/GetServiceInfo[service-info endpoint] to learn how to obtain and use a bearer token for a particular implementation.

=== Fetching DRS Objects

The DRS API allows implementers to support a variety of different content access policies, depending on what `AccessMethod` s they return:

* public content:
** server provides an `access_url` with a `url` and no `headers`
** caller fetches the object bytes without providing any auth info
* private content that requires the caller to have out-of-band auth knowledge (e.g. service account credentials):
** server provides an `access_url` with a `url` and no `headers`
** caller fetches the object bytes, passing the auth info they obtained out-of-band
* private content that requires the caller to pass an Authorization token:
** server provides an `access_url` with a `url` and `headers`
** caller fetches the object bytes, passing auth info via the specified header(s)
* private content that uses an expensive-to-generate auth mechanism (e.g. a signed URL):
** server provides an `access_id`
** caller passes the `access_id` to the `/access` endpoint
** server provides an `access_url` with the generated mechanism (e.g. a signed URL in the `url` field)
** caller fetches the object bytes from the `url` (passing auth info from the specified headers, if any)
44 changes: 29 additions & 15 deletions openapi/data_repository_service.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ security:
paths:
'/service-info':
get:
summary: Returns service version and other information
summary: Get information about this implementation.
description: >-
May return service version and other information.
operationId: GetServiceInfo
responses:
'200':
Expand Down Expand Up @@ -73,7 +75,9 @@ paths:
x-swagger-router-controller: ga4gh.drs.server
'/objects/{object_id}':
get:
summary: Retrieve a Data Object
summary: Get info about a Data Object.
description: >-
Returns object metadata, and a list of access methods that can be used to fetch object bytes.
operationId: GetObject
responses:
'200':
Expand Down Expand Up @@ -110,13 +114,15 @@ paths:
x-swagger-router-controller: ga4gh.drs.server
'/objects/{object_id}/access/{access_id}':
get:
summary: Returns a fully resolvable URL that can be used to fetch the actual object bytes.
summary: Get a URL for fetching bytes.
description: >-
Returns a fully resolvable URL that can be used to fetch the actual object bytes.
operationId: GetAccessURL
responses:
'200':
description: The access URL was found successfully.
schema:
$ref: '#/definitions/GetAccessURLResponse'
$ref: '#/definitions/AccessURL'
'400':
description: The request is malformed.
schema:
Expand Down Expand Up @@ -146,7 +152,7 @@ paths:
in: path
required: true
type: string
description: An 'access_id' from 'access_methods' list of a Data Object
description: An `access_id` from the `access_methods` list of a Data Object
tags:
- DataRepositoryService
x-swagger-router-controller: ga4gh.drs.server
Expand Down Expand Up @@ -319,13 +325,22 @@ definitions:
properties:
object:
$ref: '#/definitions/Object'
GetAccessURLResponse:
AccessURL:
type: object
required: ['object']
required: ['url']
properties:
access_url:
url:
type: string
description: A fully resolvable access_url that can be used to fetch the actual object bytes.
description: A fully resolvable URL that can be used to fetch the actual object bytes.
headers:
type: array
items:
type: string
description: >-
An optional list of headers to include in the HTTP request to `url`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a great first step. It improves what we have right now and we should go for it. As an implementer/user of DRS I'd like to know 1) what are the possible headers here, do we define them in the /service-info end point for example or in the spec as a list of acceptable ones? And 2) it would be great to see examples of how these work for each of the types of access methods DRS 1.0 would support (in the docs for example). Totally fine to address in a future PR

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re (1): As a user, you shouldn't have to know what headers are possible; you just use the ones you're given. As an implementor, you can return any headers you want. The most likely use case is to return an Authorization header, as is shown in the example in the YAML.

Re (2): this PR already includes beefed-up documentation on access methods (in front_matter.adoc); happy to add more in future PRs

These headers can be used to provide auth tokens required to fetch the object bytes.
example:
Authorization: Basic Z2E0Z2g6ZHJz
AccessMethod:
type: object
required:
Expand All @@ -348,20 +363,19 @@ definitions:
description: >-
Type of the access method.
access_url:
type: string
$ref: '#/definitions/AccessURL'
description: >-
A fully resolvable URL string that can be used to fetch the actual object bytes.
Note that at least one of access_url and access_id must be provided.
An `AccessURL` that can be used to fetch the actual object bytes.
Note that at least one of `access_url` and `access_id` must be provided.
access_id:
type: string
description: >-
An arbitrary string to be passed to the /access path to fetch an access_url.
An arbitrary string to be passed to the /access path to get an `AccessURL`.
This must be unique per object.
Note that at least one of access_url and access_id must be provided.
Note that at least one of `access_url` and `access_id` must be provided.
region:
type: string
description: >-
OPTIONAL
Name of the region in the cloud service provider that the object belongs to.
example:
us-east-1
Expand Down