Any party in possession of an auth (or bearer) token (a “bearer”) can use it to get access to the associated resources (without demonstrating possession of a cryptographic key). To prevent misuse, auth tokens need to be protected from disclosure in storage and in transport.Tyk provides auth (bearer) token access as one of the most convenient building blocks for managing security to your API. Tokens are added to a request as a header or as a query parameter. If added as a header, they may be preceded by the word “Bearer” to indicate their type, though this is optional. Usually these tokens are provided in the
Authorization
header, however Tyk can be configured to accept the token in a different header, as a query parameter or in a cookie.
components.securitySchemes
object using type: apiKey
. It also includes specification of the location (in
) and key (name
) that are to be used when providing the token to the API, for example:
authentication.stripAuthorizationData
field (Tyk Classic: strip_auth_data
).
securitySchemes
mechanism allows only one location for the auth token, but in some scenarios an API might need to support multiple potential locations to support different clients.
The Tyk Vendor Extension supports this by allowing configuration of alternative locations in the auth token entry in server.authentication.securitySchemes
. Building on the previous example, we can add optional query and cookie locations as follows:
auth.use_certificate
).
auth.signature
).
You can configure:
MasherySHA256
or MasheryMD5
)POST /tyk/keys/{keyID}
endpoint in the Tyk Gateway API to import those tokens to Tyk, off-loading access control, quotas and rate limiting from your own application.
Authorization
for the header location, but you can replace this if required)Authorization
header, so configuration is slightly different as there is no need to enable
this method. You should configure the auth
object for any non-default settings, such as a different token location or Dynamic mTLS.