We are looking at Tyk to add better quota management and a few other things, and I have a few questions about authentication/token management.
Technically, we can import API-keys generated by Tyk into our system, so that the 2 would match. However, that would also mean that a user could connect both to the Tyk gateway and directly to our end-point with the same credentials, thus escaping Tykās quota controls in the latter case (in the short term, we need to keep our end-point directly accessible as we have existing clients using it and we donāt want to migrate them to Tyk until we are satisfied everything works as we want).
In an ideal scenario, Iād like to map our own tokens to the ones generated by the Tyk, so that users going through the Tyk gateway would seamlessly authenticate against our own system, but their Tyk-generated key would not work directly with our own end-point.
Another option will be using middleware, and define āpreā middleware, which do the token mapping, by querying some service/kv storage provided by you.
Thanks Leon!
It seems option 1 would the easiest way to do it. If I understand correctly, I need to specify our key in the JSON I submit to POST /tyk/keys/ ⦠Where exactly would I put that in the JSON?
Ok, so I tried submitting the following (obviously replacing the authorization key with the one for my own user - which I also set as admin, and also putting the correct API key for the API I have created in the system).
BTW, just to be clear, I am trying to perform all this on Tyk Cloud (at least in the beginning for testing purposes). However, I noticed now that Leonās link pointed to the Tyk Hybrid documentation, so I thought Iād mention this to avoid confusion.
TBH, I saw the exact method described in the documentation to create keys via API on Tyk Cloud and I have using the cloud end-point, so I am assuming they should both work the same⦠right?
Ah, well no wonder it isnāt working - Tyk Cloud does not allow custom tokens to be injected into the gateway. For that you have to use an on-premise gateway like hybrid.
The only third-party tokens that are supported in tyk cloud are JWT and OpenID Connect ID Tokens. Otherwise everythingās needs to be generated by our cloud.
Should have asked that first really! Sorry for the frustration :-/
Sorry for the late follow-up⦠I finally managed to find some time to install Tyk on-premise⦠But I still get the error āAttempted access to non-owned keyā when I try to add a custom key with this command:
Thanks Martin⦠I did have the org_id, turns out the problem was that I missed that Tyk comes with 2 APIs, and I was trying to add the key using the one at api/keys with my admin userās secret.
I have now figured out that there is a different entry point (tyk/keys), running on a different port (8080 instead of 3000) and that requires the āsecret idā from the tyk.conf file.
Having made the necessary changes, I have now moved on to a new error message
"error": "Failed to create key, ensure security settings are correct.",
Any idea what security settings should I check?
BTW, this command instead works fine with the same token.json file
I have created my API in the system to use Auth-token and enabled āAllow query parameter as well as headerā, which in my understanding would mean that Tyk would first check if the token provided is enabled in the Tyk DB, and if yes pass on the request with the token to my own API (which in turn will authorize the token, as it originally comes from it) and respond to the request. Did I get this right?
Also, when I try to get the list of keys I get the message that Tyk is running in hashed mode, can that have something to do with the error message I am getting when I try to add my own custom key?
Turns out the dashboard was not seeing the Gateway (no Nodes listed as active). I just restarted the GW service, the Node has appeared and I can now add my keys