nokia / kong-oidc

OIDC plugin for Kong
Apache License 2.0
455 stars 320 forks source link

Filters option #177

Open ptonini opened 3 years ago

ptonini commented 3 years ago

There is a filters property on the schema and a filter module, but it's usage is not documented. How can I use it?

I need to allow some requests to straight through, based on HTTP verb and source IP. Specifically:

I've made the following hack on line 18 of the handler.lua file quickly allow OPTIONS resquests: -- if ngx.req.get_method() ~= "OPTIONS" and filter.shouldProcessRequest(oidcConfig) then

Can I use the filters property for any of that?

moxue1989 commented 3 years ago

Yea this is not very well documented, I had trouble with this functionality as well. From what I can see, it's basically a filter on the path of the request, not the method or origins.

Check our filters test https://github.com/nokia/kong-oidc/blob/master/test/unit/test_filters_advanced.lua for some examples of what works.

I have had success with exposing my api-docs without authentication by using this regex: /api[-_]docs$. This basically excludes any path that ends in /api-docs from going through this plugin

iot-resister commented 3 years ago

@moxue1989 Thanks for the tip!