cloudworkz / grafana-permission-sync

gives grafana users permissions, based on what google groups they are in
MIT License
19 stars 6 forks source link
google grafana oauth sso

Grafana Permission Sync

Docker Repository on Quay license

What does it do?

This tool assigns roles to users in Grafana - based on what Google Groups they are in. The mapping of what group results in what org/role is managed through the config file.

This tool is a full rewrite of (rewrite of grafana-gsuite-sync)

How does it work?

  1. Get all orgs and all users from grafana
  2. Fetch all relevant google groups (once every settings.groupsFetchInterval)
  3. For each user, compute what orgs they should be in and what role they should have. This "update plan" (the list of changes to be made) that will be printed to stdout, for example:
    {"level":"info", "msg":"Promote user", "user":"Alice@COMPANY.com", "org":"Some Org Name [INT]", "oldRole":"Viewer", "role":"Admin"}`
    {"level":"info", "msg":"Remove user from org", "user":"Alice@COMPANY.com", "org":"Controlling"}
    {"level":"info", "msg":"Demote user", "user":"Alice@COMPANY.com", "org":"Some Org Name [PRD]", "oldRole":"Admin", "role":"Viewer"}
    {"level":"info", "msg":"Add user to org", "user":"SomeOtherUser", "org":"Some Org Name [PRD]", "role":"Viewer"}
  4. Apply the changes slowly (capped at 10 operations per second)
  5. Wait for settings.applyInterval, then repeat

Requirements

Config

Take a look at the the demo config file to see all settings

Rules

Example:

rules: [
    {
        # Everyone in the technology group should be able to view the two grafana organizations
        note: "tech viewers", # used to show in the reason field
        groups: [technology@my-company.com],
        orgs: ["Main Grafana Org", "Testing"],
        role: Viewer,
    },
    {
        # Also assign the Admin role to certain users 
        note: "global admins", 
        users: [ admin@my-company.com ], # individual users
        orgs: ["/.*/"],
        role: Admin,
    },
] 

Why are there two different time intervals?

Health/Liveness

Kubernetes ready and liveness probes: /admin/ready and /admin/alive