I have an issue where a couple of datasets are added via the AutoQueryDataFeature and I want to add ActiveDirectory authorization on them.
I see that for endpoints that inherit from Service its as easy as decorating the functions with [RequiresAnyRole] but I can’t figure out how to do the same with the Search and Suggest endpoints that are not implemented the same way. I am assuming that the Search and Suggest endpoints are built into ServiceStack.
You can either create a Custom AutoQuery Implementation where you can then annotate it the same as your other protected services, e.g:
[RequiredRole("TheRole")]
public class MyServices : Service
{
public IAutoQueryDb AutoQuery { get; set; }
public object Any(FindMovies query)
{
using var db = AutoQuery.GetDb(query, base.Request);
var q = AutoQuery.CreateQuery(query, base.Request, db);
return AutoQuery.Execute(query, q, base.Request, db);
}
}
The data is available as a AutoQueryDataFeature which is defined in Global.asax.cs and is stored in Redis, AutoQuery.GetDb will not work in this case, do I have another option?
The only external AutoQuery Data provider supported is AutoQuery DynamoDB, Redis doesn’t support querying data, best you can do is query the Snapshot of data in memory, both AutoQuery Memory Data and AutoQuery Service Data show querying a custom in-memory resultset.