-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Autorization on Gateway #38
Comments
not 100% sure which gateway you refer too, considering there are multiple gateway examples. But I believe neither do any RBAC. This is just because there is no mapping implemented, like at the service layer. Should be pretty much copy/paste from those if you really need it. However, I personally believe that services should do their own RBAC and an API Gateway is not really the right place for it. As this would probably mean most significant service level changes would need an API Gateway level change as well. Effectively losing a part of the ability for separate deployment and autonomy over its business logic. (usually services are maintained by other teams as the gateway) |
Thank you for your answer. I meant Gateway in the spring-cloud-gateway-oidc-tokenrelay example. I agree with what you wrote, but I have a special case to solve - behind the gateway there is a regular static web application. Therefore, authorization on the Gateway would completely solve the problem. I tried to adopt the code from the services but I failed. Could you show a simple example with role mapping at Gatway level? |
Hi @landrzejewski ; I'm afraid I don't have any samples of role mapping in a gateway right now; Up to now I've only used The mock flights and mock hotels service in the spring-cloud-gateway-oidc-tokenrelay sample both use web mvc rather than webflux like the gateway, so the examples you see in there with a Would it be possible to host the static web application inside a spring service similar to the mock flights service? Might not be ideal, but it could be a way around this problem for you for now. |
A bit of a hack, but it's working and should get you started I hope. Please note that it seems Spring Security's OAuth client implementation specifically is not build for custom RBAC it seems.
|
Wonderful! That's exactly what I needed, it works perfectly. Thank you very much for help! |
Great to hear @landrzejewski ; Does that resolve your issue, or do you recon we'd best include this in the existing gateway sample? As @robbert1 already indicated is isn't the cleanest of code, so I'm leaning towards leaving it out for now; possibly with a reference to here if needed. At least until there's a cleaner API to do the same. |
I think leaving this example here is ok - people who will need this information will be able to find it. Spring Security is changing rapidly so there may soon be a cleaner way to solve this problem. By the way, you have created very cool and helpful tutorials. |
Perfect; I'll leave the issue open so the information is easier to find. We can pick it up again once we see a more agreeable API emerge in Spring Security. And thanks for the nice feedback! :) |
I wonder if everything is fine with mapping roles on the Gateway. Regardless of the role assigned to the user at Keyklock level, Spring always sees ROLE_USER. After decoding the token, the roles are fine, so it looks like Spring can't read them and uses the default one. I tried to fix this based on examples shown at the service level, but it didnt worked. Can I ask you to verify this problem? Currently, roles cannot be verified at the Gateway level
The text was updated successfully, but these errors were encountered: