Skip to content

Add ability to change default DLS parameter substitution behavior #1310

@rofleksey

Description

@rofleksey

Currently, if DLS contains a parameter that is not quoted and is not defined anywhere, i get this error:
Unrecognized token '$': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')

This is happening, because replaceProperties method replaces only defined parameters, but does nothing to at least replace undefined ones with ''. This doesn't result in error if all the parameters are quoted, because even though they are not being replaced, the JSON structure still stays syntactically correct. But if there is at least one unquoted parameter, I get this error.

For example, if I have this role configuration:

{
  "index_permissions": [
    {
      ...
      "dls": "{\"terms\":{\"arr\":[${attr.jwt.array}]}}",
      ...
    }
  ],
  ...
}

And JWT payload looks like:

{
  "array": "\"1\", \"2\", \"3\"",
}

Then everything works correctly. But if for some reason I don't define this array field in JWT payload, I get the error described above.

I think there should be an option to tweak this behavior:

  1. do nothing to undefined parameters (default)
  2. replace undefined parameters with ''
  3. throw an exception if undefined parameters are detected

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestgood first issueThese are recommended starting points for newcomers looking to make their first contributions.help wantedCommunity contributions are especially encouraged for these issues.triagedIssues labeled as 'Triaged' have been reviewed and are deemed actionable.v3.6.0Issues targeting release v3.6.0

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions