Files
gerrit/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-api-interface.html
Viktar Donich d8d91278b2 Remove gapi-auth and consolidate it with default one
This change removes gr-gapi-auth and merge gr-gerrit-auth into one
gr-auth static API, exposed as Gerrit.Auth to enable cross-domain
configuration for embedded scenario.

Apparently, Google Platform JS library shares state across instances,
and as a result for embedded use case PolyGerrit requesting OAuth
sequence breaks other instances. To mitigate that, this change provides
an interface similar to Gerrit.Nav for setting OAuth access tokens.

``` js
Gerrit.Auth.setup(getToken, defaultOptions)
```

Gerrit.Auth.setup takes following parameters:
- getToken takes a function that returns Promise resolving to full token
object (including `access_token` and `expires_at` properties)
- defaultOptions may contain `credentials` fetch option that will be
used for all HTTP requests if provided

With the access_token PolyGerrit uses Gerrit's "faster CORS":
- REST API endpoints are prefixed with /a/ (after base url)
- access_token is added as URL param
- all but GET requests are made as POST
- POST requests have Content-Type as text/plain
- $ct URL param presents actual Content-Type
- $m URL param presents actual Cotnent-Type

Change-Id: I860bb84b30a2259d750a2239b7713c019b89b0e0
2017-08-08 13:16:59 -07:00

33 lines
1.4 KiB
HTML

<!--
Copyright (C) 2016 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<link rel="import" href="../../../bower_components/polymer/polymer.html">
<link rel="import" href="../../../behaviors/base-url-behavior/base-url-behavior.html">
<link rel="import" href="../../../behaviors/gr-path-list-behavior/gr-path-list-behavior.html">
<link rel="import" href="../../../behaviors/rest-client-behavior/rest-client-behavior.html">
<link rel="import" href="gr-etag-decorator.html">
<!-- NB: es6-promise Needed for IE11 and fetch polyfill support, see Issue 4308 -->
<script src="../../../bower_components/es6-promise/dist/es6-promise.min.js"></script>
<script src="../../../bower_components/fetch/fetch.js"></script>
<dom-module id="gr-rest-api-interface">
<!-- NB: Order is important, because of namespaced classes. -->
<script src="gr-auth.js"></script>
<script src="gr-reviewer-updates-parser.js"></script>
<script src="gr-rest-api-interface.js"></script>
</dom-module>