Last updated
Last updated
Authentication is implemented according to functionality in .
The user must have a valid user account.
The user logs in via API.
The username and password are given as parameters in login request.
The login credentials (a user ID and a authentication token) are returned in response.
When sending requests via API, the user gives the login credentials as parameters in header of request message (in fields X-User-Id
and X-Auth-Token
).
Each API documentation must also contain a login endpoint. This way the user is able to log in and get user ID and Authentication token, which are needed in order to explore the API functionality with OpenAPI (formerly Swagger) specification.
Note! Some of the top level GET methods do not need authentication. However, an API key is needed in those cases. It is conveyed as a header parameter in fieldX-Api-Key.
When an HTTP request to API is done via a browser, the browser might trigger a CORS preflight request in order to find out, if the original request is allowed. For more details see
Usually APIs in APInf catalog are connected to a (API Umbrella) proxy. Because proxy use requires an API key, examining API functionality using OpenAPI specification UI (previously called as Swagger) is one of those cases, which trigger preflight CORS operation.
Original request is sent, e.g. GET /organizations
request contains header X-Api-Key (value API key), which triggers the CORS functionality in browser
Browser sends OPTIONS request to proxy (same address as original request)
request does not contain header X-Api-Key
request contains header Access-Control-Request-Headers (value string X-Api-Key)
Pitfall 1
because of missing header X-Api-Key, the proxy rejects the OPTIONS request causing original operation to fail
CURE: configure API Umbrella to accept OPTIONS request without header X-Api-Key
(After configuration) the API Umbrella accepts the OPTIONS request and conveys it to API
API receives OPTIONS request and fills supported headers into Access-Control-Allow-Headers for OPTIONS response
Pitfall 2
Although API does not necessarily use the X-Api-Key header, it has to fill the X-Api-Key header into A-C-A-H list in response in addition to other headers
API sends OPTIONS response to API Umbrella
API Umbrella conveys OPTIONS response to the browser
The browser compares A-C-R-H list in original GET request to A-C-A-H list in OPTIONS response
Browser sends
In case X-Api-Key (or any of requested headers) is missing from A-C-A-H, the browser rejects the original request
In case A-C-R-H and A-C-A-H match, browser sends the original request
API must contain a handling for OPTIONS request and it must response with support for X-Api-Key header in order to allow API use also via UI.