Some Notes on Data source Info / Data source Ref:
-
Terms I'm using for these notes:
- DatasourceRef: is model that includes (uid+type), is saved by dashboards and alerting (note: alerting is current UID only)
- DatasourceInfo: is full information that a datasource neededs to execute a request, and can be looked up by the Ref
-
Contexts:
- Alerting: The Ref is saved. Alerts run as a service, so in this context there is no user (although perhaps there should be a service user or role). Therefore for saved alerts run by the service, authorization is done at creation time, not run time - (as users would not want alerts to stop working if a user is removed).
- Query API: Runtime, in this context there is a user
-
Main Question:
- What Services are responsbile for what for data source execution?
- Where trailing "What" is:
- Authorizing a User (or Service) to a data source (or data source ref?), and who caches this?
- Taking a data source ref and getting data source info
- Decryption of secrets within data source info?
-
Considerations:
- Security (e.g. Defense in depth, services not having secrets they don't need)
- Performance (e.g. not looking up things twice)
- Making things services - and the stateless aspect (TBH "stateless" in this context isn't entirely clear to me)
-
Misc Notes:
- SSE doesn't need data source info, only the ref, I think only data source plugins and editing of data sources needs the full info
-
A Possible Architecture
- Service to Authorize Datasource Ref to Users (To be called at borders (e.g. APIs or exported services))
- Another service to Translate Datasource Ref -> Datasource Info (to be called by internal services)
- With this, things like recorded queries would use the Data Source Ref Authorization service, SSE as well only sees the Datasoure Ref but isn't responsbile for authorization. Data sources get info (I imagine an execute queries call could use the ref to fetch data source info before sending the request to a data source).
It mutates the shape of incoming data frames, so not ideal to always call it at least as it currently is.
This would require the user to be passed through to SSE, which it doesn't need otherwise. In the case of alerting, there is no user, so would need behavior for that as well. So that results in two entries paths into SSE that would be different in terms of how permissions need to be checked. Also seems a bit more intuitive to me to have this checked at the borders (HTTP API for querying or alerting) since those are the places where permissions need to be handled different (run time permissions vs creation time permissions).