mirror of https://github.com/grafana/grafana
prometheushacktoberfestmetricsmonitoringalertinggrafanagoinfluxdbmysqlpostgresanalyticsdata-visualizationdashboardbusiness-intelligenceelasticsearch
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
164 lines
6.1 KiB
164 lines
6.1 KiB
|
4 years ago
|
---
|
||
|
|
aliases:
|
||
|
|
- /docs/grafana/latest/auth/azuread/
|
||
|
4 years ago
|
- /docs/grafana/latest/setup-grafana/configure-security/configure-authentication/azuread/
|
||
|
|
description: Grafana Azure AD OAuth Guide
|
||
|
4 years ago
|
keywords:
|
||
|
|
- grafana
|
||
|
|
- configuration
|
||
|
|
- documentation
|
||
|
|
- oauth
|
||
|
4 years ago
|
title: Configure Azure AD OAuth2 authentication
|
||
|
|
weight: 600
|
||
|
4 years ago
|
---
|
||
|
6 years ago
|
|
||
|
4 years ago
|
# Configure Azure AD OAuth2 authentication
|
||
|
6 years ago
|
|
||
|
4 years ago
|
The Azure AD authentication allows you to use an Azure Active Directory tenant as an identity provider for Grafana. You can use Azure AD Application Roles to assign users and groups to Grafana roles from the Azure Portal. This topic has the following sections:
|
||
|
6 years ago
|
|
||
|
4 years ago
|
- [Azure AD OAuth2 authentication](#azure-ad-oauth2-authentication)
|
||
|
4 years ago
|
- [Create the Azure AD application](#create-the-azure-ad-application)
|
||
|
|
- [Enable Azure AD OAuth in Grafana](#enable-azure-ad-oauth-in-grafana)
|
||
|
|
- [Configure allowed groups](#configure-allowed-groups)
|
||
|
|
- [Configure allowed domains](#configure-allowed-domains)
|
||
|
|
- [Team Sync (Enterprise only)](#team-sync-enterprise-only)
|
||
|
6 years ago
|
|
||
|
6 years ago
|
## Create the Azure AD application
|
||
|
6 years ago
|
|
||
|
4 years ago
|
To enable the Azure AD OAuth2, register your application with Azure AD.
|
||
|
6 years ago
|
|
||
|
4 years ago
|
1. Log in to [Azure Portal](https://portal.azure.com), then click **Azure Active Directory** in the side menu.
|
||
|
6 years ago
|
|
||
|
4 years ago
|
1. If you have access to more than one tenant, select your account in the upper right. Set your session to the Azure AD tenant you wish to use.
|
||
|
6 years ago
|
|
||
|
4 years ago
|
1. Under **Manage** in the side menu, click **App Registrations** > **New Registration**. Enter a descriptive name.
|
||
|
6 years ago
|
|
||
|
4 years ago
|
1. Under **Redirect URI**, select the app type **Web**.
|
||
|
6 years ago
|
|
||
|
4 years ago
|
1. Add the following redirect URLs `https://<grafana domain>/login/azuread` and `https://<grafana domain>` then click **Register**. The app's **Overview** page opens.
|
||
|
|
|
||
|
|
1. Note the **Application ID**. This is the OAuth client ID.
|
||
|
6 years ago
|
|
||
|
5 years ago
|
1. Click **Endpoints** from the top menu.
|
||
|
|
|
||
|
4 years ago
|
- Note the **OAuth 2.0 authorization endpoint (v2)** URL. This is the authorization URL.
|
||
|
5 years ago
|
- Note the **OAuth 2.0 token endpoint (v2)**. This is the token URL.
|
||
|
6 years ago
|
|
||
|
4 years ago
|
1. Click **Certificates & secrets**, then add a new entry under **Client secrets** with the following configuration.
|
||
|
6 years ago
|
|
||
|
5 years ago
|
- Description: Grafana OAuth
|
||
|
|
- Expires: Never
|
||
|
|
|
||
|
4 years ago
|
1. Click **Add** then copy the key value. This is the OAuth client secret.
|
||
|
6 years ago
|
|
||
|
4 years ago
|
1. Click **Manifest**, then define the required Application Role values for Grafana: Viewer, Editor, or Admin. If not defined, all users will have the Viewer role. Every role requires a unique ID which you can generate on Linux with `uuidgen`, and on Windows through Microsoft PowerShell with `New-Guid`.
|
||
|
5 years ago
|
|
||
|
4 years ago
|
1. Include the unique ID in the configuration file:
|
||
|
6 years ago
|
|
||
|
4 years ago
|
```json
|
||
|
|
"appRoles": [
|
||
|
|
{
|
||
|
|
"allowedMemberTypes": [
|
||
|
|
"User"
|
||
|
|
],
|
||
|
|
"description": "Grafana admin Users",
|
||
|
|
"displayName": "Grafana Admin",
|
||
|
|
"id": "SOME_UNIQUE_ID",
|
||
|
|
"isEnabled": true,
|
||
|
|
"lang": null,
|
||
|
|
"origin": "Application",
|
||
|
|
"value": "Admin"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"allowedMemberTypes": [
|
||
|
|
"User"
|
||
|
|
],
|
||
|
|
"description": "Grafana read only Users",
|
||
|
|
"displayName": "Grafana Viewer",
|
||
|
|
"id": "SOME_UNIQUE_ID",
|
||
|
|
"isEnabled": true,
|
||
|
|
"lang": null,
|
||
|
|
"origin": "Application",
|
||
|
|
"value": "Viewer"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"allowedMemberTypes": [
|
||
|
|
"User"
|
||
|
|
],
|
||
|
|
"description": "Grafana Editor Users",
|
||
|
|
"displayName": "Grafana Editor",
|
||
|
|
"id": "SOME_UNIQUE_ID",
|
||
|
|
"isEnabled": true,
|
||
|
|
"lang": null,
|
||
|
|
"origin": "Application",
|
||
|
|
"value": "Editor"
|
||
|
|
}
|
||
|
|
],
|
||
|
|
```
|
||
|
6 years ago
|
|
||
|
6 years ago
|
1. Go to **Azure Active Directory** and then to **Enterprise Applications**. Search for your application and click on it.
|
||
|
6 years ago
|
|
||
|
5 years ago
|
1. Click on **Users and Groups** and add Users/Groups to the Grafana roles by using **Add User**.
|
||
|
6 years ago
|
|
||
|
6 years ago
|
## Enable Azure AD OAuth in Grafana
|
||
|
6 years ago
|
|
||
|
4 years ago
|
1. Add the following to the [Grafana configuration file]({{< relref "../../configure-grafana/#config-file-locations" >}}):
|
||
|
6 years ago
|
|
||
|
4 years ago
|
```
|
||
|
6 years ago
|
[auth.azuread]
|
||
|
|
name = Azure AD
|
||
|
|
enabled = true
|
||
|
|
allow_sign_up = true
|
||
|
|
client_id = APPLICATION_ID
|
||
|
|
client_secret = CLIENT_SECRET
|
||
|
|
scopes = openid email profile
|
||
|
|
auth_url = https://login.microsoftonline.com/TENANT_ID/oauth2/v2.0/authorize
|
||
|
|
token_url = https://login.microsoftonline.com/TENANT_ID/oauth2/v2.0/token
|
||
|
6 years ago
|
allowed_domains =
|
||
|
|
allowed_groups =
|
||
|
4 years ago
|
role_attribute_strict = false
|
||
|
6 years ago
|
```
|
||
|
|
|
||
|
4 years ago
|
You can also use these environment variables to configure **client_id** and **client_secret**:
|
||
|
4 years ago
|
|
||
|
4 years ago
|
```
|
||
|
|
GF_AUTH_AZUREAD_CLIENT_ID
|
||
|
|
GF_AUTH_AZUREAD_CLIENT_SECRET
|
||
|
|
```
|
||
|
4 years ago
|
|
||
|
4 years ago
|
**Note:** Verify that the Grafana [root_url]({{< relref "../../configure-grafana/#root-url" >}}) is set in your Azure Application Redirect URLs.
|
||
|
5 years ago
|
|
||
|
|
### Configure allowed groups
|
||
|
6 years ago
|
|
||
|
5 years ago
|
To limit access to authenticated users who are members of one or more groups, set `allowed_groups`
|
||
|
|
to a comma- or space-separated list of group object IDs. You can find object IDs for a specific group on the Azure portal:
|
||
|
6 years ago
|
|
||
|
4 years ago
|
1. Go to **Azure Active Directory -> Groups**. If you want to only give access to members of the group `example` with an ID of `8bab1c86-8fba-33e5-2089-1d1c80ec267d`, then set the following:
|
||
|
6 years ago
|
|
||
|
4 years ago
|
```
|
||
|
|
allowed_groups = 8bab1c86-8fba-33e5-2089-1d1c80ec267d
|
||
|
|
```
|
||
|
6 years ago
|
|
||
|
4 years ago
|
1. Verify that [group attributes](https://docs.microsoft.com/en-us/azure/active-directory/hybrid/how-to-connect-fed-group-claims#configure-the-azure-ad-application-registration-for-group-attributes) is enabled in your Azure AD Application Registration manifest file by navigating to **Azure Portal** > **Azure Active Directory** > **Application Registrations** > **Select Application** -> **Manifest**, and set the following:
|
||
|
6 years ago
|
|
||
|
4 years ago
|
```
|
||
|
|
"groupMembershipClaims": "ApplicationGroup, SecurityGroup"
|
||
|
|
```
|
||
|
6 years ago
|
|
||
|
5 years ago
|
### Configure allowed domains
|
||
|
|
|
||
|
4 years ago
|
The `allowed_domains` option limits access to users who belong to specific domains. Separate domains with space or comma. For example,
|
||
|
6 years ago
|
|
||
|
4 years ago
|
```
|
||
|
6 years ago
|
allowed_domains = mycompany.com mycompany.org
|
||
|
|
```
|
||
|
|
|
||
|
|
### Team Sync (Enterprise only)
|
||
|
|
|
||
|
|
With Team Sync you can map your Azure AD groups to teams in Grafana so that your users will automatically be added to
|
||
|
6 years ago
|
the correct teams.
|
||
|
6 years ago
|
|
||
|
5 years ago
|
You can reference Azure AD groups by group object ID, like `8bab1c86-8fba-33e5-2089-1d1c80ec267d`.
|
||
|
6 years ago
|
|
||
|
4 years ago
|
To learn more, refer to the [Team Sync]({{< relref "../configure-team-sync/" >}}) documentation.
|