opensearch-project / OpenSearch

🔎 Open source distributed and RESTful search engine.
https://opensearch.org/docs/latest/opensearch/index/
Apache License 2.0
9.82k stars 1.83k forks source link

[Feature Request] Rule Based request labeling to define multi-tenancy #14425

Open kaushalmahi12 opened 5 months ago

kaushalmahi12 commented 5 months ago

Is your feature request related to a problem? Please describe

Currently there is no mechanism to label/classify the incoming requests into tenants. There is an RFC open for defining the multi-tenancy in OpenSearch. We should provide a way to translate request's implicit/explicit attributes into tenants. Currently we are working on query sandboxing which can leverage this but this is not limited to this feature only and can be easily leveraged for both the indexing as well as search workloads.

Describe the solution you'd like

Rule Based Labeling

We will enable admin users to define rules to translate requests into output tokens which can be interpreted as tenants for consuming features. These rules can leverage implicit|explicit attributes to define the tenants. The output tokens will be propagated via ThreadContext or can be consumed into the feature directly as return values.

Implicit attributes could be anything like

Explicit Attributes

I am skipping over the authN/authZ part for explicit attributes since that is something which should be handled at the security layer as discussed in the parent RFC

What will a Rule look like ?

{
    "Input": {
        "attr1": ["val1", "val2*"],
        "attr2": ["xyz", "xyz*"]
        .....
    },
    "Output": {
        "field1": "value",
        "field2": "value",
        ....
    }
}

What if multiple rules matches for a request, how to resolve these conflicts ? Only one Rule should apply for a request. To avoid such conflicts we will ensure that no two rules are overlapping. But doing this will not ensure that the rukes doesn't overlap. We still need to come up with precedence of attributes.

Now the precedence of attributes needs to be tackled for both the supported type of attributes.

Related component

Other

Describe alternatives you've considered

No response

Additional context

No response

peternied commented 5 months ago

[Triage - attendees 1 2 3 4 5] @kaushalmahi12 Thanks for creating this issue