-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
[Search Pipelines] Modify search pipeline behavior based on authenticated user/role #11053
Comments
@msfroh Could you help me understand the scenario from the customer perspective, such as a set of http requests? |
@msfroh Can you elaborate on what these constraints may be? |
Oh, sure -- that's what's described in #10938, which is a (possible) driver for this issue (but the features are orthogonal). Essentially, in that issue, I propose using a search pipeline request processor to provide a finer-grained alternative to the all-or-nothing Let's use a subset of one of my examples from that issue:
So, with this pipeline, I'm saying that I generally don't want to allow prefix queries, because they can be expensive and I don't to risk bad queries overloading my cluster, but I'll allow them for field In case you're not familiar with search pipelines, this can be activated on search either explicitly:
Or it can be attached to at specific index:
Now, in this (#11053) issue, I'm wondering if (orthogonally) there's a good way to do this with some authZ/authN if there's an authenticated user, so we can specifically say "these users can run these queries, but other users cannot". I see three possible solutions (but maybe none of them is right). Processor receives auth contextIn this scenario, we propagate some (waving hands) auth context into the request processor and based on the processor's configuration, it makes decisions based on that auth context. The PUT pipeline request could be something like:
This might be the most user-friendly API (at least for this specific use-case), since we can restrict individual rules to specific users/roles, but it also means building the logic into the pipeline processor itself (which means that every processor that wants to deal with users would need its own logic to do so). IMO, that con makes it feel a bit icky from a "separation of concerns" standpoint. Authorized access to search pipelinesAnother approach could involve adding authorization to search pipelines and then using different pipelines for different users/roles:
Then you might limit specific roles to specific pipelines:
In this case, the search pipeline processor doesn't know anything about users or roles, which is nice. It's more complicated for the user, since they need to manage different pipelines for different roles. We can improve that situation by allowing pipeline delegation (i.e. the Make it an aliasing problemThis is kind of like the second solution ("Authorized access to search pipelines"), but we use aliases to avoid needing to add any new authorization logic. If we add a
This way, both roles only have permission to query via the aliases, but the aliases attach the search pipelines. This may be the easiest to implement and has the advantage that we're just reusing existing controls. It has all the downsides of the second option, though, plus the extra cognitive burden of the alias hop. |
Note that search pipeline processor can do almost anything you want with a search request or response, so a good auth mechanism could also control access to pipelines so that e.g. only certain roles can use a RAG pipeline to call out to a (potentially expensive) LLM. |
@msfroh Thanks for the details. I've got some ideas about how we handle this space that I've been trying to capture - maybe this is right time so please forgive any hand waving. I don't think a I've been thinking of this a I'm in the process of carving out time to dedicate to this effort 🤞 - as it would help the security team vastly with caching & performance, as well as some scenarios that are hard to manage such as conflicting permissions between different roles [2]. I think this would be the way I'd recommend making access controls availiable for search pipelines too, how does that sound to you? Why not just allow ACLs on search pipelines? Being able to cache authorization information isn't possible if the configuration is embedded inside resources that need to be resolved. |
Thank you for the rich detail @msfroh. I'll try to provide some context around how some other plugins have implemented attribute-based access control (ABAC) within a plugin and outside of the security plugin.
I think this approach may align with how I have seen plugins secure resources created by the plugin. I'm most familiar with how anomaly detection and ml-commons secure detectors or models created by their plugins, but I think other plugins follow a similar pattern as well. If I understand correctly, in your example the pipeline is the resource to be shared and it can be provisioned using a pattern similar to how AD or ml-commons protect the resources created in their plugins.
Edit: It would be great if the security plugin could be used for such cases. AD and ml-commons implement ABAC independently for their plugins use-cases, but the security plugin should be able to provide some mechanisms that plugins can take advantage of to secure resources created within the plugin. |
Thanks, @peternied and @cwperks! I added a comment on #6181, since that really sounds like the best way to unify some of these security + search pipelines ideas and where I think the two work streams can really help each other out. That is, if we can have a "view" concept that has access controls and binds to a specific search pipeline (without letting folks override the pipeline in their request), we can implicitly limit access to specific pipelines (both in terms of preventing folks from using pipelines unless authorized and in terms of preventing folks from bypassing pipelines). In exchange, search pipelines may help the security plugin by taking on DLS duties (and maybe FLS). |
Is your feature request related to a problem? Please describe.
In a search pipeline request processor, it would be nice to be able to customize behavior based on the particular user/role making the call.
In particular, while #10938 proposes granular restrictions on specific query types, it would be even nicer if we could say "Users with role X can only run queries that satisfy these constraints, while admin users with role Y have these less-stringent constraints."
Describe the solution you'd like
I think I'd like to be able to access the current
Subject
from a search processor, if the Identity feature is enabled. Since theSearchPipelineService.resolvePipeline()
method runs on the request thread (IIRC), we could probably injectIdentityService
intoSearchPipelineService
, which could callidentityService.getSubject()
and add theSubject
into thePipelinedRequestContext
that we're adding in #9405. Then it would be up to a specific processor to decide if they want to look at theSubject
and do something with it.Alternatively, maybe I'm thinking about the problem from the wrong angle -- perhaps we should add authorization to use search pipelines within a search request. Under that model, you could define a search pipeline that imposes some restrictions on a search request, and say that users with role X can only submit queries using that search pipeline. (Meanwhile, users with a more admin-like role can use a different search pipeline or maybe specify the
_none
pipeline explicitly.) That feels like it might be the cleaner solution, because you're separating the question of which users can access which pipelines from deciding what the individual pipelines can do.I'm not sure what the right implementation is and would appreciate suggestions from folks who know more from the security angle, like @scrawfor99 and @peternied.
Describe alternatives you've considered
I've also toyed with the idea of adding a search pipeline parameter to an index alias, similar to the existing
filter
parameter that can be used to make an index alias behave like a "view" over a subset of the index. You could create multiple aliases for each index, where each alias has a search pipeline that enables/disables some capabilities. Then you would grant specific users/roles access to the various aliases, rather than authorizing them to access specific indices. I kind of like that idea, because even as an admin, I might want to querymy_index_with_guardrails
most of the time, only queryingmy_index_that_shoots_me_in_the_foot
when I absolutely have to.Additional context
See also #10938.
The text was updated successfully, but these errors were encountered: