Kong Api Gateway - Api key's custom logics

42 Views Asked by At

I am using Kong API Gateway. I want to add custom logic for a particular API key belonging to a specific user. Is there any solution to achieve this? Essentially, I have a user panel where users can create API keys to access my backend service. Within this panel, users should have the option to restrict requests from specific frontend URLs or whitelist certain functions.

I think we can use custom plugin, if yes please suggest.

1

There are 1 best solutions below

0
Guilherme Salazar On

I want to add custom logic for a particular API key belonging to a specific user. Is there any solution to achieve this?

Yes, in Kong Gateway, you can apply plugins per consumer (which is the entity that associates with a particular API 'user' - which not necessarily maps to a human, can also be a machine, or some other kind of automation consuming the API). For example, you can apply per-user rate-limiting: see the example here https://docs.konghq.com/gateway/latest/get-started/rate-limiting/#consumer-level-rate-limiting.

Essentially, I have a user panel where users can create API keys to access my backend service. Within this panel, users should have the option to restrict requests from specific frontend URLs or whitelist certain functions.

If I get this part correctly (it's unclear what your question is), what you are looking for is the ACL plugin: https://docs.konghq.com/hub/kong-inc/acl/.