Custom authorization in Kong #7524
-
We wanted to move our company's custom authorisation to Kong. Currently we have an internal table which maps URLs to scopes and using the request URL and consumer details we are able to authorise the request. We want to move all this to Kong. We need to maintain a table on Kong level which has the different scopes associated with the different URLs. Calling another service to get the scope is also one solution for this. Any suggestions or recommended methods for this? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
Good morning, you should be able to accomplish what you need by creating a Custom Plugin. The Custom Plugin Development Guide is here: https://docs.konghq.com/gateway-oss/2.4.x/plugin-development/ Plugins can have migrations (on db mode) and custom entities (both on db and db-less modes) which could be used to map your scopes and how they map to each consumer. Since you are doing an auth plugin, it will probably be a good idea to give a look at the Basic Auth Plugin source code, or even use it as a base for your own plugin. |
Beta Was this translation helpful? Give feedback.
-
Hey, @kikito, thanks for your reply. I went through the plugin development guide and read all about custom plugins and how they work. I have a few more doubts - |
Beta Was this translation helpful? Give feedback.
-
It is difficult for me to understand what you are trying to accomplish, exactly, because "Scope" can mean a lot of different things; since this is an authorization-related discussion, I assume they mean some sort of "permission group", like "Payroll" or "Sales".
It sounds like you are trying to do something like this:
So you have one instance of your plugin associated to one Service, and then inside your custom plugin you are trying to do something like this, only with more regexes involved:
Kong already has a way to "map" request urls to regexes on its router (the
And then inside your plugin you will only need to do:
To get the scope. It's possible that I have misunderstood your needs, please provide more context if that's the case. |
Beta Was this translation helpful? Give feedback.
It is difficult for me to understand what you are trying to accomplish, exactly, because "Scope" can mean a lot of different things; since this is an authorization-related discussion, I assume they mean some sort of "permission group", like "Payroll" or "Sales".
It sounds like you are trying to do something like this:
So you have one instance of your plugin associated to one Service, and then inside your custom plugin you are trying to do something like this, only with more regexes involved: