4 title: API Authorization
7 Copyright (C) The Arvados Authors. All rights reserved.
9 SPDX-License-Identifier: CC-BY-SA-3.0
12 All requests to the API server must have an API token. API tokens can be issued by going though the login flow, or created via the API. At this time, only browser based applications can perform login from email/password. Command line applications and services must use an API token provided via the @ARVADOS_API_TOKEN@ environment variable or configuration file.
16 Browser based applications can log in using one of the two possible flows:
18 h3. Authenticate via a third party
20 # The web application instructs the user to click on a link to the @/login@ endpoint on the API server. This link should include the @return_to@ parameter in the query portion of the URL. For example @https://{{ site.arvados_api_host }}/login?return_to=XXX@ , where @return_to=XXX@ is a page in the web application.
21 # The @/login@ endpoint redirects the user to the configured third party authentication provider (e.g. Google or other OpenID Connect provider).
22 # The user logs in to the third party provider, then they are redirected back to the API server.
23 # The API server authenticates the user, issues a new API token, and redirects the browser to the URL provided in @return_to=XXX@ with the addition of @?api_token=xxxxapitokenxxxx@.
24 # The web application gets the authorization token from the query and uses it to access the API server on the user's behalf.
26 h3. Direct username/password authentication
28 # The web application presents username and password fields.
29 # When the submit button is pressed, using Javascript, the browser sends a POST request to @/arvados/v1/users/authenticate@
30 ** The request payload type is @application/javascript@
31 ** The request body is a JSON object with @username@ and @password@ fields.
32 # The API server receives the username and password, authenticates them with the upstream provider (such as LDAP or PAM), and responds with the @api_client_authorization@ object for the new API token.
33 # The web application receives the authorization token in the response and uses it to access the API server on the user's behalf.
35 h3. Using an OpenID Connect access token
37 A cluster that uses OpenID Connect as a login provider can be configured to accept OIDC access tokens as well as Arvados API tokens (this is disabled by default; see @Login.OpenIDConnect.AcceptAccessToken@ in the "default config.yml file":{{site.baseurl}}/admin/config.html).
38 # The client obtains an access token from the OpenID Connect provider via some method outside of Arvados.
39 # The client presents the access token with an Arvados API request (e.g., request header @Authorization: Bearer xxxxaccesstokenxxxx@).
40 # Depending on configuration, the API server decodes the access token (which must be a signed JWT) and confirms that it includes the required scope (see @Login.OpenIDConnect.AcceptAccessTokenScope@ in the "default config.yml file":{{site.baseurl}}/admin/config.html).
41 # The API server uses the provider's UserInfo endpoint to validate the presented token.
42 # If the token is valid, it is cached in the Arvados database and accepted in subsequent API calls for the next 10 minutes.
46 !{{site.baseurl}}/images/Session_Establishment.svg!
50 "Creation and activation of new users is described here.":{{site.baseurl}}/admin/user-management.html
52 h2. Creating tokens via the API
54 The browser login method above issues a new token. Using that token, it is possible to make API calls to create additional tokens. To do so, use the @create@ method of the "API client authorizations":{{site.baseurl}}/api/methods/api_client_authorizations.html resource.
58 Scopes can restrict a token so it may only access certain resources. This is in addition to normal permission checks for the user associated with the token.
60 Each entry in scopes consists of a @request_method@ and @request_path@. The @request_method@ is a HTTP method (one of @GET@, @POST@, @PATCH@ or @DELETE@) and @request_path@ is the request URI. A given request is permitted if it matches a scopes exactly, or the scope ends with @/@ and the request string is a prefix of the scope.
62 As a special case, a scope of @["all"]@ allows all resources. This is the default if no scope is given.
64 A valid token is always allowed to issue a request to "@GET /arvados/v1/api_client_authorizations/current@":{{ site.baseurl }}/api/methods/api_client_authorizations.html#current regardless of its scopes.
66 Using scopes is also described on the "Securing API access with scoped tokens":{{site.baseurl}}/admin/scoped-tokens.html page of the admin documentation.
70 A scope of @GET /arvados/v1/collections@ permits listing collections.
72 * Requests with different methods, such as creating a new collection using @POST /arvados/v1/collections@, will be rejected.
73 * Requests to access other resources, such as @GET /arvados/v1/groups@, will be rejected (except "@GET /arvados/v1/api_client_authorizations/current@":{{ site.baseurl }}/api/methods/api_client_authorizations.html#current, which is always allowed).
74 * Be aware that requests for specific records, such as @GET /arvados/v1/collections/962eh-4zz18-xi32mpz2621o8km@ will also be rejected. This is because the scope @GET /arvados/v1/collections@ does not end in @/@
76 A scope of @GET /arvados/v1/collections/@ (with @/@ suffix) will permit access to individual collections.
78 * The request @GET /arvados/v1/collections/962eh-4zz18-xi32mpz2621o8km@ will succeed
79 * Be aware that requests for listing @GET /arvados/v1/collections@ (no @/@ suffix) will be rejected, because it is not a match with the rule @GET /arvados/v1/collections/@
80 * A listing request @GET /arvados/v1/collections/@ will have the trailing @/@ suffix trimmed before the scope check, as a result it will not match the rule @GET /arvados/v1/collections/@.
82 To allow both listing objects and requesting individual objects, include both in the scope: @["GET /arvados/v1/collections", "GET /arvados/v1/collections/"]@
84 A narrow scope such as @GET /arvados/v1/collections/962eh-4zz18-xi32mpz2621o8km@ will disallow listing objects as well as disallow requesting any object other than those listed in the scope.