Coder Social home page Coder Social logo

Comments (2)

pravin-raha avatar pravin-raha commented on May 26, 2024 1

Thanks @nateslo, I checked with your first solution. Now it's working fine

from kong.

nateslo avatar nateslo commented on May 26, 2024

Hi @pravin-raha. I believe the issue is config.{field_name} in your entity_checks which are nested inside of the config table. If the entity_checks are moved to the top level (sibling of fields), then validation succeeds.

return {
    name = "oidc-acl",
    fields = {
        { consumer = typedefs.no_consumer },
        { protocols = typedefs.protocols_http },
        {
            config = {
                type = "record",
                fields = {
                    { whitelist = { type = "array", elements = { type = "string" }, required = false } },
                    { blacklist = { type = "array", elements = { type = "string" }, required = false } },
                    { userinfo_header_name = { type = "string", required = false, default = "x-userinfo" } }
                },
            },
        },
    },
    -- entity checks moved to top level
    entity_checks = {  
      { only_one_of = { "config.whitelist", "config.blacklist" }, },
      { at_least_one_of = { "config.whitelist", "config.blacklist" }, },
  },
}

Compare this to the ACL plugin, which has a very similar schema: https://github.com/Kong/kong/blob/master/kong/plugins/acl/schema.lua

Alternately, I believe that you can remove config. from the field names and keep entity_checks inside the config table

return {
    name = "oidc-acl",
    fields = {
        { consumer = typedefs.no_consumer },
        { protocols = typedefs.protocols_http },
        {
            config = {
                type = "record",
                fields = {
                    { whitelist = { type = "array", elements = { type = "string" }, required = false } },
                    { blacklist = { type = "array", elements = { type = "string" }, required = false } },
                    { userinfo_header_name = { type = "string", required = false, default = "x-userinfo" } }
                },
                entity_checks = {
                  { only_one_of = { "whitelist", "blacklist" }, }, -- "config." removed
                  { at_least_one_of = { "whitelist", "blacklist" }, }, -- "config." removed
              },
            },
        },
    },
}

Both pass a validation unit test but I'll let someone with more context explain the differences between the two approaches

from kong.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.