Skip to content
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

Enable automated security plugins at the service (root spec) level #5378

Merged
merged 4 commits into from
Dec 14, 2022
Merged

Enable automated security plugins at the service (root spec) level #5378

merged 4 commits into from
Dec 14, 2022

Conversation

ttyS0e
Copy link
Contributor

@ttyS0e ttyS0e commented Nov 3, 2022

changelog(Improvements): Added ability to enable automated security plugins at service-level (root of spec) when generating Kong (or Kubernetes) declarative configs

FIXES #3389

This enhancement adds the ability to use openapi-2-kong to create service-level (root of spec) security plugins, specifically OpenID-Connect, whilst generating Kong (or Kubernetes) declarative config.

It works with other security definition types also.

You will see in the tests what this is doing:

  1. If security: definition is present at the root of the document, it now creates a service-level Kong plugin to go with this declaration
  2. If a user specifies finer-grained security: on a route/method level, then a plugin will additionally be created at that level
  3. In Kong, the route-level plugin will override the service-level one, which gives the user a transparent approach for adding API specification native security to their API, without needing to use x-kong-plugin- declarations.

@filfreire
Copy link
Member

rebased with latest develop

Copy link
Member

@filfreire filfreire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally, LGTM

There seems to be an edge-case unrelated issue that makes the Preview of the spec stop working, but it's unrelated to this change.

Screenshot_2022-11-22_at_17_03_45

@filfreire filfreire requested a review from a team November 22, 2022 17:29
@filfreire
Copy link
Member

tagging someone else from @Kong/team-insomnia for a second pass

@jackkav
Copy link
Contributor

jackkav commented Dec 7, 2022

It's not clear to me if this aligns with the vision for deprecating plugin inference in o2k. @Tieske

@Tieske
Copy link
Member

Tieske commented Dec 8, 2022

No it doesn't. Let's not add this. I'll follow up with @ttyS0e

@Tieske
Copy link
Member

Tieske commented Dec 9, 2022

Had a closer look at the issue, and it is indeed a bug. The fix seems correct.

So I'm changing my opinion on this one; no objections to merge it.

But.... the input OAS is the one that describes the "backend" api (the api that Kong will proxy towards). Which is not necessarily the same as the one exposed by Kong, since Kong will live at a different hostname for example. The discrepancy here is that the security directive will describe the checks as implemented by Kong. So now it becomes a weird mix of backend and entry-point config.

That is the reason that in the new ApiOps tools we will not include generation of those security directives. We need a better way to solve this.

Copy link
Contributor

@jackkav jackkav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ttyS0e and @Tieske

@jackkav jackkav enabled auto-merge (squash) December 14, 2022 15:21
@jackkav jackkav merged commit 46bb161 into Kong:develop Dec 14, 2022
pavkout pushed a commit to pavkout/insomnia that referenced this pull request Jan 18, 2023
…ong#5378)

* feat(plugins): enable support for service-level security definition plugins

* feat(plugins): add tests for service-level security plugins

* fix(syntax): match regexes to last commit

* fix lint

Co-authored-by: Filipe Freire <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[openapi-2-kong] Key-auth plugin is missing from generated declarative config
4 participants