Categorygithub.com/DmitryShaburov/grafana-datasource-auth-proxy

# README

Grafana Datasource Auth Proxy

Limit access to Grafana datasources per team.

Table of Contents

About

Project topic

When you're using Grafana datasource proxy feature (Access: Server (default) in datasource settings), free version of Grafana does not implements any ACLs for that, and any user can query every datasource and get metrics directly from it, even with Viewer rights.

Here is related issue.

Grafana Enterprise although implements this permissions.

This project implements simple reverse proxy, that should be installed to handle api/datasources/proxy.

Here how it works:

  • Check that requested path actually contains api/datasources/proxy to avoid proxying everything else;
  • Check that there is grafana_session authentication cookie present;
  • Get list of user's teams by authentication cookie;
  • Check that at least on of the user's team have access to requested datasource;
  • If everything is OK pass request to Grafana

Limitations

Project is not production-ready and was build as an experiment. Use on your own risk.

Project supports only MySQL Grafana database backend (PR's welcome!)

Project was only tested againts Prometheus data sources

Project was only tested against Grafana 7

Project doest not supports non-standard Grafana auth cookie name (PR's welcome!)

Usage

Installation

There are multiple ways of installing grafana-datasource-auth-proxy.

Running from Helm chart

helm repo add grafana-datasource-auth-proxy https://dmitryshaburov.github.io/grafana-datasource-auth-proxy/
helm repo update
helm install [RELEASE_NAME] grafana-datasource-auth-proxy/grafana-datasource-auth-proxy

Running as Docker container

dshaburov/grafana-datasource-auth-proxy

docker run -p 9608:9608 -v /etc/grafana-datasource-auth-proxy/config.yaml:/etc/grafana-datasource-auth-proxy/config.yaml dshaburov/grafana-datasource-auth-proxy:latest

Precompiled binaries

Precompiled binaries for released versions are available in the Releases section.

Compiling the binary

You can checkout the source code and build manually:

git clone https://github.com/DmitryShaburov/grafana-datasource-auth-proxy.git
cd grafana-datasource-auth-proxy
go build .
./grafana-datasource-auth-proxy -config=config.yaml

Configuration

Flags

FlagEnvironment VariableDefault ValueDescription
configCONFIG_FILE/etc/grafana-datasource-auth-proxy/config.yamlPath to configuration file
listen-addressLISTEN_ADDRESS:3000The address to listen on for HTTP requests
grafana-urlGF_SERVER_DOMAINgrafanaGrafana remote origin host
grafana-secretGF_SECURITY_SECRET_KEYSW2YcwTIb9zpOOhoPsMmGrafana encryption secret
db-databaseGF_DATABASE_NAMEgrafanaGrafana database name
db-hostGF_DATABASE_HOST127.0.0.1:3306Grafana database host and port
db-userGF_DATABASE_USERGrafana database user
db-passGF_DATABASE_PASSWORDGrafana database password
log-formatLOG_FORMATtxtLog format, valid options are txt and json
log-levelLOG_LEVELinfoLog level, valid options are trace, debug, info, warn, error, fatal and panic

YAML config

See config.yaml for example configuration file.

Helm chart

See values.yaml for full list of available Helm chart values and their default configuration.

Contribution

PRs on Feature Requests, Bug fixes are welcome. Feel free to open an issue and have a discussion first. Contributions on more alert scenarios, more metrics are also welcome and encouraged.

License

MIT

# Functions

No description provided by the author
No description provided by the author
No description provided by the author
Helper functions.
No description provided by the author

# Structs

Configuration.
Grafana.