Users and orgs from data source?

Backstory:
I have an existing rails api and specialized javascript visualization that allows customers to view telemetry data. I’m interested in adding Grafana, or a similar tool to provide an advanced/custom view for power users and internal use. I’ve used the MySQL datasource to prove out some useful views, but a big permissions issue crops up when considering giving access to customers.

The Problem:
Our rails api has the concept of users, companies, and locations with relations between all 3. Our api authorizes and scopes requests based on these relationships. I would like to use these existing users in grafana, as well as keep our current permissions model. I’ve seen the auth proxy, and it looks like I could use that to allow users to access Grafana, but permissions would still be an issue.

Questions:

  • Is there a way to get users and orgs from a datasource?
  • Is it possible to reference the current user and team/org for authorization and scoping?
  • If I write a datasource plugin for my api, would it possible to login as my existing users and pass credentials (username and auth token) to the datasource?