<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Configure authentication on Grafana Labs</title><link>https://grafana.com/docs/grafana/v10.4/setup-grafana/configure-security/configure-authentication/</link><description>Recent content in Configure authentication on Grafana Labs</description><generator>Hugo -- gohugo.io</generator><language>en</language><atom:link href="/docs/grafana/v10.4/setup-grafana/configure-security/configure-authentication/index.xml" rel="self" type="application/rss+xml"/><item><title>Configure Grafana authentication</title><link>https://grafana.com/docs/grafana/v10.4/setup-grafana/configure-security/configure-authentication/grafana/</link><pubDate>Fri, 07 Mar 2025 09:39:42 +0000</pubDate><guid>https://grafana.com/docs/grafana/v10.4/setup-grafana/configure-security/configure-authentication/grafana/</guid><content><![CDATA[&lt;h2 id=&#34;configure-grafana-authentication&#34;&gt;Configure Grafana authentication&lt;/h2&gt;
&lt;p&gt;Grafana of course has a built in user authentication system with password authentication enabled by default. You can
disable authentication by enabling anonymous access. You can also hide login form and only allow login through an auth
provider (listed above). There is also options for allowing self sign up.&lt;/p&gt;
&lt;h3 id=&#34;login-and-short-lived-tokens&#34;&gt;Login and short-lived tokens&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;The following applies when using Grafana&amp;rsquo;s built in user authentication, LDAP (without Auth proxy) or OAuth integration.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Grafana uses short-lived tokens as a mechanism for verifying authenticated users.
These short-lived tokens are rotated each &lt;code&gt;token_rotation_interval_minutes&lt;/code&gt; for an active authenticated user.&lt;/p&gt;
&lt;p&gt;An active authenticated user that gets it token rotated will extend the &lt;code&gt;login_maximum_inactive_lifetime_duration&lt;/code&gt; time from &amp;ldquo;now&amp;rdquo; that Grafana will remember the user.
This means that a user can close its browser and come back before &lt;code&gt;now &#43; login_maximum_inactive_lifetime_duration&lt;/code&gt; and still being authenticated.
This is true as long as the time since user login is less than &lt;code&gt;login_maximum_lifetime_duration&lt;/code&gt;.&lt;/p&gt;
&lt;h4 id=&#34;remote-logout&#34;&gt;Remote logout&lt;/h4&gt;
&lt;p&gt;You can logout from other devices by removing login sessions from the bottom of your profile page. If you are
a Grafana admin user you can also do the same for any user from the Server Admin / Edit User view.&lt;/p&gt;
&lt;h2 id=&#34;settings&#34;&gt;Settings&lt;/h2&gt;
&lt;p&gt;Example:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;[auth]

# Login cookie name
login_cookie_name = grafana_session

# The lifetime (days) an authenticated user can be inactive before being required to login at next visit. Default is 7 days.
login_maximum_inactive_lifetime_duration = 7d

# The maximum lifetime (days) an authenticated user can be logged in since login time before being required to login. Default is 30 days.
login_maximum_lifetime_duration = 30d

# How often should auth tokens be rotated for authenticated users when being active. The default is each 10 minutes.
token_rotation_interval_minutes = 10

# The maximum lifetime (seconds) an api key can be used. If it is set all the api keys should have limited lifetime that is lower than this value.
api_key_max_seconds_to_live = -1&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;anonymous-authentication&#34;&gt;Anonymous authentication&lt;/h3&gt;
&lt;p&gt;You can make Grafana accessible without any login required by enabling anonymous access in the configuration file. For more information, refer to &lt;a href=&#34;../#anonymous-authentication&#34;&gt;Anonymous authentication&lt;/a&gt;.&lt;/p&gt;
&lt;h4 id=&#34;anonymous-devices&#34;&gt;Anonymous devices&lt;/h4&gt;
&lt;p&gt;The anonymous devices feature enhances the management and monitoring of anonymous access within your Grafana instance. This feature is part of ongoing efforts to provide more control and transparency over anonymous usage.&lt;/p&gt;
&lt;p&gt;Users can now view anonymous usage statistics, including the count of devices and users over the last 30 days.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Go to &lt;strong&gt;Administration -&amp;gt; Users&lt;/strong&gt; to access the anonymous devices tab.&lt;/li&gt;
&lt;li&gt;A new stat for the usage stats page -&amp;gt; Usage &amp;amp; Stats page shows the active anonymous devices last 30 days.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The number of anonymous devices is not limited by default. The configuration option &lt;code&gt;device_limit&lt;/code&gt; allows you to enforce a limit on the number of anonymous devices. This enables you to have greater control over the usage within your Grafana instance and keep the usage within the limits of your environment. Once the limit is reached, any new devices that try to access Grafana will be denied access.&lt;/p&gt;
&lt;h4 id=&#34;anonymous-users&#34;&gt;Anonymous users&lt;/h4&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Anonymous users are charged as active users in Grafana Enterprise&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h4 id=&#34;configuration&#34;&gt;Configuration&lt;/h4&gt;
&lt;p&gt;Example:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;[auth.anonymous]
enabled = true

# Organization name that should be used for unauthenticated users
org_name = Main Org.

# Role for unauthenticated users, other valid values are `Editor` and `Admin`
org_role = Viewer

# Hide the Grafana version text from the footer and help tooltip for unauthenticated users (default: false)
hide_version = true

# Setting this limits the number of anonymous devices in your instance. Any new anonymous devices added after the limit has been reached will be denied access.
device_limit =&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;If you change your organization name in the Grafana UI this setting needs to be updated to match the new name.&lt;/p&gt;
&lt;h3 id=&#34;basic-authentication&#34;&gt;Basic authentication&lt;/h3&gt;
&lt;p&gt;Basic auth is enabled by default and works with the built in Grafana user password authentication system and LDAP
authentication integration.&lt;/p&gt;
&lt;p&gt;To disable basic auth:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;[auth.basic]
enabled = false&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;disable-login-form&#34;&gt;Disable login form&lt;/h3&gt;
&lt;p&gt;You can hide the Grafana login form using the below configuration settings.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;[auth]
disable_login_form = true&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;automatic-oauth-login&#34;&gt;Automatic OAuth login&lt;/h3&gt;
&lt;p&gt;Set to true to attempt login with specific OAuth provider automatically, skipping the login screen.
This setting is ignored if multiple auth providers are configured to use auto login.
Defaults to &lt;code&gt;false&lt;/code&gt;.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;[auth.generic_oauth]
auto_login = true&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;hide-sign-out-menu&#34;&gt;Hide sign-out menu&lt;/h3&gt;
&lt;p&gt;Set the option detailed below to true to hide sign-out menu link. Useful if you use an auth proxy or JWT authentication.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;[auth]
disable_signout_menu = true&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;url-redirect-after-signing-out&#34;&gt;URL redirect after signing out&lt;/h3&gt;
&lt;p&gt;The URL to redirect the user to after signing out from Grafana can be configured under &lt;code&gt;[auth]&lt;/code&gt; or under a specific OAuth provider section (for example, &lt;code&gt;[auth.generic_oauth]&lt;/code&gt;). The URL configured under a specific OAuth provider section takes precedence over the URL configured in &lt;code&gt;[auth]&lt;/code&gt; section. This can, for example, enable signout from the OAuth provider.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;[auth.generic_oauth]
signout_redirect_url =

[auth]
signout_redirect_url =&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;protected-roles&#34;&gt;Protected roles&lt;/h3&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Available in &lt;a href=&#34;../../../../introduction/grafana-enterprise/&#34;&gt;Grafana Enterprise&lt;/a&gt; and &lt;a href=&#34;../../../../introduction/grafana-cloud/&#34;&gt;Grafana Cloud&lt;/a&gt;.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;By default, after you configure an authorization provider, Grafana will adopt existing users into the new authentication scheme. For example, if you have created a user with basic authentication having the login &lt;code&gt;jsmith@example.com&lt;/code&gt;, then set up SAML authentication where &lt;code&gt;jsmith@example.com&lt;/code&gt; is an account, the user&amp;rsquo;s authentication type will be changed to SAML if they perform a SAML sign-in.&lt;/p&gt;
&lt;p&gt;You can disable this user adoption for certain roles using the &lt;code&gt;protected_roles&lt;/code&gt; property:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;[auth.security]
protected_roles = server_admins org_admins&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The value of &lt;code&gt;protected_roles&lt;/code&gt; should be a list of roles to protect, separated by spaces. Valid roles are &lt;code&gt;viewers&lt;/code&gt;, &lt;code&gt;editors&lt;/code&gt;, &lt;code&gt;org_admins&lt;/code&gt;, &lt;code&gt;server_admins&lt;/code&gt;, and &lt;code&gt;all&lt;/code&gt; (a superset of the other roles).&lt;/p&gt;
]]></content><description>&lt;h2 id="configure-grafana-authentication">Configure Grafana authentication&lt;/h2>
&lt;p>Grafana of course has a built in user authentication system with password authentication enabled by default. You can
disable authentication by enabling anonymous access. You can also hide login form and only allow login through an auth
provider (listed above). There is also options for allowing self sign up.&lt;/p></description></item><item><title>Configure LDAP authentication</title><link>https://grafana.com/docs/grafana/v10.4/setup-grafana/configure-security/configure-authentication/ldap/</link><pubDate>Fri, 07 Mar 2025 09:39:42 +0000</pubDate><guid>https://grafana.com/docs/grafana/v10.4/setup-grafana/configure-security/configure-authentication/ldap/</guid><content><![CDATA[&lt;h1 id=&#34;configure-ldap-authentication&#34;&gt;Configure LDAP authentication&lt;/h1&gt;
&lt;p&gt;The LDAP integration in Grafana allows your Grafana users to login with their LDAP credentials. You can also specify mappings between LDAP
group memberships and Grafana Organization user roles.&lt;/p&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;&lt;a href=&#34;../enhanced-ldap/&#34;&gt;Enhanced LDAP authentication&lt;/a&gt; is available in &lt;a href=&#34;/docs/grafana-cloud/&#34;&gt;Grafana Cloud&lt;/a&gt; and in &lt;a href=&#34;../../../../introduction/grafana-enterprise/&#34;&gt;Grafana Enterprise&lt;/a&gt;.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;Refer to &lt;a href=&#34;../../../../administration/roles-and-permissions/access-control/&#34;&gt;Role-based access control&lt;/a&gt; to understand how you can control access with role-based permissions.&lt;/p&gt;
&lt;h2 id=&#34;supported-ldap-servers&#34;&gt;Supported LDAP Servers&lt;/h2&gt;
&lt;p&gt;Grafana uses a &lt;a href=&#34;https://github.com/go-ldap/ldap&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;third-party LDAP library&lt;/a&gt; under the hood that supports basic LDAP v3 functionality.
This means that you should be able to configure LDAP integration using any compliant LDAPv3 server, for example &lt;a href=&#34;#openldap&#34;&gt;OpenLDAP&lt;/a&gt; or
&lt;a href=&#34;#active-directory&#34;&gt;Active Directory&lt;/a&gt; among &lt;a href=&#34;https://en.wikipedia.org/wiki/Directory_service#LDAP_implementations&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;others&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;enable-ldap&#34;&gt;Enable LDAP&lt;/h2&gt;
&lt;p&gt;In order to use LDAP integration you&amp;rsquo;ll first need to enable LDAP in the &lt;a href=&#34;../../../configure-grafana/&#34;&gt;main config file&lt;/a&gt; as well as specify the path to the LDAP
specific configuration file (default: &lt;code&gt;/etc/grafana/ldap.toml&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;After enabling LDAP, the default behavior is for Grafana users to be created automatically upon successful LDAP authentication. If you prefer for only existing Grafana users to be able to sign in, you can change &lt;code&gt;allow_sign_up&lt;/code&gt; to &lt;code&gt;false&lt;/code&gt; in the &lt;code&gt;[auth.ldap]&lt;/code&gt; section.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;ini&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-ini&#34;&gt;[auth.ldap]
# Set to `true` to enable LDAP integration (default: `false`)
enabled = true

# Path to the LDAP specific configuration file (default: `/etc/grafana/ldap.toml`)
config_file = /etc/grafana/ldap.toml

# Allow sign-up should be `true` (default) to allow Grafana to create users on successful LDAP authentication.
# If set to `false` only already existing Grafana users will be able to login.
allow_sign_up = true&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;disable-org-role-synchronization&#34;&gt;Disable org role synchronization&lt;/h2&gt;
&lt;p&gt;If you use LDAP to authenticate users but don&amp;rsquo;t use role mapping, and prefer to manually assign organizations
and roles, you can use the &lt;code&gt;skip_org_role_sync&lt;/code&gt; configuration option.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;ini&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-ini&#34;&gt;[auth.ldap]
# Set to `true` to enable LDAP integration (default: `false`)
enabled = true

# Path to the LDAP specific configuration file (default: `/etc/grafana/ldap.toml`)
config_file = /etc/grafana/ldap.toml

# Allow sign-up should be `true` (default) to allow Grafana to create users on successful LDAP authentication.
# If set to `false` only already existing Grafana users will be able to login.
allow_sign_up = true

# Prevent synchronizing ldap users organization roles
skip_org_role_sync = true&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;grafana-ldap-configuration&#34;&gt;Grafana LDAP Configuration&lt;/h2&gt;
&lt;p&gt;Depending on which LDAP server you&amp;rsquo;re using and how that&amp;rsquo;s configured your Grafana LDAP configuration may vary.
See &lt;a href=&#34;#configuration-examples&#34;&gt;configuration examples&lt;/a&gt; for more information.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;LDAP specific configuration file (ldap.toml) example:&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;[[servers]]
# Ldap server host (specify multiple hosts space separated)
host = &amp;#34;ldap.my_secure_remote_server.org&amp;#34;
# Default port is 389 or 636 if use_ssl = true
port = 636
# Set to true if LDAP server should use an encrypted TLS connection (either with STARTTLS or LDAPS)
use_ssl = true
# If set to true, use LDAP with STARTTLS instead of LDAPS
start_tls = false
# The value of an accepted TLS cipher. By default, this value is empty. Example value: [&amp;#34;TLS_AES_256_GCM_SHA384&amp;#34;])
# For a complete list of supported ciphers and TLS versions, refer to: https://go.dev/src/crypto/tls/cipher_suites.go
tls_ciphers = []
# This is the minimum TLS version allowed. By default, this value is empty. Accepted values are: TLS1.1, TLS1.2, TLS1.3.
min_tls_version = &amp;#34;&amp;#34;
# set to true if you want to skip SSL cert validation
ssl_skip_verify = false
# set to the path to your root CA certificate or leave unset to use system defaults
# root_ca_cert = &amp;#34;/path/to/certificate.crt&amp;#34;
# Authentication against LDAP servers requiring client certificates
# client_cert = &amp;#34;/path/to/client.crt&amp;#34;
# client_key = &amp;#34;/path/to/client.key&amp;#34;

# Search user bind dn
bind_dn = &amp;#34;cn=admin,dc=grafana,dc=org&amp;#34;
# Search user bind password
# If the password contains # or ; you have to wrap it with triple quotes. Ex &amp;#34;&amp;#34;&amp;#34;#password;&amp;#34;&amp;#34;&amp;#34;
bind_password = &amp;#34;grafana&amp;#34;
# We recommend using variable expansion for the bind_password, for more info https://grafana.com/docs/grafana/latest/setup-grafana/configure-grafana/#variable-expansion
# bind_password = &amp;#39;$__env{LDAP_BIND_PASSWORD}&amp;#39;

# Timeout in seconds. Applies to each host specified in the &amp;#39;host&amp;#39; entry (space separated).
timeout = 10

# User search filter, for example &amp;#34;(cn=%s)&amp;#34; or &amp;#34;(sAMAccountName=%s)&amp;#34; or &amp;#34;(uid=%s)&amp;#34;
# Allow login from email or username, example &amp;#34;(|(sAMAccountName=%s)(userPrincipalName=%s))&amp;#34;
search_filter = &amp;#34;(cn=%s)&amp;#34;

# An array of base dns to search through
search_base_dns = [&amp;#34;dc=grafana,dc=org&amp;#34;]

# group_search_filter = &amp;#34;(&amp;amp;(objectClass=posixGroup)(memberUid=%s))&amp;#34;
# group_search_filter_user_attribute = &amp;#34;distinguishedName&amp;#34;
# group_search_base_dns = [&amp;#34;ou=groups,dc=grafana,dc=org&amp;#34;]

# Specify names of the LDAP attributes your LDAP uses
[servers.attributes]
member_of = &amp;#34;memberOf&amp;#34;
email =  &amp;#34;email&amp;#34;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Whenever you modify the ldap.toml file, you must restart Grafana in order for the change(s) to take effect.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h3 id=&#34;using-environment-variables&#34;&gt;Using environment variables&lt;/h3&gt;
&lt;p&gt;You can interpolate variables in the TOML configuration from environment variables. For instance, you could externalize your &lt;code&gt;bind_password&lt;/code&gt; that way:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;bind_password = &amp;#34;${LDAP_ADMIN_PASSWORD}&amp;#34;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;ldap-debug-view&#34;&gt;LDAP debug view&lt;/h2&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Available in Grafana v6.4&#43;&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;Grafana has an LDAP debug view built-in which allows you to test your LDAP configuration directly within Grafana. Only Grafana admins can use the LDAP debug view.&lt;/p&gt;
&lt;p&gt;Within this view, you&amp;rsquo;ll be able to see which LDAP servers are currently reachable and test your current configuration.&lt;/p&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow&#34;
    style=&#34;max-width: 600px;&#34;
    itemprop=&#34;associatedMedia&#34;
    itemscope=&#34;&#34;
    itemtype=&#34;http://schema.org/ImageObject&#34;
  &gt;&lt;a
        class=&#34;lightbox-link&#34;
        href=&#34;/static/img/docs/ldap_debug.png&#34;
        itemprop=&#34;contentUrl&#34;
      &gt;&lt;div class=&#34;img-wrapper w-100p h-auto&#34;&gt;&lt;img
          class=&#34;lazyload &#34;
          data-src=&#34;/static/img/docs/ldap_debug.png&#34;data-srcset=&#34;/static/img/docs/ldap_debug.png?w=320 320w, /static/img/docs/ldap_debug.png?w=550 550w, /static/img/docs/ldap_debug.png?w=750 750w, /static/img/docs/ldap_debug.png?w=900 900w, /static/img/docs/ldap_debug.png?w=1040 1040w, /static/img/docs/ldap_debug.png?w=1240 1240w, /static/img/docs/ldap_debug.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;LDAP testing&#34;width=&#34;971&#34;height=&#34;436&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/ldap_debug.png&#34;
            alt=&#34;LDAP testing&#34;width=&#34;971&#34;height=&#34;436&#34;class=&#34;docs-image--no-shadow&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;p&gt;To use the debug view, complete the following steps:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Type the username of a user that exists within any of your LDAP server(s)&lt;/li&gt;
&lt;li&gt;Then, press &amp;ldquo;Run&amp;rdquo;&lt;/li&gt;
&lt;li&gt;If the user is found within any of your LDAP instances, the mapping information is displayed.&lt;/li&gt;
&lt;/ol&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow&#34;
    style=&#34;max-width: 600px;&#34;
    itemprop=&#34;associatedMedia&#34;
    itemscope=&#34;&#34;
    itemtype=&#34;http://schema.org/ImageObject&#34;
  &gt;&lt;a
        class=&#34;lightbox-link&#34;
        href=&#34;/static/img/docs/ldap_debug_mapping_testing.png&#34;
        itemprop=&#34;contentUrl&#34;
      &gt;&lt;div class=&#34;img-wrapper w-100p h-auto&#34;&gt;&lt;img
          class=&#34;lazyload &#34;
          data-src=&#34;/static/img/docs/ldap_debug_mapping_testing.png&#34;data-srcset=&#34;/static/img/docs/ldap_debug_mapping_testing.png?w=320 320w, /static/img/docs/ldap_debug_mapping_testing.png?w=550 550w, /static/img/docs/ldap_debug_mapping_testing.png?w=750 750w, /static/img/docs/ldap_debug_mapping_testing.png?w=900 900w, /static/img/docs/ldap_debug_mapping_testing.png?w=1040 1040w, /static/img/docs/ldap_debug_mapping_testing.png?w=1240 1240w, /static/img/docs/ldap_debug_mapping_testing.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;LDAP mapping displayed&#34;width=&#34;1046&#34;height=&#34;762&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/ldap_debug_mapping_testing.png&#34;
            alt=&#34;LDAP mapping displayed&#34;width=&#34;1046&#34;height=&#34;762&#34;class=&#34;docs-image--no-shadow&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;p&gt;&lt;a href=&#34;../../../../introduction/grafana-enterprise/&#34;&gt;Grafana Enterprise&lt;/a&gt; users with &lt;a href=&#34;../enhanced-ldap/&#34;&gt;enhanced LDAP integration&lt;/a&gt; enabled can also see sync status in the debug view. This requires the &lt;code&gt;ldap.status:read&lt;/code&gt; permission.&lt;/p&gt;
&lt;figure
    class=&#34;figure-wrapper figure-wrapper__lightbox w-100p docs-image--no-shadow&#34;
    style=&#34;max-width: 600px;&#34;
    itemprop=&#34;associatedMedia&#34;
    itemscope=&#34;&#34;
    itemtype=&#34;http://schema.org/ImageObject&#34;
  &gt;&lt;a
        class=&#34;lightbox-link&#34;
        href=&#34;/static/img/docs/ldap_sync_debug.png&#34;
        itemprop=&#34;contentUrl&#34;
      &gt;&lt;div class=&#34;img-wrapper w-100p h-auto&#34;&gt;&lt;img
          class=&#34;lazyload &#34;
          data-src=&#34;/static/img/docs/ldap_sync_debug.png&#34;data-srcset=&#34;/static/img/docs/ldap_sync_debug.png?w=320 320w, /static/img/docs/ldap_sync_debug.png?w=550 550w, /static/img/docs/ldap_sync_debug.png?w=750 750w, /static/img/docs/ldap_sync_debug.png?w=900 900w, /static/img/docs/ldap_sync_debug.png?w=1040 1040w, /static/img/docs/ldap_sync_debug.png?w=1240 1240w, /static/img/docs/ldap_sync_debug.png?w=1920 1920w&#34;data-sizes=&#34;auto&#34;alt=&#34;LDAP sync status&#34;width=&#34;1242&#34;height=&#34;374&#34;/&gt;
        &lt;noscript&gt;
          &lt;img
            src=&#34;/static/img/docs/ldap_sync_debug.png&#34;
            alt=&#34;LDAP sync status&#34;width=&#34;1242&#34;height=&#34;374&#34;class=&#34;docs-image--no-shadow&#34;/&gt;
        &lt;/noscript&gt;&lt;/div&gt;&lt;/a&gt;&lt;/figure&gt;
&lt;h3 id=&#34;bind-and-bind-password&#34;&gt;Bind and bind password&lt;/h3&gt;
&lt;p&gt;By default the configuration expects you to specify a bind DN and bind password. This should be a read only user that can perform LDAP searches.
When the user DN is found a second bind is performed with the user provided username and password (in the normal Grafana login form).&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;bind_dn = &amp;#34;cn=admin,dc=grafana,dc=org&amp;#34;
bind_password = &amp;#34;grafana&amp;#34;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;single-bind-example&#34;&gt;Single bind example&lt;/h4&gt;
&lt;p&gt;If you can provide a single bind expression that matches all possible users, you can skip the second bind and bind against the user DN directly.
This allows you to not specify a bind_password in the configuration file.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;bind_dn = &amp;#34;cn=%s,o=users,dc=grafana,dc=org&amp;#34;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;In this case you skip providing a &lt;code&gt;bind_password&lt;/code&gt; and instead provide a &lt;code&gt;bind_dn&lt;/code&gt; value with a &lt;code&gt;%s&lt;/code&gt; somewhere. This will be replaced with the username entered in on the Grafana login page.
The search filter and search bases settings are still needed to perform the LDAP search to retrieve the other LDAP information (like LDAP groups and email).&lt;/p&gt;
&lt;h3 id=&#34;posix-schema&#34;&gt;POSIX schema&lt;/h3&gt;
&lt;p&gt;If your LDAP server does not support the &lt;code&gt;memberOf&lt;/code&gt; attribute, add the following options:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;## Group search filter, to retrieve the groups of which the user is a member (only set if memberOf attribute is not available)
group_search_filter = &amp;#34;(&amp;amp;(objectClass=posixGroup)(memberUid=%s))&amp;#34;
## An array of the base DNs to search through for groups. Typically uses ou=groups
group_search_base_dns = [&amp;#34;ou=groups,dc=grafana,dc=org&amp;#34;]
## the %s in the search filter will be replaced with the attribute defined below
group_search_filter_user_attribute = &amp;#34;uid&amp;#34;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;group-mappings&#34;&gt;Group mappings&lt;/h3&gt;
&lt;p&gt;In &lt;code&gt;[[servers.group_mappings]]&lt;/code&gt; you can map an LDAP group to a Grafana organization and role. These will be synced every time the user logs in, with LDAP being the authoritative source.&lt;/p&gt;
&lt;p&gt;The first group mapping that an LDAP user is matched to will be used for the sync. If you have LDAP users that fit multiple mappings, the topmost mapping in the TOML configuration will be used.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;LDAP specific configuration file (ldap.toml) example:&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;[[servers]]
# other settings omitted for clarity

[[servers.group_mappings]]
group_dn = &amp;#34;cn=superadmins,dc=grafana,dc=org&amp;#34;
org_role = &amp;#34;Admin&amp;#34;
grafana_admin = true # Available in Grafana v5.3 and above

[[servers.group_mappings]]
group_dn = &amp;#34;cn=admins,dc=grafana,dc=org&amp;#34;
org_role = &amp;#34;Admin&amp;#34;

[[servers.group_mappings]]
group_dn = &amp;#34;cn=users,dc=grafana,dc=org&amp;#34;
org_role = &amp;#34;Editor&amp;#34;

[[servers.group_mappings]]
group_dn = &amp;#34;*&amp;#34;
org_role = &amp;#34;Viewer&amp;#34;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Setting&lt;/th&gt;
              &lt;th&gt;Required&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Default&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;group_dn&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Yes&lt;/td&gt;
              &lt;td&gt;LDAP distinguished name (DN) of LDAP group. If you want to match all (or no LDAP groups) then you can use wildcard (&lt;code&gt;&amp;quot;*&amp;quot;&lt;/code&gt;)&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;org_role&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Yes&lt;/td&gt;
              &lt;td&gt;Assign users of &lt;code&gt;group_dn&lt;/code&gt; the organization role &lt;code&gt;Admin&lt;/code&gt;, &lt;code&gt;Editor&lt;/code&gt;, or &lt;code&gt;Viewer&lt;/code&gt;. The organization role name is case sensitive.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;org_id&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;The Grafana organization database id. Setting this allows for multiple group_dn&amp;rsquo;s to be assigned to the same &lt;code&gt;org_role&lt;/code&gt; provided the &lt;code&gt;org_id&lt;/code&gt; differs&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;1&lt;/code&gt; (default org id)&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;grafana_admin&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;When &lt;code&gt;true&lt;/code&gt; makes user of &lt;code&gt;group_dn&lt;/code&gt; Grafana server admin. A Grafana server admin has admin access over all organizations and users. Available in Grafana v5.3 and above&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;false&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;

&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Commenting out a group mapping requires also commenting out the header of
said group or it will fail validation as an empty mapping.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;[[servers]]
# other settings omitted for clarity

[[servers.group_mappings]]
group_dn = &amp;#34;cn=superadmins,dc=grafana,dc=org&amp;#34;
org_role = &amp;#34;Admin&amp;#34;
grafana_admin = true # Available in Grafana v5.3 and above

# [[servers.group_mappings]]
# group_dn = &amp;#34;cn=admins,dc=grafana,dc=org&amp;#34;
# org_role = &amp;#34;Admin&amp;#34;

[[servers.group_mappings]]
group_dn = &amp;#34;cn=users,dc=grafana,dc=org&amp;#34;
org_role = &amp;#34;Editor&amp;#34;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;nestedrecursive-group-membership&#34;&gt;Nested/recursive group membership&lt;/h3&gt;
&lt;p&gt;Users with nested/recursive group membership must have an LDAP server that supports &lt;code&gt;LDAP_MATCHING_RULE_IN_CHAIN&lt;/code&gt;
and configure &lt;code&gt;group_search_filter&lt;/code&gt; in a way that it returns the groups the submitted username is a member of.&lt;/p&gt;
&lt;p&gt;To configure &lt;code&gt;group_search_filter&lt;/code&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;You can set &lt;code&gt;group_search_base_dns&lt;/code&gt; to specify where the matching groups are defined.&lt;/li&gt;
&lt;li&gt;If you do not use &lt;code&gt;group_search_base_dns&lt;/code&gt;, then the previously defined &lt;code&gt;search_base_dns&lt;/code&gt; is used.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Active Directory example:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Active Directory groups store the Distinguished Names (DNs) of members, so your filter will need to know the DN for the user based only on the submitted username.
Multiple DN templates are searched by combining filters with the LDAP OR-operator. Two examples:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;group_search_filter = &amp;#34;(member:1.2.840.113556.1.4.1941:=%s)&amp;#34;
group_search_base_dns = [&amp;#34;DC=mycorp,DC=mytld&amp;#34;]
group_search_filter_user_attribute = &amp;#34;dn&amp;#34;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;group_search_filter = &amp;#34;(member:1.2.840.113556.1.4.1941:=CN=%s,[user container/OU])&amp;#34;
group_search_filter = &amp;#34;(|(member:1.2.840.113556.1.4.1941:=CN=%s,[user container/OU])(member:1.2.840.113556.1.4.1941:=CN=%s,[another user container/OU]))&amp;#34;
group_search_filter_user_attribute = &amp;#34;cn&amp;#34;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;For more information on AD searches see &lt;a href=&#34;https://docs.microsoft.com/en-us/windows/desktop/adsi/search-filter-syntax&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Microsoft&amp;rsquo;s Search Filter Syntax&lt;/a&gt; documentation.&lt;/p&gt;
&lt;p&gt;For troubleshooting, changing &lt;code&gt;member_of&lt;/code&gt; in &lt;code&gt;[servers.attributes]&lt;/code&gt; to &amp;ldquo;dn&amp;rdquo; will show you more accurate group memberships when &lt;a href=&#34;#troubleshooting&#34;&gt;debug is enabled&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;configuration-examples&#34;&gt;Configuration examples&lt;/h2&gt;
&lt;p&gt;The following examples describe different LDAP configuration options.&lt;/p&gt;
&lt;h3 id=&#34;openldap&#34;&gt;OpenLDAP&lt;/h3&gt;
&lt;p&gt;&lt;a href=&#34;http://www.openldap.org/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;OpenLDAP&lt;/a&gt; is an open source directory service.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;LDAP specific configuration file (ldap.toml):&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;[[servers]]
host = &amp;#34;127.0.0.1&amp;#34;
port = 389
use_ssl = false
start_tls = false
ssl_skip_verify = false
bind_dn = &amp;#34;cn=admin,dc=grafana,dc=org&amp;#34;
bind_password = &amp;#34;grafana&amp;#34;
search_filter = &amp;#34;(cn=%s)&amp;#34;
search_base_dns = [&amp;#34;dc=grafana,dc=org&amp;#34;]

[servers.attributes]
member_of = &amp;#34;memberOf&amp;#34;
email =  &amp;#34;email&amp;#34;

# [[servers.group_mappings]] omitted for clarity&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;multiple-ldap-servers&#34;&gt;Multiple LDAP servers&lt;/h3&gt;
&lt;p&gt;Grafana does support receiving information from multiple LDAP servers.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;LDAP specific configuration file (ldap.toml):&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;# --- First LDAP Server ---

[[servers]]
host = &amp;#34;10.0.0.1&amp;#34;
port = 389
use_ssl = false
start_tls = false
ssl_skip_verify = false
bind_dn = &amp;#34;cn=admin,dc=grafana,dc=org&amp;#34;
bind_password = &amp;#34;grafana&amp;#34;
search_filter = &amp;#34;(cn=%s)&amp;#34;
search_base_dns = [&amp;#34;ou=users,dc=grafana,dc=org&amp;#34;]

[servers.attributes]
member_of = &amp;#34;memberOf&amp;#34;
email =  &amp;#34;email&amp;#34;

[[servers.group_mappings]]
group_dn = &amp;#34;cn=admins,ou=groups,dc=grafana,dc=org&amp;#34;
org_role = &amp;#34;Admin&amp;#34;
grafana_admin = true

# --- Second LDAP Server ---

[[servers]]
host = &amp;#34;10.0.0.2&amp;#34;
port = 389
use_ssl = false
start_tls = false
ssl_skip_verify = false

bind_dn = &amp;#34;cn=admin,dc=grafana,dc=org&amp;#34;
bind_password = &amp;#34;grafana&amp;#34;
search_filter = &amp;#34;(cn=%s)&amp;#34;
search_base_dns = [&amp;#34;ou=users,dc=grafana,dc=org&amp;#34;]

[servers.attributes]
member_of = &amp;#34;memberOf&amp;#34;
email =  &amp;#34;email&amp;#34;

[[servers.group_mappings]]
group_dn = &amp;#34;cn=editors,ou=groups,dc=grafana,dc=org&amp;#34;
org_role = &amp;#34;Editor&amp;#34;

[[servers.group_mappings]]
group_dn = &amp;#34;*&amp;#34;
org_role = &amp;#34;Viewer&amp;#34;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;active-directory&#34;&gt;Active Directory&lt;/h3&gt;
&lt;p&gt;&lt;a href=&#34;https://technet.microsoft.com/en-us/library/hh831484%28v=ws.11%29.aspx&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Active Directory&lt;/a&gt; is a directory service which is commonly used in Windows environments.&lt;/p&gt;
&lt;p&gt;Assuming the following Active Directory server setup:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;IP address: &lt;code&gt;10.0.0.1&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Domain: &lt;code&gt;CORP&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;DNS name: &lt;code&gt;corp.local&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;LDAP specific configuration file (ldap.toml):&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;[[servers]]
host = &amp;#34;10.0.0.1&amp;#34;
port = 3269
use_ssl = true
start_tls = false
ssl_skip_verify = true
bind_dn = &amp;#34;CORP\\%s&amp;#34;
search_filter = &amp;#34;(sAMAccountName=%s)&amp;#34;
search_base_dns = [&amp;#34;dc=corp,dc=local&amp;#34;]

[servers.attributes]
member_of = &amp;#34;memberOf&amp;#34;
email =  &amp;#34;mail&amp;#34;

# [[servers.group_mappings]] omitted for clarity&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;port-requirements&#34;&gt;Port requirements&lt;/h4&gt;
&lt;p&gt;In above example SSL is enabled and an encrypted port have been configured. If your Active Directory don&amp;rsquo;t support SSL please change &lt;code&gt;enable_ssl = false&lt;/code&gt; and &lt;code&gt;port = 389&lt;/code&gt;.
Please inspect your Active Directory configuration and documentation to find the correct settings. For more information about Active Directory and port requirements see &lt;a href=&#34;https://technet.microsoft.com/en-us/library/dd772723%28v=ws.10%29&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;link&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;troubleshooting&#34;&gt;Troubleshooting&lt;/h2&gt;
&lt;p&gt;To troubleshoot and get more log info enable LDAP debug logging in the &lt;a href=&#34;../../../configure-grafana/&#34;&gt;main config file&lt;/a&gt;.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;[log]
filters = ldap:debug&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="configure-ldap-authentication">Configure LDAP authentication&lt;/h1>
&lt;p>The LDAP integration in Grafana allows your Grafana users to login with their LDAP credentials. You can also specify mappings between LDAP
group memberships and Grafana Organization user roles.&lt;/p></description></item><item><title>Configure enhanced LDAP integration</title><link>https://grafana.com/docs/grafana/v10.4/setup-grafana/configure-security/configure-authentication/enhanced-ldap/</link><pubDate>Fri, 07 Mar 2025 09:39:42 +0000</pubDate><guid>https://grafana.com/docs/grafana/v10.4/setup-grafana/configure-security/configure-authentication/enhanced-ldap/</guid><content><![CDATA[&lt;h1 id=&#34;configure-enhanced-ldap-integration&#34;&gt;Configure enhanced LDAP integration&lt;/h1&gt;
&lt;p&gt;The enhanced LDAP integration adds additional functionality on top of the &lt;a href=&#34;../ldap/&#34;&gt;LDAP integration&lt;/a&gt; available in the open source edition of Grafana.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Available in &lt;a href=&#34;../../../../introduction/grafana-enterprise/&#34;&gt;Grafana Enterprise&lt;/a&gt; and &lt;a href=&#34;/docs/grafana-cloud/&#34;&gt;Grafana Cloud&lt;/a&gt;.
If you are a Grafana Cloud customer, please &lt;a href=&#34;/profile/org#support&#34;&gt;open a support ticket in the Cloud Portal&lt;/a&gt; to request this feature.&lt;/p&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;To control user access with role-based permissions, refer to &lt;a href=&#34;../../../../administration/roles-and-permissions/access-control/&#34;&gt;role-based access control&lt;/a&gt;.&lt;/p&gt;&lt;/blockquote&gt;
&lt;h2 id=&#34;ldap-group-synchronization-for-teams&#34;&gt;LDAP group synchronization for teams&lt;/h2&gt;
&lt;p&gt;With enhanced LDAP integration, you can set up synchronization between LDAP groups and teams. This enables LDAP users that are members
of certain LDAP groups to automatically be added or removed as members to certain teams in Grafana.&lt;/p&gt;
&lt;p&gt;&lt;img
  class=&#34;lazyload d-inline-block&#34;
  data-src=&#34;/static/img/docs/enterprise/team_members_ldap.png&#34;
  alt=&#34;LDAP group synchronization&#34; width=&#34;979&#34;
     height=&#34;382&#34;/&gt;&lt;/p&gt;
&lt;p&gt;Grafana keeps track of all synchronized users in teams, and you can see which users have been synchronized from LDAP in the team members list, see &lt;code&gt;LDAP&lt;/code&gt; label in screenshot.
This mechanism allows Grafana to remove an existing synchronized user from a team when its LDAP group membership changes. This mechanism also allows you to manually add
a user as member of a team, and it will not be removed when the user signs in. This gives you flexibility to combine LDAP group memberships and Grafana team memberships.&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;../../configure-team-sync/&#34;&gt;Learn more about team sync.&lt;/a&gt;&lt;/p&gt;
&lt;div class=&#34;clearfix&#34;&gt;&lt;/div&gt;
&lt;h2 id=&#34;active-ldap-synchronization&#34;&gt;Active LDAP synchronization&lt;/h2&gt;
&lt;p&gt;In the open source version of Grafana, user data from LDAP is synchronized only during the login process when authenticating using LDAP.&lt;/p&gt;
&lt;p&gt;With active LDAP synchronization, available in Grafana Enterprise version 6.3 and later, you can configure Grafana to actively sync users with LDAP servers in the background. Only users that have logged into Grafana at least once are synchronized.&lt;/p&gt;
&lt;p&gt;Users with updated role and team membership will need to refresh the page to get access to the new features.&lt;/p&gt;
&lt;p&gt;Removed users are automatically logged out and their account disabled. These accounts are displayed in the Server Admin &amp;gt; Users page with a &lt;code&gt;disabled&lt;/code&gt; label. Disabled users keep their custom permissions on dashboards, folders, and data sources, so if you add them back in your LDAP database, they have access to the application with the same custom permissions as before.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;[auth.ldap]
...

# You can use the Cron syntax or several predefined schedulers -
# @yearly (or @annually) | Run once a year, midnight, Jan. 1st        | 0 0 1 1 *
# @monthly               | Run once a month, midnight, first of month | 0 0 1 * *
# @weekly                | Run once a week, midnight between Sat/Sun  | 0 0 * * 0
# @daily (or @midnight)  | Run once a day, midnight                   | 0 0 * * *
# @hourly                | Run once an hour, beginning of hour        | 0 * * * *
sync_cron = &amp;#34;0 1 * * *&amp;#34; # This is default value (At 1 am every day)
# This cron expression format uses 5 space-separated fields, for example
# sync_cron = &amp;#34;*/10 * * * *&amp;#34;
# This will run the LDAP Synchronization every 10th minute, which is also the minimal interval between the Grafana sync times i.e. you cannot set it for every 9th minute

# You can also disable active LDAP synchronization
active_sync_enabled = true # enabled by default&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Single bind configuration (as in the &lt;a href=&#34;../ldap/#single-bind-example&#34;&gt;Single bind example&lt;/a&gt;) is not supported with active LDAP synchronization because Grafana needs user information to perform LDAP searches.&lt;/p&gt;
&lt;p&gt;For the synchronization to work, the &lt;code&gt;servers.search_filter&lt;/code&gt; and &lt;code&gt;servers.attributes.username&lt;/code&gt; in the ldap.toml config file must match. By default, the &lt;code&gt;servers.attributes.username&lt;/code&gt; is &lt;code&gt;cn&lt;/code&gt;, so if you use another attribute as the search filter, you must also update the username attribute.&lt;/p&gt;
&lt;p&gt;For example:&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;[[servers]]
search_filter = &amp;#34;(sAMAccountName=%s)&amp;#34;

[servers.attributes]
username  = &amp;#34;sAMAccountName&amp;#34;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;If the attributes aren&amp;rsquo;t the same, the users&amp;rsquo; sessions will be terminated after each synchronization. That&amp;rsquo;s because the search will be done using the username&amp;rsquo;s value, and that value doesn&amp;rsquo;t exist for the attribute used in the search filter.&lt;/p&gt;
]]></content><description>&lt;h1 id="configure-enhanced-ldap-integration">Configure enhanced LDAP integration&lt;/h1>
&lt;p>The enhanced LDAP integration adds additional functionality on top of the &lt;a href="../ldap/">LDAP integration&lt;/a> available in the open source edition of Grafana.&lt;/p>
&lt;blockquote>
&lt;p>&lt;strong>Note:&lt;/strong> Available in &lt;a href="../../../../introduction/grafana-enterprise/">Grafana Enterprise&lt;/a> and &lt;a href="/docs/grafana-cloud/">Grafana Cloud&lt;/a>.
If you are a Grafana Cloud customer, please &lt;a href="/profile/org#support">open a support ticket in the Cloud Portal&lt;/a> to request this feature.&lt;/p></description></item><item><title>Configure SAML authentication using the configuration file</title><link>https://grafana.com/docs/grafana/v10.4/setup-grafana/configure-security/configure-authentication/saml/</link><pubDate>Fri, 07 Mar 2025 09:39:42 +0000</pubDate><guid>https://grafana.com/docs/grafana/v10.4/setup-grafana/configure-security/configure-authentication/saml/</guid><content><![CDATA[&lt;h1 id=&#34;configure-saml-authentication-using-the-configuration-file&#34;&gt;Configure SAML authentication using the configuration file&lt;/h1&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Available in &lt;a href=&#34;../../../../introduction/grafana-enterprise/&#34;&gt;Grafana Enterprise&lt;/a&gt; and &lt;a href=&#34;/docs/grafana-cloud/&#34;&gt;Grafana Cloud&lt;/a&gt;.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;SAML authentication integration allows your Grafana users to log in by using an external SAML 2.0 Identity Provider (IdP). To enable this, Grafana becomes a Service Provider (SP) in the authentication flow, interacting with the IdP to exchange user information.&lt;/p&gt;
&lt;p&gt;You can configure SAML authentication in Grafana through the user interface (UI) or the Grafana configuration file. For instructions on how to set up SAML through Grafana&amp;rsquo;s UI, refer to &lt;a href=&#34;../saml-ui/&#34;&gt;Configure SAML authentication using the Grafana user interface&lt;/a&gt;.
Both methods offer the same configuration options, but you might prefer using the Grafana configuration file if you want to keep all of Grafana&amp;rsquo;s authentication settings in one place. Grafana Cloud users do not have access to Grafana configuration file, so they should configure SAML through Grafana&amp;rsquo;s UI.&lt;/p&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Configuration in the UI takes precedence over the configuration in the Grafana configuration file. SAML settings from the UI will override any SAML configuration set in the Grafana configuration file.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h2 id=&#34;supported-saml&#34;&gt;Supported SAML&lt;/h2&gt;
&lt;p&gt;Grafana supports the following SAML 2.0 bindings:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;From the Service Provider (SP) to the Identity Provider (IdP):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;HTTP-POST&lt;/code&gt; binding&lt;/li&gt;
&lt;li&gt;&lt;code&gt;HTTP-Redirect&lt;/code&gt; binding&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;From the Identity Provider (IdP) to the Service Provider (SP):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;HTTP-POST&lt;/code&gt; binding&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In terms of security:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Grafana supports signed and encrypted assertions.&lt;/li&gt;
&lt;li&gt;Grafana does not support signed or encrypted requests.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In terms of initiation, Grafana supports:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;SP-initiated requests&lt;/li&gt;
&lt;li&gt;IdP-initiated requests&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;By default, SP-initiated requests are enabled. For instructions on how to enable IdP-initiated logins, see &lt;a href=&#34;#idp-initiated-single-sign-on-sso&#34;&gt;IdP-initiated Single Sign-On (SSO)&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;edit-saml-options-in-the-grafana-config-file&#34;&gt;Edit SAML options in the Grafana config file&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;In the &lt;code&gt;[auth.saml]&lt;/code&gt; section in the Grafana configuration file, set &lt;a href=&#34;../../../configure-grafana/enterprise-configuration/#enabled&#34;&gt;&lt;code&gt;enabled&lt;/code&gt;&lt;/a&gt; to &lt;code&gt;true&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Configure the &lt;a href=&#34;#certificate-and-private-key&#34;&gt;certificate and private key&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;On the Okta application page where you have been redirected after application created, navigate to the &lt;strong&gt;Sign On&lt;/strong&gt; tab and find &lt;strong&gt;Identity Provider metadata&lt;/strong&gt; link in the &lt;strong&gt;Settings&lt;/strong&gt; section.&lt;/li&gt;
&lt;li&gt;Set the &lt;a href=&#34;../../../configure-grafana/enterprise-configuration/#idp_metadata_url&#34;&gt;&lt;code&gt;idp_metadata_url&lt;/code&gt;&lt;/a&gt; to the URL obtained from the previous step. The URL should look like &lt;code&gt;https://&amp;lt;your-org-id&amp;gt;.okta.com/app/&amp;lt;application-id&amp;gt;/sso/saml/metadata&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Set the following options to the attribute names configured at the &lt;strong&gt;step 10&lt;/strong&gt; of the SAML integration setup. You can find this attributes on the &lt;strong&gt;General&lt;/strong&gt; tab of the application page (&lt;strong&gt;ATTRIBUTE STATEMENTS&lt;/strong&gt; and &lt;strong&gt;GROUP ATTRIBUTE STATEMENTS&lt;/strong&gt; in the &lt;strong&gt;SAML Settings&lt;/strong&gt; section).
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;../../../configure-grafana/enterprise-configuration/#assertion_attribute_login&#34;&gt;&lt;code&gt;assertion_attribute_login&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;../../../configure-grafana/enterprise-configuration/#assertion_attribute_email&#34;&gt;&lt;code&gt;assertion_attribute_email&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;../../../configure-grafana/enterprise-configuration/#assertion_attribute_name&#34;&gt;&lt;code&gt;assertion_attribute_name&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;../../../configure-grafana/enterprise-configuration/#assertion_attribute_groups&#34;&gt;&lt;code&gt;assertion_attribute_groups&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Save the configuration file and and then restart the Grafana server.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;When you are finished, the Grafana configuration might look like this example:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;[server]
root_url = https://grafana.example.com

[auth.saml]
enabled = true
auto_login = false
private_key_path = &amp;#34;/path/to/private_key.pem&amp;#34;
certificate_path = &amp;#34;/path/to/certificate.cert&amp;#34;
idp_metadata_url = &amp;#34;https://my-org.okta.com/app/my-application/sso/saml/metadata&amp;#34;
assertion_attribute_name = DisplayName
assertion_attribute_login = Login
assertion_attribute_email = Email
assertion_attribute_groups = Group&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;enable-saml-authentication-in-grafana&#34;&gt;Enable SAML authentication in Grafana&lt;/h2&gt;
&lt;p&gt;To use the SAML integration, in the &lt;code&gt;auth.saml&lt;/code&gt; section of in the Grafana custom configuration file, set &lt;code&gt;enabled&lt;/code&gt; to &lt;code&gt;true&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Refer to &lt;a href=&#34;../../../configure-grafana/&#34;&gt;Configuration&lt;/a&gt; for more information about configuring Grafana.&lt;/p&gt;
&lt;h2 id=&#34;certificate-and-private-key&#34;&gt;Certificate and private key&lt;/h2&gt;
&lt;p&gt;The SAML SSO standard uses asymmetric encryption to exchange information between the SP (Grafana) and the IdP. To perform such encryption, you need a public part and a private part. In this case, the X.509 certificate provides the public part, while the private key provides the private part. The private key needs to be issued in a &lt;a href=&#34;https://en.wikipedia.org/wiki/PKCS_8&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;PKCS#8&lt;/a&gt; format.&lt;/p&gt;
&lt;p&gt;Grafana supports two ways of specifying both the &lt;code&gt;certificate&lt;/code&gt; and &lt;code&gt;private_key&lt;/code&gt;.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Without a suffix (&lt;code&gt;certificate&lt;/code&gt; or &lt;code&gt;private_key&lt;/code&gt;), the configuration assumes you&amp;rsquo;ve supplied the base64-encoded file contents.&lt;/li&gt;
&lt;li&gt;With the &lt;code&gt;_path&lt;/code&gt; suffix (&lt;code&gt;certificate_path&lt;/code&gt; or &lt;code&gt;private_key_path&lt;/code&gt;), then Grafana treats the value entered as a file path and attempts to read the file from the file system.&lt;/li&gt;
&lt;/ul&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;You can only use one form of each configuration option. Using multiple forms, such as both &lt;code&gt;certificate&lt;/code&gt; and &lt;code&gt;certificate_path&lt;/code&gt;, results in an error.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;hr /&gt;
&lt;h3 id=&#34;example-of-how-to-generate-saml-credentials&#34;&gt;&lt;strong&gt;Example&lt;/strong&gt; of how to generate SAML credentials:&lt;/h3&gt;
&lt;p&gt;An example of how to generate a self-signed certificate and private key that&amp;rsquo;s valid for one year:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;sh&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sh&#34;&gt;$ openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes​&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The generated &lt;code&gt;key.pem&lt;/code&gt; and &lt;code&gt;cert.pem&lt;/code&gt; files are then used for certificate and private_key.&lt;/p&gt;
&lt;p&gt;The key you provide should look like:&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;-----BEGIN PRIVATE KEY-----
...
...
-----END PRIVATE KEY-----&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;set-up-saml-with-okta&#34;&gt;Set up SAML with Okta&lt;/h2&gt;
&lt;p&gt;Grafana supports user authentication through Okta, which is useful when you want your users to access Grafana using single sign on. This guide will follow you through the steps of configuring SAML authentication in Grafana with &lt;a href=&#34;https://okta.com/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Okta&lt;/a&gt;. You need to be an admin in your Okta organization to access Admin Console and create SAML integration. You also need permissions to edit Grafana config file and restart Grafana server.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Before you begin:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;To configure SAML integration with Okta, create an app integration inside the Okta organization first. &lt;a href=&#34;https://help.okta.com/en/prod/Content/Topics/Apps/apps-overview-add-apps.htm&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Add app integration in Okta&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Ensure you have permission to administer SAML authentication. For more information about roles and permissions in Grafana, refer to &lt;a href=&#34;../../../../administration/roles-and-permissions/&#34;&gt;Roles and permissions&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;To set up SAML with Okta:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Log in to the &lt;a href=&#34;https://login.okta.com/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Okta portal&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Go to the Admin Console in your Okta organization by clicking &lt;strong&gt;Admin&lt;/strong&gt; in the upper-right corner. If you are in the Developer Console, then click &lt;strong&gt;Developer Console&lt;/strong&gt; in the upper-left corner and then click &lt;strong&gt;Classic UI&lt;/strong&gt; to switch over to the Admin Console.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;In the Admin Console, navigate to &lt;strong&gt;Applications&lt;/strong&gt; &amp;gt; &lt;strong&gt;Applications&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Add Application&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Create New App&lt;/strong&gt; to start the Application Integration Wizard.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Choose &lt;strong&gt;Web&lt;/strong&gt; as a platform.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Select &lt;strong&gt;SAML 2.0&lt;/strong&gt; in the Sign on method section.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Create&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;On the &lt;strong&gt;General Settings&lt;/strong&gt; tab, enter a name for your Grafana integration. You can also upload a logo.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;On the &lt;strong&gt;Configure SAML&lt;/strong&gt; tab, enter the SAML information related to your Grafana instance:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;In the &lt;strong&gt;Single sign on URL&lt;/strong&gt; field, use the &lt;code&gt;/saml/acs&lt;/code&gt; endpoint URL of your Grafana instance, for example, &lt;code&gt;https://grafana.example.com/saml/acs&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;In the &lt;strong&gt;Audience URI (SP Entity ID)&lt;/strong&gt; field, use the &lt;code&gt;/saml/metadata&lt;/code&gt; endpoint URL, for example, &lt;code&gt;https://grafana.example.com/saml/metadata&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Leave the default values for &lt;strong&gt;Name ID format&lt;/strong&gt; and &lt;strong&gt;Application username&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;In the &lt;strong&gt;ATTRIBUTE STATEMENTS (OPTIONAL)&lt;/strong&gt; section, enter the SAML attributes to be shared with Grafana, for example:&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Attribute name (in Grafana)&lt;/th&gt;
              &lt;th&gt;Value (in Okta profile)&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;Login&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;user.login&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Email&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;user.email&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;DisplayName&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;user.firstName &#43; &amp;quot; &amp;quot; &#43; user.lastName&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;In the &lt;strong&gt;GROUP ATTRIBUTE STATEMENTS (OPTIONAL)&lt;/strong&gt; section, enter a group attribute name (for example, &lt;code&gt;Group&lt;/code&gt;) and set filter to &lt;code&gt;Matches regex .*&lt;/code&gt; to return all user groups.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Next&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;On the final Feedback tab, fill out the form and then click &lt;strong&gt;Finish&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;configure-saml-authentication-in-grafana&#34;&gt;Configure SAML authentication in Grafana&lt;/h2&gt;
&lt;p&gt;The table below describes all SAML configuration options. Continue reading below for details on specific options. Like any other Grafana configuration, you can apply these options as &lt;a href=&#34;../../../configure-grafana/#override-configuration-with-environment-variables&#34;&gt;environment variables&lt;/a&gt;.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Setting&lt;/th&gt;
              &lt;th&gt;Required&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Default&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;enabled&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Whether SAML authentication is allowed&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;false&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;name&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Name used to refer to the SAML authentication in the Grafana user interface.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;SAML&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;single_logout&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Whether SAML Single Logout enabled&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;false&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;allow_sign_up&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Whether to allow new Grafana user creation through SAML login. If set to &lt;code&gt;false&lt;/code&gt;, then only existing Grafana users can log in with SAML.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;true&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;auto_login&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Whether SAML auto login is enabled&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;false&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;allow_idp_initiated&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Whether SAML IdP-initiated login is allowed&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;false&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;certificate&lt;/code&gt; or &lt;code&gt;certificate_path&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Yes&lt;/td&gt;
              &lt;td&gt;Base64-encoded string or Path for the SP X.509 certificate&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;private_key&lt;/code&gt; or &lt;code&gt;private_key_path&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Yes&lt;/td&gt;
              &lt;td&gt;Base64-encoded string or Path for the SP private key&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;signature_algorithm&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Signature algorithm used for signing requests to the IdP. Supported values are rsa-sha1, rsa-sha256, rsa-sha512.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;idp_metadata&lt;/code&gt;, &lt;code&gt;idp_metadata_path&lt;/code&gt;, or &lt;code&gt;idp_metadata_url&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Yes&lt;/td&gt;
              &lt;td&gt;Base64-encoded string, Path or URL for the IdP SAML metadata XML&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;max_issue_delay&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Duration, since the IdP issued a response and the SP is allowed to process it&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;90s&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;metadata_valid_duration&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Duration, for how long the SP metadata is valid&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;48h&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;relay_state&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Relay state for IdP-initiated login. Should match relay state configured in IdP&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;assertion_attribute_name&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Friendly name or name of the attribute within the SAML assertion to use as the user name. Alternatively, this can be a template with variables that match the names of attributes within the SAML assertion.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;displayName&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;assertion_attribute_login&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Friendly name or name of the attribute within the SAML assertion to use as the user login handle&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;mail&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;assertion_attribute_email&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Friendly name or name of the attribute within the SAML assertion to use as the user email&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;mail&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;assertion_attribute_groups&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Friendly name or name of the attribute within the SAML assertion to use as the user groups&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;assertion_attribute_role&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Friendly name or name of the attribute within the SAML assertion to use as the user roles&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;assertion_attribute_org&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Friendly name or name of the attribute within the SAML assertion to use as the user organization&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;allowed_organizations&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;List of comma- or space-separated organizations. User should be a member of at least one organization to log in.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;org_mapping&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;List of comma- or space-separated Organization:OrgId:Role mappings. Organization can be &lt;code&gt;*&lt;/code&gt; meaning &amp;ldquo;All users&amp;rdquo;. Role is optional and can have the following values: &lt;code&gt;Viewer&lt;/code&gt;, &lt;code&gt;Editor&lt;/code&gt; or &lt;code&gt;Admin&lt;/code&gt;.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;role_values_none&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;List of comma- or space-separated roles which will be mapped into the None role&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;role_values_editor&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;List of comma- or space-separated roles which will be mapped into the Editor role&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;role_values_admin&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;List of comma- or space-separated roles which will be mapped into the Admin role&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;role_values_grafana_admin&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;List of comma- or space-separated roles which will be mapped into the Grafana Admin (Super Admin) role&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;name_id_format&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;The Name ID Format to request within the SAML assertion&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;urn:oasis:names:tc:SAML:2.0:nameid-format:transient&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;signature-algorithm&#34;&gt;Signature algorithm&lt;/h3&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Available in Grafana version 7.3 and later.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;The SAML standard recommends using a digital signature for some types of messages, like authentication or logout requests. If the &lt;code&gt;signature_algorithm&lt;/code&gt; option is configured, Grafana will put a digital signature into SAML requests. Supported signature types are &lt;code&gt;rsa-sha1&lt;/code&gt;, &lt;code&gt;rsa-sha256&lt;/code&gt;, &lt;code&gt;rsa-sha512&lt;/code&gt;. This option should match your IdP configuration, otherwise, signature validation will fail. Grafana uses key and certificate configured with &lt;code&gt;private_key&lt;/code&gt; and &lt;code&gt;certificate&lt;/code&gt; options for signing SAML requests.&lt;/p&gt;
&lt;h3 id=&#34;specify-users-name-id&#34;&gt;Specify user&amp;rsquo;s Name ID&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;name_id_format&lt;/code&gt; configuration field specifies the format of the NameID element in the SAML assertion.&lt;/p&gt;
&lt;p&gt;By default, this is set to &lt;code&gt;urn:oasis:names:tc:SAML:2.0:nameid-format:transient&lt;/code&gt; and does not need to be specified in the configuration file.&lt;/p&gt;
&lt;p&gt;The following list includes valid configuration field values:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;urn:oasis:names:tc:SAML:2.0:nameid-format:transient&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;urn:oasis:names:tc:SAML:2.0:nameid-format:persistent&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;idp-metadata&#34;&gt;IdP metadata&lt;/h3&gt;
&lt;p&gt;You also need to define the public part of the IdP for message verification. The SAML IdP metadata XML defines where and how Grafana exchanges user information.&lt;/p&gt;
&lt;p&gt;Grafana supports three ways of specifying the IdP metadata.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Without a suffix &lt;code&gt;idp_metadata&lt;/code&gt;, Grafana assumes base64-encoded XML file contents.&lt;/li&gt;
&lt;li&gt;With the &lt;code&gt;_path&lt;/code&gt; suffix, Grafana assumes a file path and attempts to read the file from the file system.&lt;/li&gt;
&lt;li&gt;With the &lt;code&gt;_url&lt;/code&gt; suffix, Grafana assumes a URL and attempts to load the metadata from the given location.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;maximum-issue-delay&#34;&gt;Maximum issue delay&lt;/h3&gt;
&lt;p&gt;Prevents SAML response replay attacks and internal clock skews between the SP (Grafana) and the IdP. You can set a maximum amount of time between the IdP issuing a response and the SP (Grafana) processing it.&lt;/p&gt;
&lt;p&gt;The configuration options is specified as a duration, such as &lt;code&gt;max_issue_delay = 90s&lt;/code&gt; or &lt;code&gt;max_issue_delay = 1h&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&#34;metadata-valid-duration&#34;&gt;Metadata valid duration&lt;/h3&gt;
&lt;p&gt;SP metadata is likely to expire at some point, perhaps due to a certificate rotation or change of location binding. Grafana allows you to specify for how long the metadata should be valid. Leveraging the &lt;code&gt;validUntil&lt;/code&gt; field, you can tell consumers until when your metadata is going to be valid. The duration is computed by adding the duration to the current time.&lt;/p&gt;
&lt;p&gt;The configuration option is specified as a duration, such as &lt;code&gt;metadata_valid_duration = 48h&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&#34;identity-provider-idp-registration&#34;&gt;Identity provider (IdP) registration&lt;/h3&gt;
&lt;p&gt;For the SAML integration to work correctly, you need to make the IdP aware of the SP.&lt;/p&gt;
&lt;p&gt;The integration provides two key endpoints as part of Grafana:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;/saml/metadata&lt;/code&gt; endpoint, which contains the SP metadata. You can either download and upload it manually, or you make the IdP request it directly from the endpoint. Some providers name it Identifier or Entity ID.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;/saml/acs&lt;/code&gt; endpoint, which is intended to receive the ACS (Assertion Customer Service) callback. Some providers name it SSO URL or Reply URL.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;idp-initiated-single-sign-on-sso&#34;&gt;IdP-initiated Single Sign-On (SSO)&lt;/h3&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Available in Grafana version 7.3 and later.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;By default, Grafana allows only service provider (SP) initiated logins (when the user logs in with SAML via Grafana’s login page). If you want users to log in into Grafana directly from your identity provider (IdP), set the &lt;code&gt;allow_idp_initiated&lt;/code&gt; configuration option to &lt;code&gt;true&lt;/code&gt; and configure &lt;code&gt;relay_state&lt;/code&gt; with the same value specified in the IdP configuration.&lt;/p&gt;
&lt;p&gt;IdP-initiated SSO has some security risks, so make sure you understand the risks before enabling this feature. When using IdP-initiated SSO, Grafana receives unsolicited SAML requests and can&amp;rsquo;t verify that login flow was started by the user. This makes it hard to detect whether SAML message has been stolen or replaced. Because of this, IdP-initiated SSO is vulnerable to login cross-site request forgery (CSRF) and man in the middle (MITM) attacks. We do not recommend using IdP-initiated SSO and keeping it disabled whenever possible.&lt;/p&gt;
&lt;h3 id=&#34;single-logout&#34;&gt;Single logout&lt;/h3&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Available in Grafana version 7.3 and later.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;SAML&amp;rsquo;s single logout feature allows users to log out from all applications associated with the current IdP session established via SAML SSO. If the &lt;code&gt;single_logout&lt;/code&gt; option is set to &lt;code&gt;true&lt;/code&gt; and a user logs out, Grafana requests IdP to end the user session which in turn triggers logout from all other applications the user is logged into using the same IdP session (applications should support single logout). Conversely, if another application connected to the same IdP logs out using single logout, Grafana receives a logout request from IdP and ends the user session.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;HTTP-Redirect&lt;/code&gt; and &lt;code&gt;HTTP-POST&lt;/code&gt; bindings are supported for single logout.
When using &lt;code&gt;HTTP-Redirect&lt;/code&gt; bindings the query should include a request signature.&lt;/p&gt;
&lt;h3 id=&#34;assertion-mapping&#34;&gt;Assertion mapping&lt;/h3&gt;
&lt;p&gt;During the SAML SSO authentication flow, Grafana receives the ACS callback. The callback contains all the relevant information of the user under authentication embedded in the SAML response. Grafana parses the response to create (or update) the user within its internal database.&lt;/p&gt;
&lt;p&gt;For Grafana to map the user information, it looks at the individual attributes within the assertion. You can think of these attributes as Key/Value pairs (although, they contain more information than that).&lt;/p&gt;
&lt;p&gt;Grafana provides configuration options that let you modify which keys to look at for these values. The data we need to create the user in Grafana is Name, Login handle, and email.&lt;/p&gt;
&lt;h4 id=&#34;the-assertion_attribute_name-option&#34;&gt;The &lt;code&gt;assertion_attribute_name&lt;/code&gt; option&lt;/h4&gt;
&lt;p&gt;&lt;code&gt;assertion_attribute_name&lt;/code&gt; is a special assertion mapping that can either be a simple key, indicating a mapping to a single assertion attribute on the SAML response, or a complex template with variables using the &lt;code&gt;$__saml{&amp;lt;attribute&amp;gt;}&lt;/code&gt; syntax. If this property is misconfigured, Grafana will log an error message on startup and disallow SAML sign-ins. Grafana will also log errors after a login attempt if a variable in the template is missing from the SAML response.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Examples&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;ini&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-ini&#34;&gt;#plain string mapping
assertion_attribute_name = displayName&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;ini&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-ini&#34;&gt;#template mapping
assertion_attribute_name = $__saml{firstName} $__saml{lastName}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;allow-new-user-signups&#34;&gt;Allow new user signups&lt;/h3&gt;
&lt;p&gt;By default, new Grafana users using SAML authentication will have an account created for them automatically. To decouple authentication and account creation and ensure only users with existing accounts can log in with SAML, set the &lt;code&gt;allow_sign_up&lt;/code&gt; option to false.&lt;/p&gt;
&lt;h3 id=&#34;configure-automatic-login&#34;&gt;Configure automatic login&lt;/h3&gt;
&lt;p&gt;Set &lt;code&gt;auto_login&lt;/code&gt; option to true to attempt login automatically, skipping the login screen.
This setting is ignored if multiple auth providers are configured to use auto login.&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;auto_login = true&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;configure-team-sync&#34;&gt;Configure team sync&lt;/h3&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Team sync support for SAML is available in Grafana version 7.0 and later.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;To use SAML Team sync, set &lt;a href=&#34;../../../configure-grafana/enterprise-configuration/#assertion_attribute_groups&#34;&gt;&lt;code&gt;assertion_attribute_groups&lt;/code&gt;&lt;/a&gt; to the attribute name where you store user groups. Then Grafana will use attribute values extracted from SAML assertion to add user into the groups with the same name configured on the External group sync tab.&lt;/p&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Teamsync allows you sync users from SAML to Grafana teams. It does not automatically create teams in Grafana. You need to create teams in Grafana before you can use this feature.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;Given the following partial SAML assertion:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;xml&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-xml&#34;&gt;&amp;lt;saml2:Attribute
    Name=&amp;#34;groups&amp;#34;
    NameFormat=&amp;#34;urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified&amp;#34;&amp;gt;
    &amp;lt;saml2:AttributeValue
        xmlns:xs=&amp;#34;http://www.w3.org/2001/XMLSchema&amp;#34;
        xmlns:xsi=&amp;#34;http://www.w3.org/2001/XMLSchema-instance&amp;#34;
        xsi:type=&amp;#34;xs:string&amp;#34;&amp;gt;admins_group
    &amp;lt;/saml2:AttributeValue&amp;gt;
    &amp;lt;saml2:AttributeValue
        xmlns:xs=&amp;#34;http://www.w3.org/2001/XMLSchema&amp;#34;
        xmlns:xsi=&amp;#34;http://www.w3.org/2001/XMLSchema-instance&amp;#34;
        xsi:type=&amp;#34;xs:string&amp;#34;&amp;gt;division_1
    &amp;lt;/saml2:AttributeValue&amp;gt;
&amp;lt;/saml2:Attribute&amp;gt;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The configuration would look like this:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;ini&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-ini&#34;&gt;[auth.saml]
# ...
assertion_attribute_groups = groups&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The following &lt;code&gt;External Group ID&lt;/code&gt;s would be valid for input in the desired team&amp;rsquo;s &lt;em&gt;External group sync&lt;/em&gt; tab:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;admins_group&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;division_1&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a href=&#34;../../configure-team-sync/&#34;&gt;Learn more about Team Sync&lt;/a&gt;&lt;/p&gt;
&lt;h3 id=&#34;configure-role-sync&#34;&gt;Configure role sync&lt;/h3&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Available in Grafana version 7.0 and later.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;Role sync allows you to map user roles from an identity provider to Grafana. To enable role sync, configure role attribute and possible values for the Editor, Admin, and Grafana Admin roles. For more information about user roles, refer to &lt;a href=&#34;../../../../administration/roles-and-permissions/&#34;&gt;Roles and permissions&lt;/a&gt;.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;In the configuration file, set &lt;a href=&#34;../../../configure-grafana/enterprise-configuration/#assertion_attribute_role&#34;&gt;&lt;code&gt;assertion_attribute_role&lt;/code&gt;&lt;/a&gt; option to the attribute name where the role information will be extracted from.&lt;/li&gt;
&lt;li&gt;Set the &lt;a href=&#34;../../../configure-grafana/enterprise-configuration/#role_values_none&#34;&gt;&lt;code&gt;role_values_none&lt;/code&gt;&lt;/a&gt; option to the values mapped to the &lt;code&gt;None&lt;/code&gt; role.&lt;/li&gt;
&lt;li&gt;Set the &lt;a href=&#34;../../../configure-grafana/enterprise-configuration/#role_values_editor&#34;&gt;&lt;code&gt;role_values_editor&lt;/code&gt;&lt;/a&gt; option to the values mapped to the &lt;code&gt;Editor&lt;/code&gt; role.&lt;/li&gt;
&lt;li&gt;Set the &lt;a href=&#34;../../../configure-grafana/enterprise-configuration/#role_values_admin&#34;&gt;&lt;code&gt;role_values_admin&lt;/code&gt;&lt;/a&gt; option to the values mapped to the organization &lt;code&gt;Admin&lt;/code&gt; role.&lt;/li&gt;
&lt;li&gt;Set the &lt;a href=&#34;../../../configure-grafana/enterprise-configuration/#role_values_grafana_admin&#34;&gt;&lt;code&gt;role_values_grafana_admin&lt;/code&gt;&lt;/a&gt; option to the values mapped to the &lt;code&gt;Grafana Admin&lt;/code&gt; role.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;If a user role doesn&amp;rsquo;t match any of configured values, then the &lt;code&gt;Viewer&lt;/code&gt; role will be assigned.&lt;/p&gt;
&lt;p&gt;For more information about roles and permissions in Grafana, refer to &lt;a href=&#34;../../../../administration/roles-and-permissions/&#34;&gt;Roles and permissions&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Example configuration:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;ini&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-ini&#34;&gt;[auth.saml]
assertion_attribute_role = role
role_values_none = none, external
role_values_editor = editor, developer
role_values_admin = admin, operator
role_values_grafana_admin = superadmin&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Important&lt;/strong&gt;: When role sync is configured, any changes of user roles and organization membership made manually in Grafana will be overwritten on next user login. Assign user organizations and roles in the IdP instead.&lt;/p&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Available in Grafana version 9.2 and later.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;If you don&amp;rsquo;t want user organizations and roles to be synchronized with the IdP, you can use the &lt;code&gt;skip_org_role_sync&lt;/code&gt; configuration option.&lt;/p&gt;
&lt;p&gt;Example configuration:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;ini&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-ini&#34;&gt;[auth.saml]
skip_org_role_sync = true&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;configure-organization-mapping&#34;&gt;Configure organization mapping&lt;/h3&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Available in Grafana version 7.0 and later.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;Organization mapping allows you to assign users to particular organization in Grafana depending on attribute value obtained from identity provider.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;In configuration file, set &lt;a href=&#34;../../../configure-grafana/enterprise-configuration/#assertion_attribute_org&#34;&gt;&lt;code&gt;assertion_attribute_org&lt;/code&gt;&lt;/a&gt; to the attribute name you store organization info in. This attribute can be an array if you want a user to be in multiple organizations.&lt;/li&gt;
&lt;li&gt;Set &lt;a href=&#34;../../../configure-grafana/enterprise-configuration/#org_mapping&#34;&gt;&lt;code&gt;org_mapping&lt;/code&gt;&lt;/a&gt; option to the comma-separated list of &lt;code&gt;Organization:OrgId&lt;/code&gt; pairs to map organization from IdP to Grafana organization specified by id. If you want users to have different roles in multiple organizations, you can set this option to a comma-separated list of &lt;code&gt;Organization:OrgId:Role&lt;/code&gt; mappings.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;For example, use following configuration to assign users from &lt;code&gt;Engineering&lt;/code&gt; organization to the Grafana organization with id &lt;code&gt;2&lt;/code&gt; as Editor and users from &lt;code&gt;Sales&lt;/code&gt; - to the org with id &lt;code&gt;3&lt;/code&gt; as Admin, based on &lt;code&gt;Org&lt;/code&gt; assertion attribute value:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;[auth.saml]
assertion_attribute_org = Org
org_mapping = Engineering:2:Editor, Sales:3:Admin&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;You can specify multiple organizations both for the IdP and Grafana:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;org_mapping = Engineering:2, Sales:2&lt;/code&gt; to map users from &lt;code&gt;Engineering&lt;/code&gt; and &lt;code&gt;Sales&lt;/code&gt; to &lt;code&gt;2&lt;/code&gt; in Grafana.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;org_mapping = Engineering:2, Engineering:3&lt;/code&gt; to assign &lt;code&gt;Engineering&lt;/code&gt; to both &lt;code&gt;2&lt;/code&gt; and &lt;code&gt;3&lt;/code&gt; in Grafana.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You can use &lt;code&gt;*&lt;/code&gt; as the SAML Organization if you want all your users to be in some Grafana organizations with a default role:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;org_mapping = *:2:Editor&lt;/code&gt; to map all users to &lt;code&gt;2&lt;/code&gt; in Grafana as Editors.&lt;/li&gt;
&lt;/ul&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Available in Grafana version 9.2 and later.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;You can use &lt;code&gt;*&lt;/code&gt; as the Grafana organization in the mapping if you want all users from a given SAML Organization to be added to all existing Grafana organizations.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;org_mapping = Engineering:*&lt;/code&gt; to map users from &lt;code&gt;Engineering&lt;/code&gt; to all existing Grafana organizations.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;org_mapping = Administration:*:Admin&lt;/code&gt; to map users from &lt;code&gt;Administration&lt;/code&gt; to all existing Grafana organizations as Admins.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;configure-allowed-organizations&#34;&gt;Configure allowed organizations&lt;/h3&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Available in Grafana version 7.0 and later.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;With the &lt;a href=&#34;../../../configure-grafana/enterprise-configuration/#allowed_organizations&#34;&gt;&lt;code&gt;allowed_organizations&lt;/code&gt;&lt;/a&gt; option you can specify a list of organizations where the user must be a member of at least one of them to be able to log in to Grafana.&lt;/p&gt;
&lt;p&gt;To put values containing spaces in the list, use the following JSON syntax:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;ini&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-ini&#34;&gt;allowed_organizations = [&amp;#34;org 1&amp;#34;, &amp;#34;second org&amp;#34;]&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;example-saml-configuration&#34;&gt;Example SAML configuration&lt;/h3&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;[auth.saml]
enabled = true
auto_login = false
certificate_path = &amp;#34;/path/to/certificate.cert&amp;#34;
private_key_path = &amp;#34;/path/to/private_key.pem&amp;#34;
idp_metadata_path = &amp;#34;/my/metadata.xml&amp;#34;
max_issue_delay = 90s
metadata_valid_duration = 48h
assertion_attribute_name = displayName
assertion_attribute_login = mail
assertion_attribute_email = mail

assertion_attribute_groups = Group
assertion_attribute_role = Role
assertion_attribute_org = Org
role_values_editor = editor, developer
role_values_admin = admin, operator
role_values_grafana_admin = superadmin
org_mapping = Engineering:2:Editor, Engineering:3:Viewer, Sales:3:Editor, *:1:Editor
allowed_organizations = Engineering, Sales&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;troubleshoot-saml-authentication-in-grafana&#34;&gt;Troubleshoot SAML authentication in Grafana&lt;/h2&gt;
&lt;p&gt;To troubleshoot and get more log information, enable SAML debug logging in the configuration file. Refer to &lt;a href=&#34;../../../configure-grafana/#filters&#34;&gt;Configuration&lt;/a&gt; for more information.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;[log]
filters = saml.auth:debug&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;troubleshooting&#34;&gt;Troubleshooting&lt;/h2&gt;
&lt;p&gt;Following are common issues found in configuring SAML authentication in Grafana and how to resolve them.&lt;/p&gt;
&lt;h3 id=&#34;infinite-redirect-loop--user-gets-redirected-to-the-login-page-after-successful-login-on-the-idp-side&#34;&gt;Infinite redirect loop / User gets redirected to the login page after successful login on the IdP side&lt;/h3&gt;
&lt;p&gt;If you experience an infinite redirect loop when &lt;code&gt;auto_login = true&lt;/code&gt; or redirected to the login page after successful login, it is likely that the &lt;code&gt;grafana_session&lt;/code&gt; cookie&amp;rsquo;s SameSite setting is set to &lt;code&gt;Strict&lt;/code&gt;. This setting prevents the &lt;code&gt;grafana_session&lt;/code&gt; cookie from being sent to Grafana during cross-site requests. To resolve this issue, set the &lt;code&gt;security.cookie_samesite&lt;/code&gt; option to &lt;code&gt;Lax&lt;/code&gt; in the Grafana configuration file.&lt;/p&gt;
&lt;h3 id=&#34;saml-authentication-fails-with-error&#34;&gt;SAML authentication fails with error:&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;asn1: structure error: tags don&#39;t match&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We only support one private key format: PKCS#8.&lt;/p&gt;
&lt;p&gt;The keys may be in a different format (PKCS#1 or PKCS#12); in that case, it may be necessary to convert the private key format.&lt;/p&gt;
&lt;p&gt;The following command creates a pkcs8 key file.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;$ openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes​&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;convert-the-private-key-format-to-base64&#34;&gt;&lt;strong&gt;Convert&lt;/strong&gt; the private key format to base64&lt;/h4&gt;
&lt;p&gt;The following command converts keys to base64 format.&lt;/p&gt;
&lt;p&gt;Base64-encode the cert.pem and key.pem files:
(-w0 switch is not needed on Mac, only for Linux)&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;sh&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-sh&#34;&gt;$ base64 -w0 key.pem &amp;gt; key.pem.base64
$ base64 -w0 cert.pem &amp;gt; cert.pem.base64&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The base64-encoded values (&lt;code&gt;key.pem.base64, cert.pem.base64&lt;/code&gt; files) are then used for certificate and private_key.&lt;/p&gt;
&lt;p&gt;The keys you provide should look like:&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;-----BEGIN PRIVATE KEY-----
...
...
-----END PRIVATE KEY-----&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;saml-login-attempts-fail-with-request-response-origin-not-allowed&#34;&gt;SAML login attempts fail with request response &amp;ldquo;origin not allowed&amp;rdquo;&lt;/h3&gt;
&lt;p&gt;When the user logs in using SAML and gets presented with &amp;ldquo;origin not allowed&amp;rdquo;, the user might be issuing the login from an IdP (identity provider) service or the user is behind a reverse proxy. This potentially happens as Grafana&amp;rsquo;s CSRF checks deem the requests to be invalid. For more information &lt;a href=&#34;https://owasp.org/www-community/attacks/csrf&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;CSRF&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;To solve this issue, you can configure either the &lt;a href=&#34;../../../configure-grafana/#csrf_trusted_origins&#34;&gt;&lt;code&gt;csrf_trusted_origins&lt;/code&gt;&lt;/a&gt; or &lt;a href=&#34;../../../configure-grafana/#csrf_additional_headers&#34;&gt;&lt;code&gt;csrf_additional_headers&lt;/code&gt;&lt;/a&gt; option in the SAML configuration.&lt;/p&gt;
&lt;p&gt;Example of a configuration file:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;# config.ini
...
[security]
csrf_trusted_origins = https://grafana.example.com
csrf_additional_headers = X-Forwarded-Host
...&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;saml-login-attempts-fail-with-request-response-login-session-has-expired&#34;&gt;SAML login attempts fail with request response &amp;ldquo;login session has expired&amp;rdquo;&lt;/h3&gt;
&lt;p&gt;Accessing the Grafana login page from a URL that is not the root URL of the
Grafana server can cause the instance to return the following error: &amp;ldquo;login session has expired&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;If you are accessing grafana through a proxy server, ensure that cookies are correctly
rewritten to the root URL of Grafana.
Cookies must be set on the same url as the &lt;code&gt;root_url&lt;/code&gt; of Grafana. This is normally the reverse proxy&amp;rsquo;s domain/address.&lt;/p&gt;
&lt;p&gt;Review the cookie settings in your proxy server configuration to ensure that cookies are
not being discarded&lt;/p&gt;
&lt;p&gt;Review the following settings in your grafana config:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;ini&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-ini&#34;&gt;[security]
cookie_samesite = none&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This setting should be set to none to allow grafana session cookies to work correctly with redirects.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;ini&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-ini&#34;&gt;[security]
cookie_secure = true&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Ensure cookie_secure is set to true to ensure that cookies are only sent over HTTPS.&lt;/p&gt;
]]></content><description>&lt;h1 id="configure-saml-authentication-using-the-configuration-file">Configure SAML authentication using the configuration file&lt;/h1>
&lt;div class="admonition admonition-note">&lt;blockquote>&lt;p class="title text-uppercase">Note&lt;/p>&lt;p>Available in &lt;a href="../../../../introduction/grafana-enterprise/">Grafana Enterprise&lt;/a> and &lt;a href="/docs/grafana-cloud/">Grafana Cloud&lt;/a>.&lt;/p>&lt;/blockquote>&lt;/div>
&lt;p>SAML authentication integration allows your Grafana users to log in by using an external SAML 2.0 Identity Provider (IdP). To enable this, Grafana becomes a Service Provider (SP) in the authentication flow, interacting with the IdP to exchange user information.&lt;/p></description></item><item><title>Configure SAML authentication using the Grafana user interface</title><link>https://grafana.com/docs/grafana/v10.4/setup-grafana/configure-security/configure-authentication/saml-ui/</link><pubDate>Fri, 07 Mar 2025 09:39:42 +0000</pubDate><guid>https://grafana.com/docs/grafana/v10.4/setup-grafana/configure-security/configure-authentication/saml-ui/</guid><content><![CDATA[&lt;h1 id=&#34;configure-saml-authentication-using-the-grafana-user-interface&#34;&gt;Configure SAML authentication using the Grafana user interface&lt;/h1&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Available in &lt;a href=&#34;../../../../introduction/grafana-enterprise/&#34;&gt;Grafana Enterprise&lt;/a&gt; version 10.0 and later, and &lt;a href=&#34;/docs/grafana-cloud/&#34;&gt;Grafana Cloud Pro and Advanced&lt;/a&gt;.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;You can configure SAML authentication in Grafana through the user interface (UI) or the Grafana configuration file. For instructions on how to set up SAML using the Grafana configuration file, refer to &lt;a href=&#34;../saml/&#34;&gt;Configure SAML authentication using the configuration file&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The Grafana SAML UI provides the following advantages over configuring SAML in the Grafana configuration file:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;It is accessible by Grafana Cloud users&lt;/li&gt;
&lt;li&gt;SAML UI carries out input validation and provides useful feedback on the correctness of the configuration, making SAML setup easier&lt;/li&gt;
&lt;li&gt;It doesn&amp;rsquo;t require Grafana to be restarted after a configuration update&lt;/li&gt;
&lt;li&gt;Access to the SAML UI only requires access to authentication settings, so it can be used by users with limited access to Grafana&amp;rsquo;s configuration&lt;/li&gt;
&lt;/ul&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Any configuration changes made through the Grafana user interface (UI) will take precedence over settings specified in the Grafana configuration file or through environment variables. This means that if you modify any configuration settings in the UI, they will override any corresponding settings set via environment variables or defined in the configuration file. For more information on how Grafana determines the order of precedence for its settings, please refer to the &lt;a href=&#34;../../../configure-grafana/settings-updates-at-runtime/&#34;&gt;Settings update at runtime&lt;/a&gt;.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;



&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Disabling the UI does not affect any configuration settings that were previously set up through the UI. Those settings will continue to function as intended even with the UI disabled.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h2 id=&#34;before-you-begin&#34;&gt;Before you begin&lt;/h2&gt;
&lt;p&gt;To follow this guide, you need:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Knowledge of SAML authentication. Refer to &lt;a href=&#34;../saml/&#34;&gt;SAML authentication in Grafana&lt;/a&gt; for an overview of Grafana&amp;rsquo;s SAML integration.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Permissions &lt;code&gt;settings:read&lt;/code&gt; and &lt;code&gt;settings:write&lt;/code&gt; with scope &lt;code&gt;settings:auth.saml:*&lt;/code&gt; that allow you to read and update SAML authentication settings.&lt;/p&gt;
&lt;p&gt;These permissions are granted by &lt;code&gt;fixed:authentication.config:writer&lt;/code&gt; role.
By default, this role is granted to Grafana server administrator in self-hosted instances and to Organization admins in Grafana Cloud instances.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Grafana instance running Grafana version 10.0 or later with &lt;a href=&#34;../../../../introduction/grafana-enterprise/&#34;&gt;Grafana Enterprise&lt;/a&gt; or &lt;a href=&#34;/docs/grafana-cloud/&#34;&gt;Grafana Cloud Pro or Advanced&lt;/a&gt; license.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;steps&#34;&gt;Steps&lt;/h2&gt;
&lt;p&gt;Follow these steps to configure and enable SAML integration:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Sign in to Grafana and navigate to &lt;strong&gt;Administration &amp;gt; Authentication &amp;gt; Configure SAML&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Complete the &lt;strong&gt;General settings&lt;/strong&gt; fields.&lt;/p&gt;
&lt;p&gt;For assistance, consult the following table for additional guidance about certain fields:&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Field&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;strong&gt;Allow signup&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;If enabled, you can create new users through the SAML login. If disabled, then only existing Grafana users can log in with SAML.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;strong&gt;Auto login&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;If enabled, Grafana will attempt to automatically log in with SAML skipping the login screen.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;strong&gt;Single logout&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;The SAML single logout feature enables users to log out from all applications associated with the current IdP session established using SAML SSO. For more information, refer to [SAML single logout documentation]](../saml/#single-logout).&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;strong&gt;Identity provider initiated login&lt;/strong&gt;&lt;/td&gt;
              &lt;td&gt;Enables users to log in to Grafana directly from the SAML IdP. For more information, refer to &lt;a href=&#34;../saml/#idp-initiated-single-sign-on-sso&#34;&gt;IdP initiated login documentation&lt;/a&gt;.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;ol start=&#34;3&#34;&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Next: Key and certificate&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Provide a certificate and a private key that will be used by the service provider (Grafana) and the SAML IdP.&lt;/p&gt;
&lt;p&gt;Use the &lt;a href=&#34;https://en.wikipedia.org/wiki/PKCS_8&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;PKCS #8&lt;/a&gt; format to issue the private key.&lt;/p&gt;
&lt;p&gt;For more information, refer to an &lt;a href=&#34;../saml/#example-of-how-to-generate-saml-credentials&#34;&gt;example on how to generate SAML credentials&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;In the &lt;strong&gt;Sign requests&lt;/strong&gt; field, specify whether you want the outgoing requests to be signed, and, if so, which signature algorithm should be used.&lt;/p&gt;
&lt;p&gt;The SAML standard recommends using a digital signature for some types of messages, like authentication or logout requests to avoid &lt;a href=&#34;https://en.wikipedia.org/wiki/Man-in-the-middle_attack&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;man-in-the-middle attacks&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Next: Connect Grafana with Identity Provider&lt;/strong&gt; and complete the section.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Next: User mapping&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If you wish to &lt;a href=&#34;../saml/#assertion-mapping&#34;&gt;map user information from SAML assertions&lt;/a&gt;, complete the &lt;strong&gt;Assertion attributes mappings&lt;/strong&gt; section.&lt;/p&gt;
&lt;p&gt;You also need to configure the &lt;strong&gt;Groups attribute&lt;/strong&gt; field if you want to use team sync. Team sync automatically maps users to Grafana teams based on their SAML group membership.
Learn more about &lt;a href=&#34;../../configure-team-sync/&#34;&gt;team sync&lt;/a&gt; and &lt;a href=&#34;../saml/#configure-team-sync&#34;&gt;configuring team sync for SAML&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If you want to automatically assign users&amp;rsquo; roles based on their SAML roles, complete the &lt;strong&gt;Role mapping&lt;/strong&gt; section.&lt;/p&gt;
&lt;p&gt;First, you need to configure the &lt;strong&gt;Role attribute&lt;/strong&gt; field to specify which SAML attribute should be used to retrieve SAML role information.
Then enter the SAML roles that you want to map to Grafana roles in &lt;strong&gt;Role mapping&lt;/strong&gt; section. If you want to map multiple SAML roles to a Grafana role, separate them by a comma and a space. For example, &lt;code&gt;Editor: editor, developer&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Role mapping will automatically update user&amp;rsquo;s &lt;a href=&#34;../../../../administration/roles-and-permissions/access-control/#basic-roles&#34;&gt;basic role&lt;/a&gt; based on their SAML roles every time the user logs in to Grafana.
Learn more about &lt;a href=&#34;../saml/#configure-role-sync&#34;&gt;SAML role synchronization&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If you have multiple organizations and want to automatically add users to organizations, complete the &lt;strong&gt;Org mapping section&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;First, you need to configure the &lt;strong&gt;Org attribute&lt;/strong&gt; field to specify which SAML attribute should be used to retrieve SAML organization information.
Now fill in the &lt;strong&gt;Org mapping&lt;/strong&gt; field with mappings from SAML organization to Grafana organization. For example, &lt;code&gt;Org mapping: Engineering:2, Sales:2&lt;/code&gt; will map users who belong to &lt;code&gt;Engineering&lt;/code&gt; or &lt;code&gt;Sales&lt;/code&gt; organizations in SAML to Grafana organization with ID 2.
If you want users to have different roles in different organizations, you can additionally specify a role. For example, &lt;code&gt;Org mapping: Engineering:2:Editor&lt;/code&gt; will map users who belong to &lt;code&gt;Engineering&lt;/code&gt; organizations in SAML to Grafana organization with ID 2 and assign them Editor role.&lt;/p&gt;
&lt;p&gt;Organization mapping will automatically update user&amp;rsquo;s organization memberships (and roles, if they have been configured) based on their SAML organization every time the user logs in to Grafana.
Learn more about &lt;a href=&#34;../saml/#configure-organization-mapping&#34;&gt;SAML organization mapping&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If you want to limit the access to Grafana based on user&amp;rsquo;s SAML organization membership, fill in the &lt;strong&gt;Allowed organizations&lt;/strong&gt; field.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Next: Test and enable&lt;/strong&gt; and then click &lt;strong&gt;Save and enable&lt;/strong&gt;.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;If there are issues with your configuration, an error message will appear. Refer back to the previous steps to correct the issues and click on &lt;code&gt;Save and apply&lt;/code&gt; on the top right corner once you are done.&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If there are no configuration issues, SAML integration status will change to &lt;code&gt;Enabled&lt;/code&gt;.
Your SAML configuration is now enabled.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;To disable SAML integration, click &lt;code&gt;Disable&lt;/code&gt; in the top right corner.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
]]></content><description>&lt;h1 id="configure-saml-authentication-using-the-grafana-user-interface">Configure SAML authentication using the Grafana user interface&lt;/h1>
&lt;div class="admonition admonition-note">&lt;blockquote>&lt;p class="title text-uppercase">Note&lt;/p>&lt;p>Available in &lt;a href="../../../../introduction/grafana-enterprise/">Grafana Enterprise&lt;/a> version 10.0 and later, and &lt;a href="/docs/grafana-cloud/">Grafana Cloud Pro and Advanced&lt;/a>.&lt;/p>&lt;/blockquote>&lt;/div>
&lt;p>You can configure SAML authentication in Grafana through the user interface (UI) or the Grafana configuration file. For instructions on how to set up SAML using the Grafana configuration file, refer to &lt;a href="../saml/">Configure SAML authentication using the configuration file&lt;/a>.&lt;/p></description></item><item><title>Configure generic OAuth2 authentication</title><link>https://grafana.com/docs/grafana/v10.4/setup-grafana/configure-security/configure-authentication/generic-oauth/</link><pubDate>Fri, 07 Mar 2025 09:39:42 +0000</pubDate><guid>https://grafana.com/docs/grafana/v10.4/setup-grafana/configure-security/configure-authentication/generic-oauth/</guid><content><![CDATA[&lt;h1 id=&#34;configure-generic-oauth2-authentication&#34;&gt;Configure generic OAuth2 authentication&lt;/h1&gt;


&lt;div data-shared=&#34;auth/intro.md&#34;&gt;
            &lt;p&gt;There are numerous authentication methods available in Grafana to verify user identity. The authentication configuration dictates which users can access Grafana and the methods they can use for logging in.
You can also configure Grafana to automatically update users&amp;rsquo; roles and team memberships in Grafana based on the information returned by the auth provider integration.&lt;/p&gt;
&lt;p&gt;When deciding on an authentication method, it&amp;rsquo;s important to take into account your current identity and access management system as well as the specific authentication and authorization features you require.
For a complete list of the available authentication options and the features they support, refer to 
    &lt;a href=&#34;/docs/grafana/v10.4/setup-grafana/configure-security/configure-authentication/&#34;&gt;Configure authentication&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;

        
&lt;p&gt;Grafana provides OAuth2 integrations for the following auth providers:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;../azuread/&#34;&gt;Azure AD OAuth&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;../github/&#34;&gt;GitHub OAuth&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;../gitlab/&#34;&gt;GitLab OAuth&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;../google/&#34;&gt;Google OAuth&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;../grafana-com/&#34;&gt;Grafana Com OAuth&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;../keycloak/&#34;&gt;Keycloak OAuth&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;../okta/&#34;&gt;Okta OAuth&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If your OAuth2 provider is not listed, you can use generic OAuth2 authentication.&lt;/p&gt;
&lt;p&gt;This topic describes how to configure generic OAuth2 authentication using different methods and includes &lt;a href=&#34;#examples-of-setting-up-generic-oauth2&#34;&gt;examples of setting up generic OAuth2&lt;/a&gt; with specific OAuth2 providers.&lt;/p&gt;
&lt;h2 id=&#34;before-you-begin&#34;&gt;Before you begin&lt;/h2&gt;
&lt;p&gt;To follow this guide:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Ensure you know how to create an OAuth2 application with your OAuth2 provider. Consult the documentation of your OAuth2 provider for more information.&lt;/li&gt;
&lt;li&gt;Ensure your identity provider returns OpenID UserInfo compatible information such as the &lt;code&gt;sub&lt;/code&gt; claim.&lt;/li&gt;
&lt;li&gt;If you are using refresh tokens, ensure you know how to set them up with your OAuth2 provider. Consult the documentation of your OAuth2 provider for more information.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;configure-generic-oauth-authentication-client-using-the-grafana-ui&#34;&gt;Configure generic OAuth authentication client using the Grafana UI&lt;/h2&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Available in Public Preview in Grafana 10.4 behind the &lt;code&gt;ssoSettingsApi&lt;/code&gt; feature toggle.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;As a Grafana Admin, you can configure Generic OAuth2 client from within Grafana using the Generic OAuth UI. To do this, navigate to &lt;strong&gt;Administration &amp;gt; Authentication &amp;gt; Generic OAuth&lt;/strong&gt; page and fill in the form. If you have a current configuration in the Grafana configuration file then the form will be pre-populated with those values otherwise the form will contain default values.&lt;/p&gt;
&lt;p&gt;After you have filled in the form, click &lt;strong&gt;Save&lt;/strong&gt; to save the configuration. If the save was successful, Grafana will apply the new configurations.&lt;/p&gt;
&lt;p&gt;If you need to reset changes you made in the UI back to the default values, click &lt;strong&gt;Reset&lt;/strong&gt;. After you have reset the changes, Grafana will apply the configuration from the Grafana configuration file (if there is any configuration) or the default values.&lt;/p&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;If you run Grafana in high availability mode, configuration changes may not get applied to all Grafana instances immediately. You may need to wait a few minutes for the configuration to propagate to all Grafana instances.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;Refer to &lt;a href=&#34;#configuration-options&#34;&gt;configuration options&lt;/a&gt; for more information.&lt;/p&gt;
&lt;h2 id=&#34;configure-generic-oauth-authentication-client-using-the-terraform-provider&#34;&gt;Configure generic OAuth authentication client using the Terraform provider&lt;/h2&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Available in Public Preview in Grafana 10.4 behind the &lt;code&gt;ssoSettingsApi&lt;/code&gt; feature toggle. Supported in the Terraform provider since v2.12.0.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;


&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;terraform&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-terraform&#34;&gt;resource &amp;#34;grafana_sso_settings&amp;#34; &amp;#34;generic_sso_settings&amp;#34; {
  provider_name = &amp;#34;generic_oauth&amp;#34;
  oauth2_settings {
    name              = &amp;#34;Auth0&amp;#34;
    auth_url          = &amp;#34;https://&amp;lt;domain&amp;gt;/authorize&amp;#34;
    token_url         = &amp;#34;https://&amp;lt;domain&amp;gt;/oauth/token&amp;#34;
    api_url           = &amp;#34;https://&amp;lt;domain&amp;gt;/userinfo&amp;#34;
    client_id         = &amp;#34;&amp;lt;client id&amp;gt;&amp;#34;
    client_secret     = &amp;#34;&amp;lt;client secret&amp;gt;&amp;#34;
    allow_sign_up     = true
    auto_login        = false
    scopes            = &amp;#34;openid profile email offline_access&amp;#34;
    use_pkce          = true
    use_refresh_token = true
  }
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Refer to &lt;a href=&#34;https://registry.terraform.io/providers/grafana/grafana/latest/docs/resources/sso_settings&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Terraform Registry&lt;/a&gt; for a complete reference on using the &lt;code&gt;grafana_sso_settings&lt;/code&gt; resource.&lt;/p&gt;
&lt;h2 id=&#34;configure-generic-oauth-authentication-client-using-the-grafana-configuration-file&#34;&gt;Configure generic OAuth authentication client using the Grafana configuration file&lt;/h2&gt;
&lt;p&gt;Ensure that you have access to the &lt;a href=&#34;../../../configure-grafana/#configuration-file-location&#34;&gt;Grafana configuration file&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;steps&#34;&gt;Steps&lt;/h3&gt;
&lt;p&gt;To integrate your OAuth2 provider with Grafana using our generic OAuth2 authentication, follow these steps:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Create an OAuth2 application in your chosen OAuth2 provider.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Set the callback URL for your OAuth2 app to &lt;code&gt;http://&amp;lt;my_grafana_server_name_or_ip&amp;gt;:&amp;lt;grafana_server_port&amp;gt;/login/generic_oauth&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Ensure that the callback URL is the complete HTTP address that you use to access Grafana via your browser, but with the appended path of &lt;code&gt;/login/generic_oauth&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;For the callback URL to be correct, it might be necessary to set the &lt;code&gt;root_url&lt;/code&gt; option in the &lt;code&gt;[server]&lt;/code&gt;section of the Grafana configuration file. For example, if you are serving Grafana behind a proxy.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Refer to the following table to update field values located in the &lt;code&gt;[auth.generic_oauth]&lt;/code&gt; section of the Grafana configuration file:&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Field&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;client_id&lt;/code&gt;, &lt;code&gt;client_secret&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;These values must match the client ID and client secret from your OAuth2 app.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;auth_url&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The authorization endpoint of your OAuth2 provider.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;api_url&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The user information endpoint of your OAuth2 provider. Information returned by this endpoint must be compatible with &lt;a href=&#34;https://connect2id.com/products/server/docs/api/userinfo&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;OpenID UserInfo&lt;/a&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;enabled&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Enables generic OAuth2 authentication. Set this value to &lt;code&gt;true&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;Review the list of other generic OAuth2 &lt;a href=&#34;#configuration-options&#34;&gt;configuration options&lt;/a&gt; and complete them, as necessary.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Optional: &lt;a href=&#34;#configure-a-refresh-token&#34;&gt;Configure a refresh token&lt;/a&gt;:&lt;/p&gt;
&lt;p&gt;a. Extend the &lt;code&gt;scopes&lt;/code&gt; field of &lt;code&gt;[auth.generic_oauth]&lt;/code&gt; section in Grafana configuration file with refresh token scope used by your OAuth2 provider.&lt;/p&gt;
&lt;p&gt;b. Set &lt;code&gt;use_refresh_token&lt;/code&gt; to &lt;code&gt;true&lt;/code&gt; in &lt;code&gt;[auth.generic_oauth]&lt;/code&gt; section in Grafana configuration file.&lt;/p&gt;
&lt;p&gt;c. Enable the refresh token on the provider if required.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&#34;#configure-role-mapping&#34;&gt;Configure role mapping&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Optional: &lt;a href=&#34;#configure-team-synchronization&#34;&gt;Configure team synchronization&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Restart Grafana.&lt;/p&gt;
&lt;p&gt;You should now see a generic OAuth2 login button on the login page and be able to log in or sign up with your OAuth2 provider.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;configure-login&#34;&gt;Configure login&lt;/h3&gt;
&lt;p&gt;Grafana can resolve a user&amp;rsquo;s login from the OAuth2 ID token or user information retrieved from the OAuth2 UserInfo endpoint.
Grafana looks at these sources in the order listed until it finds a login.
If no login is found, then the user&amp;rsquo;s login is set to user&amp;rsquo;s email address.&lt;/p&gt;
&lt;p&gt;Refer to the following table for information on what to configure based on how your Oauth2 provider returns a user&amp;rsquo;s login:&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Source of login&lt;/th&gt;
              &lt;th&gt;Required configuration&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;login&lt;/code&gt; or &lt;code&gt;username&lt;/code&gt; field of the OAuth2 ID token.&lt;/td&gt;
              &lt;td&gt;N/A&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Another field of the OAuth2 ID token.&lt;/td&gt;
              &lt;td&gt;Set &lt;code&gt;login_attribute_path&lt;/code&gt; configuration option.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;login&lt;/code&gt; or &lt;code&gt;username&lt;/code&gt; field of the user information from the UserInfo endpoint.&lt;/td&gt;
              &lt;td&gt;N/A&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Another field of the user information from the UserInfo endpoint.&lt;/td&gt;
              &lt;td&gt;Set &lt;code&gt;login_attribute_path&lt;/code&gt; configuration option.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;configure-display-name&#34;&gt;Configure display name&lt;/h3&gt;
&lt;p&gt;Grafana can resolve a user&amp;rsquo;s display name from the OAuth2 ID token or user information retrieved from the OAuth2 UserInfo endpoint.
Grafana looks at these sources in the order listed until it finds a display name.
If no display name is found, then user&amp;rsquo;s login is displayed instead.&lt;/p&gt;
&lt;p&gt;Refer to the following table for information on what you need to configure depending on how your Oauth2 provider returns a user&amp;rsquo;s name:&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Source of display name&lt;/th&gt;
              &lt;th&gt;Required configuration&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;name&lt;/code&gt; or &lt;code&gt;display_name&lt;/code&gt; field of the OAuth2 ID token.&lt;/td&gt;
              &lt;td&gt;N/A&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Another field of the OAuth2 ID token.&lt;/td&gt;
              &lt;td&gt;Set &lt;code&gt;name_attribute_path&lt;/code&gt; configuration option.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;name&lt;/code&gt; or &lt;code&gt;display_name&lt;/code&gt; field of the user information from the UserInfo endpoint.&lt;/td&gt;
              &lt;td&gt;N/A&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Another field of the user information from the UserInfo endpoint.&lt;/td&gt;
              &lt;td&gt;Set &lt;code&gt;name_attribute_path&lt;/code&gt; configuration option.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;configure-email-address&#34;&gt;Configure email address&lt;/h3&gt;
&lt;p&gt;Grafana can resolve the user&amp;rsquo;s email address from the OAuth2 ID token, the user information retrieved from the OAuth2 UserInfo endpoint, or the OAuth2 &lt;code&gt;/emails&lt;/code&gt; endpoint.
Grafana looks at these sources in the order listed until an email address is found.
If no email is found, then the email address of the user is set to an empty string.&lt;/p&gt;
&lt;p&gt;Refer to the following table for information on what to configure based on how the Oauth2 provider returns a user&amp;rsquo;s email address:&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Source of email address&lt;/th&gt;
              &lt;th&gt;Required configuration&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;email&lt;/code&gt; field of the OAuth2 ID token.&lt;/td&gt;
              &lt;td&gt;N/A&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;attributes&lt;/code&gt; map of the OAuth2 ID token.&lt;/td&gt;
              &lt;td&gt;Set &lt;code&gt;email_attribute_name&lt;/code&gt; configuration option. By default, Grafana searches for email under &lt;code&gt;email:primary&lt;/code&gt; key.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;upn&lt;/code&gt; field of the OAuth2 ID token.&lt;/td&gt;
              &lt;td&gt;N/A&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;email&lt;/code&gt; field of the user information from the UserInfo endpoint.&lt;/td&gt;
              &lt;td&gt;N/A&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Another field of the user information from the UserInfo endpoint.&lt;/td&gt;
              &lt;td&gt;Set &lt;code&gt;email_attribute_path&lt;/code&gt; configuration option.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Email address marked as primary from the &lt;code&gt;/emails&lt;/code&gt; endpoint of &lt;br /&gt; the OAuth2 provider (obtained by appending &lt;code&gt;/emails&lt;/code&gt; to the URL &lt;br /&gt; configured with &lt;code&gt;api_url&lt;/code&gt;)&lt;/td&gt;
              &lt;td&gt;N/A&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;configure-a-refresh-token&#34;&gt;Configure a refresh token&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; This feature is behind the &lt;code&gt;accessTokenExpirationCheck&lt;/code&gt; feature toggle.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;When a user logs in using an OAuth2 provider, Grafana verifies that the access token has not expired. When an access token expires, Grafana uses the provided refresh token (if any exists) to obtain a new access token.&lt;/p&gt;
&lt;p&gt;Grafana uses a refresh token to obtain a new access token without requiring the user to log in again. If a refresh token doesn&amp;rsquo;t exist, Grafana logs the user out of the system after the access token has expired.&lt;/p&gt;
&lt;p&gt;To configure generic OAuth2 to use a refresh token, set &lt;code&gt;use_refresh_token&lt;/code&gt; configuration option to &lt;code&gt;true&lt;/code&gt; and perform one or both of the following steps, if required:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Extend the &lt;code&gt;scopes&lt;/code&gt; field of &lt;code&gt;[auth.generic_oauth]&lt;/code&gt; section in Grafana configuration file with additional scopes.&lt;/li&gt;
&lt;li&gt;Enable the refresh token on the provider.&lt;/li&gt;
&lt;/ol&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; The &lt;code&gt;accessTokenExpirationCheck&lt;/code&gt; feature toggle will be removed in Grafana v10.3.0 and the &lt;code&gt;use_refresh_token&lt;/code&gt; configuration value will be used instead for configuring refresh token fetching and access token expiration check.&lt;/p&gt;&lt;/blockquote&gt;
&lt;h3 id=&#34;configure-role-mapping&#34;&gt;Configure role mapping&lt;/h3&gt;
&lt;p&gt;Unless &lt;code&gt;skip_org_role_sync&lt;/code&gt; option is enabled, the user&amp;rsquo;s role will be set to the role retrieved from the auth provider upon user login.&lt;/p&gt;
&lt;p&gt;The user&amp;rsquo;s role is retrieved using a &lt;a href=&#34;http://jmespath.org/examples.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;JMESPath&lt;/a&gt; expression from the &lt;code&gt;role_attribute_path&lt;/code&gt; configuration option.
To map the server administrator role, use the &lt;code&gt;allow_assign_grafana_admin&lt;/code&gt; configuration option.
Refer to &lt;a href=&#34;#configuration-options&#34;&gt;configuration options&lt;/a&gt; for more information.&lt;/p&gt;
&lt;p&gt;If no valid role is found, the user is assigned the role specified by &lt;a href=&#34;../../../configure-grafana/#auto_assign_org_role&#34;&gt;the &lt;code&gt;auto_assign_org_role&lt;/code&gt; option&lt;/a&gt;.
You can disable this default role assignment by setting &lt;code&gt;role_attribute_strict = true&lt;/code&gt;.
This setting denies user access if no role or an invalid role is returned.&lt;/p&gt;
&lt;p&gt;To ease configuration of a proper JMESPath expression, go to &lt;a href=&#34;http://jmespath.org/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;JMESPath&lt;/a&gt; to test and evaluate expressions with custom payloads.&lt;/p&gt;
&lt;h4 id=&#34;role-mapping-examples&#34;&gt;Role mapping examples&lt;/h4&gt;
&lt;p&gt;This section includes examples of JMESPath expressions used for role mapping.&lt;/p&gt;
&lt;h5 id=&#34;map-user-organization-role&#34;&gt;Map user organization role&lt;/h5&gt;
&lt;p&gt;In this example, the user has been granted the role of an &lt;code&gt;Editor&lt;/code&gt;. The role assigned is based on the value of the property &lt;code&gt;role&lt;/code&gt;, which must be a valid Grafana role such as &lt;code&gt;Admin&lt;/code&gt;, &lt;code&gt;Editor&lt;/code&gt;, &lt;code&gt;Viewer&lt;/code&gt; or &lt;code&gt;None&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Payload:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JSON&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-json&#34;&gt;{
    ...
    &amp;#34;role&amp;#34;: &amp;#34;Editor&amp;#34;,
    ...
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Config:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;role_attribute_path = role&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;In the following more complex example, the user has been granted the &lt;code&gt;Admin&lt;/code&gt; role. This is because they are a member of the &lt;code&gt;admin&lt;/code&gt; group of their OAuth2 provider.
If the user was a member of the &lt;code&gt;editor&lt;/code&gt; group, they would be granted the &lt;code&gt;Editor&lt;/code&gt; role, otherwise &lt;code&gt;Viewer&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Payload:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JSON&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-json&#34;&gt;{
    ...
    &amp;#34;info&amp;#34;: {
        ...
        &amp;#34;groups&amp;#34;: [
            &amp;#34;engineer&amp;#34;,
            &amp;#34;admin&amp;#34;,
        ],
        ...
    },
    ...
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Config:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;role_attribute_path = contains(info.groups[*], &amp;#39;admin&amp;#39;) &amp;amp;&amp;amp; &amp;#39;Admin&amp;#39; || contains(info.groups[*], &amp;#39;editor&amp;#39;) &amp;amp;&amp;amp; &amp;#39;Editor&amp;#39; || &amp;#39;Viewer&amp;#39;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h5 id=&#34;map-server-administrator-role&#34;&gt;Map server administrator role&lt;/h5&gt;
&lt;p&gt;In the following example, the user is granted the Grafana server administrator role.&lt;/p&gt;
&lt;p&gt;Payload:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JSON&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-json&#34;&gt;{
    ...
    &amp;#34;info&amp;#34;: {
        ...
        &amp;#34;roles&amp;#34;: [
            &amp;#34;admin&amp;#34;,
        ],
        ...
    },
    ...
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Config:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;ini&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-ini&#34;&gt;role_attribute_path = contains(info.roles[*], &amp;#39;admin&amp;#39;) &amp;amp;&amp;amp; &amp;#39;GrafanaAdmin&amp;#39; || contains(info.roles[*], &amp;#39;editor&amp;#39;) &amp;amp;&amp;amp; &amp;#39;Editor&amp;#39; || &amp;#39;Viewer&amp;#39;
allow_assign_grafana_admin = true&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h5 id=&#34;map-one-role-to-all-users&#34;&gt;Map one role to all users&lt;/h5&gt;
&lt;p&gt;In this example, all users will be assigned &lt;code&gt;Viewer&lt;/code&gt; role regardless of the user information received from the identity provider.&lt;/p&gt;
&lt;p&gt;Config:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;ini&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-ini&#34;&gt;role_attribute_path = &amp;#34;&amp;#39;Viewer&amp;#39;&amp;#34;
skip_org_role_sync = false&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;configure-team-synchronization&#34;&gt;Configure team synchronization&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Available in &lt;a href=&#34;../../../../introduction/grafana-enterprise/&#34;&gt;Grafana Enterprise&lt;/a&gt; and &lt;a href=&#34;/docs/grafana-cloud/&#34;&gt;Grafana Cloud&lt;/a&gt;.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;By using Team Sync, you can link your OAuth2 groups to teams within Grafana. This will automatically assign users to the appropriate teams.
Teams for each user are synchronized when the user logs in.&lt;/p&gt;
&lt;p&gt;Generic OAuth2 groups can be referenced by group ID, such as &lt;code&gt;8bab1c86-8fba-33e5-2089-1d1c80ec267d&lt;/code&gt; or &lt;code&gt;myteam&lt;/code&gt;.
For information on configuring OAuth2 groups with Grafana using the &lt;code&gt;groups_attribute_path&lt;/code&gt; configuration option, refer to &lt;a href=&#34;#configuration-options&#34;&gt;configuration options&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;To learn more about Team Sync, refer to &lt;a href=&#34;../../configure-team-sync/&#34;&gt;Configure team sync&lt;/a&gt;.&lt;/p&gt;
&lt;h4 id=&#34;team-synchronization-example&#34;&gt;Team synchronization example&lt;/h4&gt;
&lt;p&gt;Configuration:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;groups_attribute_path = info.groups&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Payload:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JSON&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-json&#34;&gt;{
    ...
    &amp;#34;info&amp;#34;: {
        ...
        &amp;#34;groups&amp;#34;: [
            &amp;#34;engineers&amp;#34;,
            &amp;#34;analysts&amp;#34;,
        ],
        ...
    },
    ...
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;configuration-options&#34;&gt;Configuration options&lt;/h2&gt;
&lt;p&gt;The following table outlines the various generic OAuth2 configuration options. You can apply these options as environment variables, similar to any other configuration within Grafana.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Setting&lt;/th&gt;
              &lt;th&gt;Required&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Default&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;enabled&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Enables generic OAuth2 authentication.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;false&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;name&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Name that refers to the generic OAuth2 authentication from the Grafana user interface.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;OAuth&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;icon&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Icon used for the generic OAuth2 authentication in the Grafana user interface.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;signin&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;client_id&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Yes&lt;/td&gt;
              &lt;td&gt;Client ID provided by your OAuth2 app.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;client_secret&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Yes&lt;/td&gt;
              &lt;td&gt;Client secret provided by your OAuth2 app.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;auth_url&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Yes&lt;/td&gt;
              &lt;td&gt;Authorization endpoint of your OAuth2 provider.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;token_url&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Yes&lt;/td&gt;
              &lt;td&gt;Endpoint used to obtain the OAuth2 access token.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;api_url&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Yes&lt;/td&gt;
              &lt;td&gt;Endpoint used to obtain user information compatible with &lt;a href=&#34;https://connect2id.com/products/server/docs/api/userinfo&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;OpenID UserInfo&lt;/a&gt;.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;auth_style&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Name of the &lt;a href=&#34;https://pkg.go.dev/golang.org/x/oauth2#AuthStyle&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;OAuth2 AuthStyle&lt;/a&gt; to be used when ID token is requested from OAuth2 provider. It determines how &lt;code&gt;client_id&lt;/code&gt; and &lt;code&gt;client_secret&lt;/code&gt; are sent to Oauth2 provider. Available values are &lt;code&gt;AutoDetect&lt;/code&gt;, &lt;code&gt;InParams&lt;/code&gt; and &lt;code&gt;InHeader&lt;/code&gt;.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;AutoDetect&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;scopes&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;List of comma- or space-separated OAuth2 scopes.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;user:email&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;empty_scopes&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Set to &lt;code&gt;true&lt;/code&gt; to use an empty scope during authentication.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;false&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;allow_sign_up&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Controls Grafana user creation through the generic OAuth2 login. Only existing Grafana users can log in with generic OAuth if set to &lt;code&gt;false&lt;/code&gt;.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;true&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;auto_login&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Set to &lt;code&gt;true&lt;/code&gt; to enable users to bypass the login screen and automatically log in. This setting is ignored if you configure multiple auth providers to use auto-login.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;false&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;id_token_attribute_name&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;The name of the key used to extract the ID token from the returned OAuth2 token.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;id_token&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;login_attribute_path&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;http://jmespath.org/examples.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;JMESPath&lt;/a&gt; expression to use for user login lookup from the user ID token. For more information on how user login is retrieved, refer to &lt;a href=&#34;#configure-login&#34;&gt;Configure login&lt;/a&gt;.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;name_attribute_path&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;http://jmespath.org/examples.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;JMESPath&lt;/a&gt; expression to use for user name lookup from the user ID token. This name will be used as the user&amp;rsquo;s display name. For more information on how user display name is retrieved, refer to &lt;a href=&#34;#configure-display-name&#34;&gt;Configure display name&lt;/a&gt;.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;email_attribute_path&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;http://jmespath.org/examples.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;JMESPath&lt;/a&gt; expression to use for user email lookup from the user information. For more information on how user email is retrieved, refer to &lt;a href=&#34;#configure-email-address&#34;&gt;Configure email address&lt;/a&gt;.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;email_attribute_name&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Name of the key to use for user email lookup within the &lt;code&gt;attributes&lt;/code&gt; map of OAuth2 ID token. For more information on how user email is retrieved, refer to &lt;a href=&#34;#configure-email-address&#34;&gt;Configure email address&lt;/a&gt;.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;email:primary&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;role_attribute_path&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;http://jmespath.org/examples.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;JMESPath&lt;/a&gt; expression to use for Grafana role lookup. Grafana will first evaluate the expression using the OAuth2 ID token. If no role is found, the expression will be evaluated using the user information obtained from the UserInfo endpoint. The result of the evaluation should be a valid Grafana role (&lt;code&gt;Viewer&lt;/code&gt;, &lt;code&gt;Editor&lt;/code&gt;, &lt;code&gt;Admin&lt;/code&gt; or &lt;code&gt;GrafanaAdmin&lt;/code&gt;). For more information on user role mapping, refer to &lt;a href=&#34;#configure-role-mapping&#34;&gt;Configure role mapping&lt;/a&gt;.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;role_attribute_strict&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Set to &lt;code&gt;true&lt;/code&gt; to deny user login if the Grafana role cannot be extracted using &lt;code&gt;role_attribute_path&lt;/code&gt;. For more information on user role mapping, refer to &lt;a href=&#34;#configure-role-mapping&#34;&gt;Configure role mapping&lt;/a&gt;.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;false&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;allow_assign_grafana_admin&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Set to &lt;code&gt;true&lt;/code&gt; to enable automatic sync of the Grafana server administrator role. If this option is set to &lt;code&gt;true&lt;/code&gt; and the result of evaluating &lt;code&gt;role_attribute_path&lt;/code&gt; for a user is &lt;code&gt;GrafanaAdmin&lt;/code&gt;, Grafana grants the user the server administrator privileges and organization administrator role. If this option is set to &lt;code&gt;false&lt;/code&gt; and the result of evaluating &lt;code&gt;role_attribute_path&lt;/code&gt; for a user is &lt;code&gt;GrafanaAdmin&lt;/code&gt;, Grafana grants the user only organization administrator role. For more information on user role mapping, refer to &lt;a href=&#34;#configure-role-mapping&#34;&gt;Configure role mapping&lt;/a&gt;.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;false&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;skip_org_role_sync&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Set to &lt;code&gt;true&lt;/code&gt; to stop automatically syncing user roles. This will allow you to set organization roles for your users from within Grafana manually.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;false&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;groups_attribute_path&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;http://jmespath.org/examples.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;JMESPath&lt;/a&gt; expression to use for user group lookup. Grafana will first evaluate the expression using the OAuth2 ID token. If no groups are found, the expression will be evaluated using the user information obtained from the UserInfo endpoint. The result of the evaluation should be a string array of groups.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;allowed_groups&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;List of comma- or space-separated groups. The user should be a member of at least one group to log in. If you configure &lt;code&gt;allowed_groups&lt;/code&gt;, you must also configure &lt;code&gt;groups_attribute_path&lt;/code&gt;.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;allowed_organizations&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;List of comma- or space-separated organizations. The user should be a member of at least one organization to log in.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;allowed_domains&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;List comma- or space-separated domains. The user should belong to at least one domain to log in.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;team_ids&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;String list of team IDs. If set, the user must be a member of one of the given teams to log in. If you configure &lt;code&gt;team_ids&lt;/code&gt;, you must also configure &lt;code&gt;teams_url&lt;/code&gt; and &lt;code&gt;team_ids_attribute_path&lt;/code&gt;.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;team_ids_attribute_path&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;The &lt;a href=&#34;http://jmespath.org/examples.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;JMESPath&lt;/a&gt; expression to use for Grafana team ID lookup within the results returned by the &lt;code&gt;teams_url&lt;/code&gt; endpoint.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;teams_url&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;The URL used to query for team IDs. If not set, the default value is &lt;code&gt;/teams&lt;/code&gt;. If you configure &lt;code&gt;teams_url&lt;/code&gt;, you must also configure &lt;code&gt;team_ids_attribute_path&lt;/code&gt;.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;tls_skip_verify_insecure&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;If set to &lt;code&gt;true&lt;/code&gt;, the client accepts any certificate presented by the server and any host name in that certificate. &lt;em&gt;You should only use this for testing&lt;/em&gt;, because this mode leaves SSL/TLS susceptible to man-in-the-middle attacks.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;false&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;tls_client_cert&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;The path to the certificate.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;tls_client_key&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;The path to the key.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;tls_client_ca&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;The path to the trusted certificate authority list.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;use_pkce&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Set to &lt;code&gt;true&lt;/code&gt; to use &lt;a href=&#34;https://datatracker.ietf.org/doc/html/rfc7636&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Proof Key for Code Exchange (PKCE)&lt;/a&gt;. Grafana uses the SHA256 based &lt;code&gt;S256&lt;/code&gt; challenge method and a 128 bytes (base64url encoded) code verifier.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;false&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;use_refresh_token&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Set to &lt;code&gt;true&lt;/code&gt; to use refresh token and check access token expiration.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;false&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h2 id=&#34;examples-of-setting-up-generic-oauth2&#34;&gt;Examples of setting up generic OAuth2&lt;/h2&gt;
&lt;p&gt;This section includes examples of setting up generic OAuth2 integration.&lt;/p&gt;
&lt;h3 id=&#34;set-up-oauth2-with-descope&#34;&gt;Set up OAuth2 with Descope&lt;/h3&gt;
&lt;p&gt;To set up generic OAuth2 authentication with Descope, follow these steps:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Create a Descope Project &lt;a href=&#34;https://app.descope.com/gettingStarted&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;here&lt;/a&gt;, and go through the Getting Started Wizard to configure your authentication. You can skip step if you already have Descope project set up.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If you wish to use a flow besides &lt;code&gt;Sign Up or In&lt;/code&gt;, go to the &lt;strong&gt;IdP Applications&lt;/strong&gt; menu in the console, and select your IdP application. Then alter the &lt;strong&gt;Flow Hosting URL&lt;/strong&gt; query parameter &lt;code&gt;?flow=sign-up-or-in&lt;/code&gt; to change which flow id you wish to use.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Save&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Update the &lt;code&gt;[auth.generic_oauth]&lt;/code&gt; section of the Grafana configuration file using the values from the &lt;strong&gt;Settings&lt;/strong&gt; tab:&lt;/p&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;You can get your Client ID (Descope Project ID) under &lt;a href=&#34;https://app.descope.com/settings/project&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Project Settings&lt;/a&gt;. Your Client Secret (Descope Access Key) can be generated under &lt;a href=&#34;https://app.descope.com/accesskeys&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Access Keys&lt;/a&gt;.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;


&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;[auth.generic_oauth]
enabled = true
allow_sign_up = true
auto_login = false
team_ids =
allowed_organizations =
name = Descope
client_id = &amp;lt;Descope Project ID&amp;gt;
client_secret = &amp;lt;Descope Access Key&amp;gt;
scopes = openid profile email descope.claims descope.custom_claims
auth_url = https://api.descope.com/oauth2/v1/authorize
token_url = https://api.descope.com/oauth2/v1/token
api_url = https://api.descope.com/oauth2/v1/userinfo
use_pkce = true
use_refresh_token = true&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;set-up-oauth2-with-auth0&#34;&gt;Set up OAuth2 with Auth0&lt;/h3&gt;
&lt;p&gt;To set up generic OAuth2 authentication with Auth0, follow these steps:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Create an Auth0 application using the following parameters:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Name: Grafana&lt;/li&gt;
&lt;li&gt;Type: Regular Web Application&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Go to the &lt;strong&gt;Settings&lt;/strong&gt; tab of the application and set &lt;strong&gt;Allowed Callback URLs&lt;/strong&gt; to &lt;code&gt;https://&amp;lt;grafana domain&amp;gt;/login/generic_oauth&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Save Changes&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Update the &lt;code&gt;[auth.generic_oauth]&lt;/code&gt; section of the Grafana configuration file using the values from the &lt;strong&gt;Settings&lt;/strong&gt; tab:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;[auth.generic_oauth]
enabled = true
allow_sign_up = true
auto_login = false
team_ids =
allowed_organizations =
name = Auth0
client_id = &amp;lt;client id&amp;gt;
client_secret = &amp;lt;client secret&amp;gt;
scopes = openid profile email offline_access
auth_url = https://&amp;lt;domain&amp;gt;/authorize
token_url = https://&amp;lt;domain&amp;gt;/oauth/token
api_url = https://&amp;lt;domain&amp;gt;/userinfo
use_pkce = true
use_refresh_token = true&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;set-up-oauth2-with-bitbucket&#34;&gt;Set up OAuth2 with Bitbucket&lt;/h3&gt;
&lt;p&gt;To set up generic OAuth2 authentication with Bitbucket, follow these steps:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Navigate to &lt;strong&gt;Settings &amp;gt; Workspace setting &amp;gt; OAuth consumers&lt;/strong&gt; in BitBucket.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Create an application by selecting &lt;strong&gt;Add consumer&lt;/strong&gt; and using the following parameters:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Allowed Callback URLs: &lt;code&gt;https://&amp;lt;grafana domain&amp;gt;/login/generic_oauth&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Save&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Update the &lt;code&gt;[auth.generic_oauth]&lt;/code&gt; section of the Grafana configuration file using the values from the &lt;code&gt;Key&lt;/code&gt; and &lt;code&gt;Secret&lt;/code&gt; from the consumer description:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;[auth.generic_oauth]
name = BitBucket
enabled = true
allow_sign_up = true
auto_login = false
client_id = &amp;lt;client key&amp;gt;
client_secret = &amp;lt;client secret&amp;gt;
scopes = account email
auth_url = https://bitbucket.org/site/oauth2/authorize
token_url = https://bitbucket.org/site/oauth2/access_token
api_url = https://api.bitbucket.org/2.0/user
teams_url = https://api.bitbucket.org/2.0/user/permissions/workspaces
team_ids_attribute_path = values[*].workspace.slug
team_ids =
allowed_organizations =
use_refresh_token = true&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;By default, a refresh token is included in the response for the &lt;strong&gt;Authorization Code Grant&lt;/strong&gt;.&lt;/p&gt;
&lt;h3 id=&#34;set-up-oauth2-with-onelogin&#34;&gt;Set up OAuth2 with OneLogin&lt;/h3&gt;
&lt;p&gt;To set up generic OAuth2 authentication with OneLogin, follow these steps:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Create a new Custom Connector in OneLogin with the following settings:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Name: Grafana&lt;/li&gt;
&lt;li&gt;Sign On Method: OpenID Connect&lt;/li&gt;
&lt;li&gt;Redirect URI: &lt;code&gt;https://&amp;lt;grafana domain&amp;gt;/login/generic_oauth&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Signing Algorithm: RS256&lt;/li&gt;
&lt;li&gt;Login URL: &lt;code&gt;https://&amp;lt;grafana domain&amp;gt;/login/generic_oauth&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Add an app to the Grafana Connector:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Display Name: Grafana&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Update the &lt;code&gt;[auth.generic_oauth]&lt;/code&gt; section of the Grafana configuration file using the client ID and client secret from the &lt;strong&gt;SSO&lt;/strong&gt; tab of the app details page:&lt;/p&gt;
&lt;p&gt;Your OneLogin Domain will match the URL you use to access OneLogin.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;[auth.generic_oauth]
name = OneLogin
enabled = true
allow_sign_up = true
auto_login = false
client_id = &amp;lt;client id&amp;gt;
client_secret = &amp;lt;client secret&amp;gt;
scopes = openid email name
auth_url = https://&amp;lt;onelogin domain&amp;gt;.onelogin.com/oidc/2/auth
token_url = https://&amp;lt;onelogin domain&amp;gt;.onelogin.com/oidc/2/token
api_url = https://&amp;lt;onelogin domain&amp;gt;.onelogin.com/oidc/2/me
team_ids =
allowed_organizations =&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
]]></content><description>&lt;h1 id="configure-generic-oauth2-authentication">Configure generic OAuth2 authentication&lt;/h1>
&lt;div data-shared="auth/intro.md">
&lt;p>There are numerous authentication methods available in Grafana to verify user identity. The authentication configuration dictates which users can access Grafana and the methods they can use for logging in.
You can also configure Grafana to automatically update users&amp;rsquo; roles and team memberships in Grafana based on the information returned by the auth provider integration.&lt;/p></description></item><item><title>Configure Azure AD OAuth2 authentication</title><link>https://grafana.com/docs/grafana/v10.4/setup-grafana/configure-security/configure-authentication/azuread/</link><pubDate>Fri, 07 Mar 2025 09:39:42 +0000</pubDate><guid>https://grafana.com/docs/grafana/v10.4/setup-grafana/configure-security/configure-authentication/azuread/</guid><content><![CDATA[&lt;h1 id=&#34;configure-azure-ad-oauth2-authentication&#34;&gt;Configure Azure AD OAuth2 authentication&lt;/h1&gt;
&lt;p&gt;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.&lt;/p&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;If Users use the same email address in Azure AD that they use with other authentication providers (such as Grafana.com), you need to do additional configuration to ensure that the users are matched correctly. Please refer to &lt;a href=&#34;../#using-the-same-email-address-to-login-with-different-identity-providers&#34;&gt;Using the same email address to login with different identity providers&lt;/a&gt; for more information.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h2 id=&#34;create-the-azure-ad-application&#34;&gt;Create the Azure AD application&lt;/h2&gt;
&lt;p&gt;To enable the Azure AD OAuth2, register your application with Azure AD.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Log in to &lt;a href=&#34;https://portal.azure.com&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Azure Portal&lt;/a&gt;, then click &lt;strong&gt;Azure Active Directory&lt;/strong&gt; in the side menu.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Under &lt;strong&gt;Manage&lt;/strong&gt; in the side menu, click &lt;strong&gt;App Registrations&lt;/strong&gt; &amp;gt; &lt;strong&gt;New Registration&lt;/strong&gt;. Enter a descriptive name.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Under &lt;strong&gt;Redirect URI&lt;/strong&gt;, select the app type &lt;strong&gt;Web&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Add the following redirect URLs &lt;code&gt;https://&amp;lt;grafana domain&amp;gt;/login/azuread&lt;/code&gt; and &lt;code&gt;https://&amp;lt;grafana domain&amp;gt;&lt;/code&gt; then click &lt;strong&gt;Register&lt;/strong&gt;. The app&amp;rsquo;s &lt;strong&gt;Overview&lt;/strong&gt; page opens.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Note the &lt;strong&gt;Application ID&lt;/strong&gt;. This is the OAuth client ID.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Endpoints&lt;/strong&gt; from the top menu.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Note the &lt;strong&gt;OAuth 2.0 authorization endpoint (v2)&lt;/strong&gt; URL. This is the authorization URL.&lt;/li&gt;
&lt;li&gt;Note the &lt;strong&gt;OAuth 2.0 token endpoint (v2)&lt;/strong&gt;. This is the token URL.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Certificates &amp;amp; secrets&lt;/strong&gt;, then add a new entry under &lt;strong&gt;Client secrets&lt;/strong&gt; with the following configuration.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Description: Grafana OAuth&lt;/li&gt;
&lt;li&gt;Expires: Never&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Add&lt;/strong&gt; then copy the key value. This is the OAuth client secret.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Define the required application roles for Grafana &lt;a href=&#34;#configure-application-roles-for-grafana-in-the-azure-portal&#34;&gt;using the Azure Portal&lt;/a&gt; or &lt;a href=&#34;#configure-application-roles-for-grafana-in-the-manifest-file&#34;&gt;using the manifest file&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Go to &lt;strong&gt;Azure Active Directory&lt;/strong&gt; and then to &lt;strong&gt;Enterprise Applications&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Search for your application and click it.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Users and Groups&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Add user/group&lt;/strong&gt; to add a user or group to the Grafana roles.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;configure-application-roles-for-grafana-in-the-azure-portal&#34;&gt;Configure application roles for Grafana in the Azure Portal&lt;/h3&gt;
&lt;p&gt;This section describes setting up basic application roles for Grafana within the Azure Portal. For more information, see &lt;a href=&#34;https://learn.microsoft.com/en-us/entra/identity-platform/howto-add-app-roles-in-apps&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Add app roles to your application and receive them in the token&lt;/a&gt;.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Go to &lt;strong&gt;App Registrations&lt;/strong&gt;, search for your application, and click it.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;App roles&lt;/strong&gt; and then &lt;strong&gt;Create app role&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Define a role corresponding to each Grafana role: Viewer, Editor, and Admin.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Choose a &lt;strong&gt;Display name&lt;/strong&gt; for the role. For example, &amp;ldquo;Grafana Editor&amp;rdquo;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Set the &lt;strong&gt;Allowed member types&lt;/strong&gt; to &lt;strong&gt;Users/Groups&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Ensure that the &lt;strong&gt;Value&lt;/strong&gt; field matches the Grafana role name. For example, &amp;ldquo;Editor&amp;rdquo;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Choose a &lt;strong&gt;Description&lt;/strong&gt; for the role. For example, &amp;ldquo;Grafana Editor Users&amp;rdquo;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Apply&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;configure-application-roles-for-grafana-in-the-manifest-file&#34;&gt;Configure application roles for Grafana in the manifest file&lt;/h3&gt;
&lt;p&gt;If you prefer to configure the application roles for Grafana in the manifest file, complete the following steps:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Go to &lt;strong&gt;App Registrations&lt;/strong&gt;, search for your application, and click it.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Manifest&lt;/strong&gt; and then click &lt;strong&gt;Edit&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Add a Universally Unique Identifier to each role.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Every role requires a &lt;a href=&#34;https://en.wikipedia.org/wiki/Universally_unique_identifier&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Universally Unique Identifier&lt;/a&gt; which you can generate on Linux with &lt;code&gt;uuidgen&lt;/code&gt;, and on Windows through Microsoft PowerShell with &lt;code&gt;New-Guid&lt;/code&gt;.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Replace each &amp;ldquo;SOME_UNIQUE_ID&amp;rdquo; with the generated ID in the manifest file:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JSON&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-json&#34;&gt;	&amp;#34;appRoles&amp;#34;: [
			{
				&amp;#34;allowedMemberTypes&amp;#34;: [
					&amp;#34;User&amp;#34;
				],
				&amp;#34;description&amp;#34;: &amp;#34;Grafana org admin Users&amp;#34;,
				&amp;#34;displayName&amp;#34;: &amp;#34;Grafana Org Admin&amp;#34;,
				&amp;#34;id&amp;#34;: &amp;#34;SOME_UNIQUE_ID&amp;#34;,
				&amp;#34;isEnabled&amp;#34;: true,
				&amp;#34;lang&amp;#34;: null,
				&amp;#34;origin&amp;#34;: &amp;#34;Application&amp;#34;,
				&amp;#34;value&amp;#34;: &amp;#34;Admin&amp;#34;
			},
			{
				&amp;#34;allowedMemberTypes&amp;#34;: [
					&amp;#34;User&amp;#34;
				],
				&amp;#34;description&amp;#34;: &amp;#34;Grafana read only Users&amp;#34;,
				&amp;#34;displayName&amp;#34;: &amp;#34;Grafana Viewer&amp;#34;,
				&amp;#34;id&amp;#34;: &amp;#34;SOME_UNIQUE_ID&amp;#34;,
				&amp;#34;isEnabled&amp;#34;: true,
				&amp;#34;lang&amp;#34;: null,
				&amp;#34;origin&amp;#34;: &amp;#34;Application&amp;#34;,
				&amp;#34;value&amp;#34;: &amp;#34;Viewer&amp;#34;
			},
			{
				&amp;#34;allowedMemberTypes&amp;#34;: [
					&amp;#34;User&amp;#34;
				],
				&amp;#34;description&amp;#34;: &amp;#34;Grafana Editor Users&amp;#34;,
				&amp;#34;displayName&amp;#34;: &amp;#34;Grafana Editor&amp;#34;,
				&amp;#34;id&amp;#34;: &amp;#34;SOME_UNIQUE_ID&amp;#34;,
				&amp;#34;isEnabled&amp;#34;: true,
				&amp;#34;lang&amp;#34;: null,
				&amp;#34;origin&amp;#34;: &amp;#34;Application&amp;#34;,
				&amp;#34;value&amp;#34;: &amp;#34;Editor&amp;#34;
			}
		],&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Save&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;assign-server-administrator-privileges&#34;&gt;Assign server administrator privileges&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;Available in Grafana v9.2 and later versions.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;If the application role received by Grafana is &lt;code&gt;GrafanaAdmin&lt;/code&gt;, Grafana grants the user server administrator privileges.&lt;br /&gt;
This is useful if you want to grant server administrator privileges to a subset of users.&lt;br /&gt;
Grafana also assigns the user the &lt;code&gt;Admin&lt;/code&gt; role of the default organization.&lt;/p&gt;
&lt;p&gt;The setting &lt;code&gt;allow_assign_grafana_admin&lt;/code&gt; under &lt;code&gt;[auth.azuread]&lt;/code&gt; must be set to &lt;code&gt;true&lt;/code&gt; for this to work.&lt;br /&gt;
If the setting is set to &lt;code&gt;false&lt;/code&gt;, the user is assigned the role of &lt;code&gt;Admin&lt;/code&gt; of the default organization, but not server administrator privileges.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JSON&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-json&#34;&gt;{
  &amp;#34;allowedMemberTypes&amp;#34;: [&amp;#34;User&amp;#34;],
  &amp;#34;description&amp;#34;: &amp;#34;Grafana server admin Users&amp;#34;,
  &amp;#34;displayName&amp;#34;: &amp;#34;Grafana Server Admin&amp;#34;,
  &amp;#34;id&amp;#34;: &amp;#34;SOME_UNIQUE_ID&amp;#34;,
  &amp;#34;isEnabled&amp;#34;: true,
  &amp;#34;lang&amp;#34;: null,
  &amp;#34;origin&amp;#34;: &amp;#34;Application&amp;#34;,
  &amp;#34;value&amp;#34;: &amp;#34;GrafanaAdmin&amp;#34;
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;before-you-begin&#34;&gt;Before you begin&lt;/h2&gt;
&lt;p&gt;Ensure that you have followed the steps in &lt;a href=&#34;#create-the-azure-ad-application&#34;&gt;Create the Azure AD application&lt;/a&gt; before you begin.&lt;/p&gt;
&lt;h2 id=&#34;configure-azure-ad-authentication-client-using-the-grafana-ui&#34;&gt;Configure Azure AD authentication client using the Grafana UI&lt;/h2&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Available in Public Preview in Grafana 10.4 behind the &lt;code&gt;ssoSettingsApi&lt;/code&gt; feature toggle.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;As a Grafana Admin, you can configure your Azure AD OAuth2 client from within Grafana using the Grafana UI. To do this, navigate to the &lt;strong&gt;Administration &amp;gt; Authentication &amp;gt; Azure AD&lt;/strong&gt; page and fill in the form. If you have a current configuration in the Grafana configuration file, the form will be pre-populated with those values. Otherwise the form will contain default values.&lt;/p&gt;
&lt;p&gt;After you have filled in the form, click &lt;strong&gt;Save&lt;/strong&gt; to save the configuration. If the save was successful, Grafana will apply the new configurations.&lt;/p&gt;
&lt;p&gt;If you need to reset changes you made in the UI back to the default values, click &lt;strong&gt;Reset&lt;/strong&gt;. After you have reset the changes, Grafana will apply the configuration from the Grafana configuration file (if there is any configuration) or the default values.&lt;/p&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;If you run Grafana in high availability mode, configuration changes may not get applied to all Grafana instances immediately. You may need to wait a few minutes for the configuration to propagate to all Grafana instances.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h2 id=&#34;configure-azure-ad-authentication-client-using-the-terraform-provider&#34;&gt;Configure Azure AD authentication client using the Terraform provider&lt;/h2&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Available in Public Preview in Grafana 10.4 behind the &lt;code&gt;ssoSettingsApi&lt;/code&gt; feature toggle. Supported in the Terraform provider since v2.12.0.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;


&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;terraform&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-terraform&#34;&gt;resource &amp;#34;grafana_sso_settings&amp;#34; &amp;#34;azuread_sso_settings&amp;#34; {
  provider_name = &amp;#34;azuread&amp;#34;
  oauth2_settings {
    name                       = &amp;#34;Azure AD&amp;#34;
    auth_url                   = &amp;#34;https://login.microsoftonline.com/TENANT_ID/oauth2/v2.0/authorize&amp;#34;
    token_url                  = &amp;#34;https://login.microsoftonline.com/TENANT_ID/oauth2/v2.0/token&amp;#34;
    client_id                  = &amp;#34;APPLICATION_ID&amp;#34;
    client_secret              = &amp;#34;CLIENT_SECRET&amp;#34;
    allow_sign_up              = true
    auto_login                 = false
    scopes                     = &amp;#34;openid email profile&amp;#34;
    allowed_organizations      = &amp;#34;TENANT_ID&amp;#34;
    role_attribute_strict      = false
    allow_assign_grafana_admin = false
    skip_org_role_sync         = false
    use_pkce                   = true
  }
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Refer to &lt;a href=&#34;https://registry.terraform.io/providers/grafana/grafana/latest/docs/resources/sso_settings&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Terraform Registry&lt;/a&gt; for a complete reference on using the &lt;code&gt;grafana_sso_settings&lt;/code&gt; resource.&lt;/p&gt;
&lt;h2 id=&#34;configure-azure-ad-authentication-client-using-the-grafana-configuration-file&#34;&gt;Configure Azure AD authentication client using the Grafana configuration file&lt;/h2&gt;
&lt;p&gt;Ensure that you have access to the &lt;a href=&#34;../../../configure-grafana/#configuration-file-location&#34;&gt;Grafana configuration file&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;enable-azure-ad-oauth-in-grafana&#34;&gt;Enable Azure AD OAuth in Grafana&lt;/h3&gt;
&lt;p&gt;Add the following to the &lt;a href=&#34;../../../configure-grafana/#configuration-file-location&#34;&gt;Grafana configuration file&lt;/a&gt;:&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;[auth.azuread]
name = Azure AD
enabled = true
allow_sign_up = true
auto_login = false
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
allowed_domains =
allowed_groups =
allowed_organizations = TENANT_ID
role_attribute_strict = false
allow_assign_grafana_admin = false
skip_org_role_sync = false
use_pkce = true&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;You can also use these environment variables to configure &lt;strong&gt;client_id&lt;/strong&gt; and &lt;strong&gt;client_secret&lt;/strong&gt;:&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;GF_AUTH_AZUREAD_CLIENT_ID
GF_AUTH_AZUREAD_CLIENT_SECRET&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Verify that the Grafana &lt;a href=&#34;../../../configure-grafana/#root_url&#34;&gt;root_url&lt;/a&gt; is set in your Azure Application Redirect URLs.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h3 id=&#34;configure-refresh-token&#34;&gt;Configure refresh token&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;Available in Grafana v9.3 and later versions.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;When a user logs in using an OAuth provider, Grafana verifies that the access token has not expired. When an access token expires, Grafana uses the provided refresh token (if any exists) to obtain a new access token.&lt;/p&gt;
&lt;p&gt;Grafana uses a refresh token to obtain a new access token without requiring the user to log in again. If a refresh token doesn&amp;rsquo;t exist, Grafana logs the user out of the system after the access token has expired.&lt;/p&gt;
&lt;p&gt;Refresh token fetching and access token expiration check is enabled by default for the AzureAD provider since Grafana v10.1.0. If you would like to disable access token expiration check then set the &lt;code&gt;use_refresh_token&lt;/code&gt; configuration value to &lt;code&gt;false&lt;/code&gt;.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; The &lt;code&gt;accessTokenExpirationCheck&lt;/code&gt; feature toggle has been removed in Grafana v10.3.0 and the &lt;code&gt;use_refresh_token&lt;/code&gt; configuration value will be used instead for configuring refresh token fetching and access token expiration check.&lt;/p&gt;&lt;/blockquote&gt;
&lt;h3 id=&#34;configure-allowed-tenants&#34;&gt;Configure allowed tenants&lt;/h3&gt;
&lt;p&gt;To limit access to authenticated users who are members of one or more tenants, set &lt;code&gt;allowed_organizations&lt;/code&gt;
to a comma- or space-separated list of tenant IDs. You can find tenant IDs on the Azure portal under &lt;strong&gt;Azure Active Directory -&amp;gt; Overview&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Make sure to include the tenant IDs of all the federated Users&amp;rsquo; root directory if your Azure AD contains external identities.&lt;/p&gt;
&lt;p&gt;For example, if you want to only give access to members of the tenant &lt;code&gt;example&lt;/code&gt; with an ID of &lt;code&gt;8bab1c86-8fba-33e5-2089-1d1c80ec267d&lt;/code&gt;, then set the following:&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;allowed_organizations = 8bab1c86-8fba-33e5-2089-1d1c80ec267d&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;configure-allowed-groups&#34;&gt;Configure allowed groups&lt;/h3&gt;
&lt;p&gt;Azure AD groups can be used to limit user access to Grafana. For more information about managing groups in Azure AD, refer to &lt;a href=&#34;https://learn.microsoft.com/en-us/entra/fundamentals/how-to-manage-groups&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Manage Microsoft Entra groups and group membership&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;To limit access to authenticated users who are members of one or more AzureAD groups, set &lt;code&gt;allowed_groups&lt;/code&gt;
to a &lt;strong&gt;comma-&lt;/strong&gt; or &lt;strong&gt;space-separated&lt;/strong&gt; list of group object IDs.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;To find object IDs for a specific group on the Azure portal, go to &lt;strong&gt;Azure Active Directory &amp;gt; Groups&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;You can find the Object Id of a group by clicking on the group and then clicking on &lt;strong&gt;Properties&lt;/strong&gt;. The object ID is listed under &lt;strong&gt;Object ID&lt;/strong&gt;. If you want to only give access to members of the group &lt;code&gt;example&lt;/code&gt; with an Object Id of &lt;code&gt;8bab1c86-8fba-33e5-2089-1d1c80ec267d&lt;/code&gt;, then set the following:&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;  allowed_groups = 8bab1c86-8fba-33e5-2089-1d1c80ec267d&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You must enable adding the &lt;a href=&#34;https://learn.microsoft.com/en-us/entra/identity-platform/optional-claims#configure-groups-optional-claims&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;group attribute&lt;/a&gt; to the tokens in your Azure AD App registration either &lt;a href=&#34;#configure-group-membership-claims-on-the-azure-portal&#34;&gt;from the Azure Portal&lt;/a&gt; or &lt;a href=&#34;#configure-group-membership-claim-in-the-manifest-file&#34;&gt;from the manifest file&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h4 id=&#34;configure-group-membership-claims-on-the-azure-portal&#34;&gt;Configure group membership claims on the Azure Portal&lt;/h4&gt;
&lt;p&gt;To ensure that the &lt;code&gt;groups&lt;/code&gt; claim is included in the token, add the &lt;code&gt;groups&lt;/code&gt; claim to the token configuration either through the Azure Portal UI or by editing the manifest file.&lt;/p&gt;
&lt;p&gt;To configure group membership claims from the Azure Portal UI, complete the following steps:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Navigate to the &lt;strong&gt;App Registrations&lt;/strong&gt; page and select your application.&lt;/li&gt;
&lt;li&gt;Select &lt;strong&gt;Token configuration&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Add groups claim&lt;/strong&gt; and select the relevant option for your use case (for example, &lt;strong&gt;Security groups&lt;/strong&gt; and &lt;strong&gt;Groups assigned to the application&lt;/strong&gt;).&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;For more information, see &lt;a href=&#34;https://learn.microsoft.com/en-us/entra/identity-platform/optional-claims#configure-groups-optional-claims&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Configure groups optional claims&lt;/a&gt;.&lt;/p&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;If the user is a member of more than 200 groups, Azure AD does not emit the groups claim in the token and instead emits a group overage claim. To set up a group overage claim, see &lt;a href=&#34;#users-with-over-200-group-assignments&#34;&gt;Users with over 200 Group assignments&lt;/a&gt;.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h4 id=&#34;configure-group-membership-claim-in-the-manifest-file&#34;&gt;Configure group membership claim in the manifest file&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Go to &lt;strong&gt;App Registrations&lt;/strong&gt;, search for your application, and click it.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Manifest&lt;/strong&gt; and then click &lt;strong&gt;Edit&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Add the following to the root of the manifest file:&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;&amp;#34;groupMembershipClaims&amp;#34;: &amp;#34;ApplicationGroup, SecurityGroup&amp;#34;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;configure-allowed-domains&#34;&gt;Configure allowed domains&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;allowed_domains&lt;/code&gt; option limits access to users who belong to specific domains. Separate domains with space or comma. For example,&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;allowed_domains = mycompany.com mycompany.org&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;pkce&#34;&gt;PKCE&lt;/h3&gt;
&lt;p&gt;IETF&amp;rsquo;s &lt;a href=&#34;https://datatracker.ietf.org/doc/html/rfc7636&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;RFC 7636&lt;/a&gt;
introduces &amp;ldquo;proof key for code exchange&amp;rdquo; (PKCE) which provides
additional protection against some forms of authorization code
interception attacks. PKCE will be required in &lt;a href=&#34;https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-03&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;OAuth 2.1&lt;/a&gt;.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;You can disable PKCE in Grafana by setting &lt;code&gt;use_pkce&lt;/code&gt; to &lt;code&gt;false&lt;/code&gt; in the&lt;code&gt;[auth.azuread]&lt;/code&gt; section.&lt;/p&gt;&lt;/blockquote&gt;
&lt;h3 id=&#34;configure-automatic-login&#34;&gt;Configure automatic login&lt;/h3&gt;
&lt;p&gt;To bypass the login screen and log in automatically, enable the &amp;ldquo;auto_login&amp;rdquo; feature.
This setting is ignored if multiple auth providers are configured to use auto login.&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;auto_login = true&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;team-sync-enterprise-only&#34;&gt;Team Sync (Enterprise only)&lt;/h3&gt;
&lt;p&gt;With Team Sync you can map your Azure AD groups to teams in Grafana so that your users will automatically be added to
the correct teams.&lt;/p&gt;
&lt;p&gt;You can reference Azure AD groups by group object ID, like &lt;code&gt;8bab1c86-8fba-33e5-2089-1d1c80ec267d&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;To learn more, refer to the &lt;a href=&#34;../../configure-team-sync/&#34;&gt;Team Sync&lt;/a&gt; documentation.&lt;/p&gt;
&lt;h2 id=&#34;common-troubleshooting&#34;&gt;Common troubleshooting&lt;/h2&gt;
&lt;p&gt;Here are some common issues and particulars you can run into when
configuring Azure AD authentication in Grafana.&lt;/p&gt;
&lt;h3 id=&#34;users-with-over-200-group-assignments&#34;&gt;Users with over 200 Group assignments&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;Supported in Grafana v8.5 and later versions.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;To ensure that the token size doesn&amp;rsquo;t exceed HTTP header size limits,
Azure AD limits the number of object IDs that it includes in the groups claim.
If a user is member of more groups than the
overage limit (200), then
Azure AD does not emit the groups claim in the token and emits a group overage claim instead.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;More information in &lt;a href=&#34;https://learn.microsoft.com/en-us/azure/active-directory/develop/id-token-claims-reference#groups-overage-claim&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Groups overage claim&lt;/a&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;If Grafana receives a token with a group overage claim instead of a groups claim,
Grafana attempts to retrieve the user&amp;rsquo;s group membership by calling the included endpoint.&lt;/p&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;The &amp;lsquo;App registration&amp;rsquo; must include the &lt;code&gt;GroupMember.Read.All&lt;/code&gt; API permission for group overage claim calls to succeed.&lt;/p&gt;
&lt;p&gt;Admin consent might be required for this permission.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h4 id=&#34;configure-the-required-graph-api-permissions&#34;&gt;Configure the required Graph API permissions&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;Navigate to &lt;strong&gt;Azure Active Directory &amp;gt; App registrations&lt;/strong&gt; and select your application.&lt;/li&gt;
&lt;li&gt;Select &lt;strong&gt;API permissions&lt;/strong&gt; and then click on &lt;strong&gt;Add a permission&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Select &lt;strong&gt;Microsoft Graph&lt;/strong&gt; from the list of APIs.&lt;/li&gt;
&lt;li&gt;Select &lt;strong&gt;Delegated permissions&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Under the &lt;strong&gt;GroupMember&lt;/strong&gt; section, select &lt;strong&gt;GroupMember.Read.All&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Add permissions&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Admin consent may be required for this permission.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h3 id=&#34;force-fetching-groups-from-microsoft-graph-api&#34;&gt;Force fetching groups from Microsoft Graph API&lt;/h3&gt;
&lt;p&gt;To force fetching groups from Microsoft Graph API instead of the &lt;code&gt;id_token&lt;/code&gt;. You can use the &lt;code&gt;force_use_graph_api&lt;/code&gt; config option.&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;force_use_graph_api = true&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;map-roles&#34;&gt;Map roles&lt;/h3&gt;
&lt;p&gt;By default, Azure AD authentication will map users to organization roles based on the most privileged application role assigned to the user in AzureAD.&lt;/p&gt;
&lt;p&gt;If no application role is found, the user is assigned the role specified by
&lt;a href=&#34;../../../configure-grafana/#auto_assign_org_role&#34;&gt;the &lt;code&gt;auto_assign_org_role&lt;/code&gt; option&lt;/a&gt;.
You can disable this default role assignment by setting &lt;code&gt;role_attribute_strict = true&lt;/code&gt;.
It denies user access if no role or an invalid role is returned.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;On every login&lt;/strong&gt; the user organization role will be reset to match AzureAD&amp;rsquo;s application role and
their organization membership will be reset to the default organization.&lt;/p&gt;
&lt;h2 id=&#34;skip-organization-role-sync&#34;&gt;Skip organization role sync&lt;/h2&gt;
&lt;p&gt;If Azure AD authentication is not intended to sync user roles and organization membership and prevent the sync of org roles from AzureAD, set &lt;code&gt;skip_org_role_sync&lt;/code&gt; to &lt;code&gt;true&lt;/code&gt;. This is useful if you want to manage the organization roles for your users from within Grafana or that your organization roles are synced from another provider.
See &lt;a href=&#34;../../../configure-grafana/#authazuread&#34;&gt;Configure Grafana&lt;/a&gt; for more details.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;ini&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-ini&#34;&gt;[auth.azuread]
# ..
# prevents the sync of org roles from AzureAD
skip_org_role_sync = true&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="configure-azure-ad-oauth2-authentication">Configure Azure AD OAuth2 authentication&lt;/h1>
&lt;p>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.&lt;/p></description></item><item><title>Configure GitHub OAuth2 authentication</title><link>https://grafana.com/docs/grafana/v10.4/setup-grafana/configure-security/configure-authentication/github/</link><pubDate>Fri, 07 Mar 2025 09:39:42 +0000</pubDate><guid>https://grafana.com/docs/grafana/v10.4/setup-grafana/configure-security/configure-authentication/github/</guid><content><![CDATA[&lt;h1 id=&#34;configure-github-oauth2-authentication&#34;&gt;Configure GitHub OAuth2 authentication&lt;/h1&gt;


&lt;div data-shared=&#34;auth/intro.md&#34;&gt;
            &lt;p&gt;There are numerous authentication methods available in Grafana to verify user identity. The authentication configuration dictates which users can access Grafana and the methods they can use for logging in.
You can also configure Grafana to automatically update users&amp;rsquo; roles and team memberships in Grafana based on the information returned by the auth provider integration.&lt;/p&gt;
&lt;p&gt;When deciding on an authentication method, it&amp;rsquo;s important to take into account your current identity and access management system as well as the specific authentication and authorization features you require.
For a complete list of the available authentication options and the features they support, refer to 
    &lt;a href=&#34;/docs/grafana/v10.4/setup-grafana/configure-security/configure-authentication/&#34;&gt;Configure authentication&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;

        
&lt;p&gt;This topic describes how to configure GitHub OAuth2 authentication.&lt;/p&gt;
&lt;h2 id=&#34;before-you-begin&#34;&gt;Before you begin&lt;/h2&gt;
&lt;p&gt;Ensure you know how to create a GitHub OAuth app. Consult GitHub&amp;rsquo;s documentation on &lt;a href=&#34;https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/creating-an-oauth-app&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;creating an OAuth app&lt;/a&gt; for more information.&lt;/p&gt;
&lt;h2 id=&#34;configure-github-authentication-client-using-the-grafana-ui&#34;&gt;Configure GitHub authentication client using the Grafana UI&lt;/h2&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Available in Public Preview in Grafana 10.4 behind the &lt;code&gt;ssoSettingsApi&lt;/code&gt; feature toggle.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;As a Grafana Admin, you can configure GitHub OAuth2 client from within Grafana using the GitHub UI. To do this, navigate to &lt;strong&gt;Administration &amp;gt; Authentication &amp;gt; GitHub&lt;/strong&gt; page and fill in the form. If you have a current configuration in the Grafana configuration file, the form will be pre-populated with those values. Otherwise the form will contain default values.&lt;/p&gt;
&lt;p&gt;After you have filled in the form, click &lt;strong&gt;Save&lt;/strong&gt; . If the save was successful, Grafana will apply the new configurations.&lt;/p&gt;
&lt;p&gt;If you need to reset changes you made in the UI back to the default values, click &lt;strong&gt;Reset&lt;/strong&gt;. After you have reset the changes, Grafana will apply the configuration from the Grafana configuration file (if there is any configuration) or the default values.&lt;/p&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;If you run Grafana in high availability mode, configuration changes may not get applied to all Grafana instances immediately. You may need to wait a few minutes for the configuration to propagate to all Grafana instances.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;Refer to &lt;a href=&#34;#configuration-options&#34;&gt;configuration options&lt;/a&gt; for more information.&lt;/p&gt;
&lt;h2 id=&#34;configure-github-authentication-client-using-the-terraform-provider&#34;&gt;Configure GitHub authentication client using the Terraform provider&lt;/h2&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Available in Public Preview in Grafana 10.4 behind the &lt;code&gt;ssoSettingsApi&lt;/code&gt; feature toggle. Supported in the Terraform provider since v2.12.0.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;


&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;terraform&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-terraform&#34;&gt;resource &amp;#34;grafana_sso_settings&amp;#34; &amp;#34;github_sso_settings&amp;#34; {
  provider_name = &amp;#34;github&amp;#34;
  oauth2_settings {
    name                  = &amp;#34;Github&amp;#34;
    client_id             = &amp;#34;YOUR_GITHUB_APP_CLIENT_ID&amp;#34;
    client_secret         = &amp;#34;YOUR_GITHUB_APP_CLIENT_SECRET&amp;#34;
    allow_sign_up         = true
    auto_login            = false
    scopes                = &amp;#34;user:email,read:org&amp;#34;
    team_ids              = &amp;#34;150,300&amp;#34;
    allowed_organizations = &amp;#34;[\&amp;#34;My Organization\&amp;#34;, \&amp;#34;Octocats\&amp;#34;]&amp;#34;
    allowed_domains       = &amp;#34;mycompany.com mycompany.org&amp;#34;
    role_attribute_path   = &amp;#34;[login==&amp;#39;octocat&amp;#39;][0] &amp;amp;&amp;amp; &amp;#39;GrafanaAdmin&amp;#39; || &amp;#39;Viewer&amp;#39;&amp;#34;
  }
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Go to &lt;a href=&#34;https://registry.terraform.io/providers/grafana/grafana/latest/docs/resources/sso_settings&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Terraform Registry&lt;/a&gt; for a complete reference on using the &lt;code&gt;grafana_sso_settings&lt;/code&gt; resource.&lt;/p&gt;
&lt;h2 id=&#34;configure-github-authentication-client-using-the-grafana-configuration-file&#34;&gt;Configure GitHub authentication client using the Grafana configuration file&lt;/h2&gt;
&lt;p&gt;Ensure that you have access to the &lt;a href=&#34;../../../configure-grafana/#configuration-file-location&#34;&gt;Grafana configuration file&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;configure-github-authentication&#34;&gt;Configure GitHub authentication&lt;/h3&gt;
&lt;p&gt;To configure GitHub authentication with Grafana, follow these steps:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Create an OAuth application in GitHub.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Set the callback URL for your GitHub OAuth app to &lt;code&gt;http://&amp;lt;my_grafana_server_name_or_ip&amp;gt;:&amp;lt;grafana_server_port&amp;gt;/login/github&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Ensure that the callback URL is the complete HTTP address that you use to access Grafana via your browser, but with the appended path of &lt;code&gt;/login/github&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;For the callback URL to be correct, it might be necessary to set the &lt;code&gt;root_url&lt;/code&gt; option in the &lt;code&gt;[server]&lt;/code&gt;section of the Grafana configuration file. For example, if you are serving Grafana behind a proxy.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Refer to the following table to update field values located in the &lt;code&gt;[auth.github]&lt;/code&gt; section of the Grafana configuration file:&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Field&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;client_id&lt;/code&gt;, &lt;code&gt;client_secret&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;These values must match the client ID and client secret from your GitHub OAuth app.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;enabled&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Enables GitHub authentication. Set this value to &lt;code&gt;true&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;Review the list of other GitHub &lt;a href=&#34;#configuration-options&#34;&gt;configuration options&lt;/a&gt; and complete them, as necessary.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&#34;#configure-role-mapping&#34;&gt;Configure role mapping&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Optional: &lt;a href=&#34;#configure-team-synchronization&#34;&gt;Configure team synchronization&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Restart Grafana.&lt;/p&gt;
&lt;p&gt;You should now see a GitHub login button on the login page and be able to log in or sign up with your GitHub accounts.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;configure-role-mapping&#34;&gt;Configure role mapping&lt;/h3&gt;
&lt;p&gt;Unless &lt;code&gt;skip_org_role_sync&lt;/code&gt; option is enabled, the user&amp;rsquo;s role will be set to the role retrieved from GitHub upon user login.&lt;/p&gt;
&lt;p&gt;The user&amp;rsquo;s role is retrieved using a &lt;a href=&#34;http://jmespath.org/examples.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;JMESPath&lt;/a&gt; expression from the &lt;code&gt;role_attribute_path&lt;/code&gt; configuration option.
To map the server administrator role, use the &lt;code&gt;allow_assign_grafana_admin&lt;/code&gt; configuration option.
Refer to &lt;a href=&#34;#configuration-options&#34;&gt;configuration options&lt;/a&gt; for more information.&lt;/p&gt;
&lt;p&gt;If no valid role is found, the user is assigned the role specified by &lt;a href=&#34;../../../configure-grafana/#auto_assign_org_role&#34;&gt;the &lt;code&gt;auto_assign_org_role&lt;/code&gt; option&lt;/a&gt;.
You can disable this default role assignment by setting &lt;code&gt;role_attribute_strict = true&lt;/code&gt;.
This setting denies user access if no role or an invalid role is returned.&lt;/p&gt;
&lt;p&gt;To ease configuration of a proper JMESPath expression, go to &lt;a href=&#34;http://jmespath.org/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;JMESPath&lt;/a&gt; to test and evaluate expressions with custom payloads.&lt;/p&gt;
&lt;h4 id=&#34;role-mapping-examples&#34;&gt;Role mapping examples&lt;/h4&gt;
&lt;p&gt;This section includes examples of JMESPath expressions used for role mapping.&lt;/p&gt;
&lt;h5 id=&#34;map-roles-using-github-user-information&#34;&gt;Map roles using GitHub user information&lt;/h5&gt;
&lt;p&gt;In this example, the user with login &lt;code&gt;octocat&lt;/code&gt; has been granted the &lt;code&gt;Admin&lt;/code&gt; role.
All other users are granted the &lt;code&gt;Viewer&lt;/code&gt; role.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;role_attribute_path = [login==&amp;#39;octocat&amp;#39;][0] &amp;amp;&amp;amp; &amp;#39;Admin&amp;#39; || &amp;#39;Viewer&amp;#39;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h5 id=&#34;map-roles-using-github-teams&#34;&gt;Map roles using GitHub teams&lt;/h5&gt;
&lt;p&gt;In this example, the user from GitHub team &lt;code&gt;my-github-team&lt;/code&gt; has been granted the &lt;code&gt;Editor&lt;/code&gt; role.
All other users are granted the &lt;code&gt;Viewer&lt;/code&gt; role.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;role_attribute_path = contains(groups[*], &amp;#39;@my-github-organization/my-github-team&amp;#39;) &amp;amp;&amp;amp; &amp;#39;Editor&amp;#39; || &amp;#39;Viewer&amp;#39;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;map-server-administrator-role&#34;&gt;Map server administrator role&lt;/h4&gt;
&lt;p&gt;In this example, the user with login &lt;code&gt;octocat&lt;/code&gt; has been granted the &lt;code&gt;Admin&lt;/code&gt; organization role as well as the Grafana server admin role.
All other users are granted the &lt;code&gt;Viewer&lt;/code&gt; role.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;role_attribute_path = [login==&amp;#39;octocat&amp;#39;][0] &amp;amp;&amp;amp; &amp;#39;GrafanaAdmin&amp;#39; || &amp;#39;Viewer&amp;#39;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h5 id=&#34;map-one-role-to-all-users&#34;&gt;Map one role to all users&lt;/h5&gt;
&lt;p&gt;In this example, all users will be assigned &lt;code&gt;Viewer&lt;/code&gt; role regardless of the user information received from the identity provider.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;ini&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-ini&#34;&gt;role_attribute_path = &amp;#34;&amp;#39;Viewer&amp;#39;&amp;#34;
skip_org_role_sync = false&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;example-of-github-configuration-in-grafana&#34;&gt;Example of GitHub configuration in Grafana&lt;/h3&gt;
&lt;p&gt;This section includes an example of GitHub configuration in the Grafana configuration file.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;[auth.github]
enabled = true
client_id = YOUR_GITHUB_APP_CLIENT_ID
client_secret = YOUR_GITHUB_APP_CLIENT_SECRET
scopes = user:email,read:org
auth_url = https://github.com/login/oauth/authorize
token_url = https://github.com/login/oauth/access_token
api_url = https://api.github.com/user
allow_sign_up = true
auto_login = false
team_ids = 150,300
allowed_organizations = [&amp;#34;My Organization&amp;#34;, &amp;#34;Octocats&amp;#34;]
allowed_domains = mycompany.com mycompany.org
role_attribute_path = [login==&amp;#39;octocat&amp;#39;][0] &amp;amp;&amp;amp; &amp;#39;GrafanaAdmin&amp;#39; || &amp;#39;Viewer&amp;#39;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;configure-team-synchronization&#34;&gt;Configure team synchronization&lt;/h2&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Available in &lt;a href=&#34;../../../../introduction/grafana-enterprise/&#34;&gt;Grafana Enterprise&lt;/a&gt; and Grafana Cloud.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;By using Team Sync, you can map teams from your GitHub organization to teams within Grafana. This will automatically assign users to the appropriate teams.
Teams for each user are synchronized when the user logs in.&lt;/p&gt;
&lt;p&gt;GitHub teams can be referenced in two ways:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;https://github.com/orgs/&amp;lt;org&amp;gt;/teams/&amp;lt;slug&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;@&amp;lt;org&amp;gt;/&amp;lt;slug&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Examples: &lt;code&gt;https://github.com/orgs/grafana/teams/developers&lt;/code&gt; or &lt;code&gt;@grafana/developers&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;To learn more about Team Sync, refer to &lt;a href=&#34;../../configure-team-sync/&#34;&gt;Configure team sync&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;configuration-options&#34;&gt;Configuration options&lt;/h2&gt;
&lt;p&gt;The table below describes all GitHub OAuth configuration options. Like any other Grafana configuration, you can apply these options as environment variables.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Setting&lt;/th&gt;
              &lt;th&gt;Required&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Default&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;enabled&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Whether GitHub OAuth authentication is allowed.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;false&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;name&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Name used to refer to the GitHub authentication in the Grafana user interface.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;GitHub&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;icon&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Icon used for GitHub authentication in the Grafana user interface.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;github&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;client_id&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Yes&lt;/td&gt;
              &lt;td&gt;Client ID provided by your GitHub OAuth app.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;client_secret&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Yes&lt;/td&gt;
              &lt;td&gt;Client secret provided by your GitHub OAuth app.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;auth_url&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Yes&lt;/td&gt;
              &lt;td&gt;Authorization endpoint of your GitHub OAuth provider.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;https://github.com/login/oauth/authorize&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;token_url&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Yes&lt;/td&gt;
              &lt;td&gt;Endpoint used to obtain GitHub OAuth access token.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;https://github.com/login/oauth/access_token&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;api_url&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Yes&lt;/td&gt;
              &lt;td&gt;Endpoint used to obtain GitHub user information compatible with &lt;a href=&#34;https://connect2id.com/products/server/docs/api/userinfo&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;OpenID UserInfo&lt;/a&gt;.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;https://api.github.com/user&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;scopes&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;List of comma- or space-separated GitHub OAuth scopes.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;user:email,read:org&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;allow_sign_up&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Whether to allow new Grafana user creation through GitHub login. If set to &lt;code&gt;false&lt;/code&gt;, then only existing Grafana users can log in with GitHub OAuth.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;true&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;auto_login&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Set to &lt;code&gt;true&lt;/code&gt; to enable users to bypass the login screen and automatically log in. This setting is ignored if you configure multiple auth providers to use auto-login.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;false&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;role_attribute_path&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;http://jmespath.org/examples.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;JMESPath&lt;/a&gt; expression to use for Grafana role lookup. Grafana will first evaluate the expression using the user information obtained from the UserInfo endpoint. If no role is found, Grafana creates a JSON data with &lt;code&gt;groups&lt;/code&gt; key that maps to GitHub teams obtained from GitHub&amp;rsquo;s &lt;a href=&#34;https://docs.github.com/en/rest/teams/teams#list-teams-for-the-authenticated-user&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;&lt;code&gt;/api/user/teams&lt;/code&gt;&lt;/a&gt; endpoint, and evaluates the expression using this data. The result of the evaluation should be a valid Grafana role (&lt;code&gt;Viewer&lt;/code&gt;, &lt;code&gt;Editor&lt;/code&gt;, &lt;code&gt;Admin&lt;/code&gt; or &lt;code&gt;GrafanaAdmin&lt;/code&gt;). For more information on user role mapping, refer to &lt;a href=&#34;#configure-role-mapping&#34;&gt;Configure role mapping&lt;/a&gt;.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;role_attribute_strict&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Set to &lt;code&gt;true&lt;/code&gt; to deny user login if the Grafana role cannot be extracted using &lt;code&gt;role_attribute_path&lt;/code&gt;. For more information on user role mapping, refer to &lt;a href=&#34;#configure-role-mapping&#34;&gt;Configure role mapping&lt;/a&gt;.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;false&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;allow_assign_grafana_admin&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Set to &lt;code&gt;true&lt;/code&gt; to enable automatic sync of the Grafana server administrator role. If this option is set to &lt;code&gt;true&lt;/code&gt; and the result of evaluating &lt;code&gt;role_attribute_path&lt;/code&gt; for a user is &lt;code&gt;GrafanaAdmin&lt;/code&gt;, Grafana grants the user the server administrator privileges and organization administrator role. If this option is set to &lt;code&gt;false&lt;/code&gt; and the result of evaluating &lt;code&gt;role_attribute_path&lt;/code&gt; for a user is &lt;code&gt;GrafanaAdmin&lt;/code&gt;, Grafana grants the user only organization administrator role. For more information on user role mapping, refer to &lt;a href=&#34;#configure-role-mapping&#34;&gt;Configure role mapping&lt;/a&gt;.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;false&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;skip_org_role_sync&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Set to &lt;code&gt;true&lt;/code&gt; to stop automatically syncing user roles.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;false&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;allowed_organizations&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;List of comma- or space-separated organizations. User must be a member of at least one organization to log in.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;allowed_domains&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;List of comma- or space-separated domains. User must belong to at least one domain to log in.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;team_ids&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Integer list of team IDs. If set, user has to be a member of one of the given teams to log in.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;tls_skip_verify_insecure&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;If set to &lt;code&gt;true&lt;/code&gt;, the client accepts any certificate presented by the server and any host name in that certificate. &lt;em&gt;You should only use this for testing&lt;/em&gt;, because this mode leaves SSL/TLS susceptible to man-in-the-middle attacks.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;false&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;tls_client_cert&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;The path to the certificate.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;tls_client_key&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;The path to the key.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;tls_client_ca&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;The path to the trusted certificate authority list.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;]]></content><description>&lt;h1 id="configure-github-oauth2-authentication">Configure GitHub OAuth2 authentication&lt;/h1>
&lt;div data-shared="auth/intro.md">
&lt;p>There are numerous authentication methods available in Grafana to verify user identity. The authentication configuration dictates which users can access Grafana and the methods they can use for logging in.
You can also configure Grafana to automatically update users&amp;rsquo; roles and team memberships in Grafana based on the information returned by the auth provider integration.&lt;/p></description></item><item><title>Configure GitLab OAuth2 authentication</title><link>https://grafana.com/docs/grafana/v10.4/setup-grafana/configure-security/configure-authentication/gitlab/</link><pubDate>Fri, 07 Mar 2025 09:39:42 +0000</pubDate><guid>https://grafana.com/docs/grafana/v10.4/setup-grafana/configure-security/configure-authentication/gitlab/</guid><content><![CDATA[&lt;h1 id=&#34;configure-gitlab-oauth2-authentication&#34;&gt;Configure GitLab OAuth2 authentication&lt;/h1&gt;


&lt;div data-shared=&#34;auth/intro.md&#34;&gt;
            &lt;p&gt;There are numerous authentication methods available in Grafana to verify user identity. The authentication configuration dictates which users can access Grafana and the methods they can use for logging in.
You can also configure Grafana to automatically update users&amp;rsquo; roles and team memberships in Grafana based on the information returned by the auth provider integration.&lt;/p&gt;
&lt;p&gt;When deciding on an authentication method, it&amp;rsquo;s important to take into account your current identity and access management system as well as the specific authentication and authorization features you require.
For a complete list of the available authentication options and the features they support, refer to 
    &lt;a href=&#34;/docs/grafana/v10.4/setup-grafana/configure-security/configure-authentication/&#34;&gt;Configure authentication&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;

        
&lt;p&gt;This topic describes how to configure GitLab OAuth2 authentication.&lt;/p&gt;
&lt;h2 id=&#34;before-you-begin&#34;&gt;Before you begin&lt;/h2&gt;
&lt;p&gt;Ensure you know how to create a GitLab OAuth application. Consult GitLab&amp;rsquo;s documentation on &lt;a href=&#34;https://docs.gitlab.com/ee/integration/oauth_provider.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;creating a GitLab OAuth application&lt;/a&gt; for more information.&lt;/p&gt;
&lt;h2 id=&#34;configure-gitlab-authentication-client-using-the-grafana-ui&#34;&gt;Configure GitLab authentication client using the Grafana UI&lt;/h2&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Available in Public Preview in Grafana 10.4 behind the &lt;code&gt;ssoSettingsApi&lt;/code&gt; feature toggle.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;As a Grafana Admin, you can configure GitLab OAuth2 client from within Grafana using the GitLab UI. To do this, navigate to &lt;strong&gt;Administration &amp;gt; Authentication &amp;gt; GitLab&lt;/strong&gt; page and fill in the form. If you have a current configuration in the Grafana configuration file then the form will be pre-populated with those values otherwise the form will contain default values.&lt;/p&gt;
&lt;p&gt;After you have filled in the form, click &lt;strong&gt;Save&lt;/strong&gt; to save the configuration. If the save was successful, Grafana will apply the new configurations.&lt;/p&gt;
&lt;p&gt;If you need to reset changes you made in the UI back to the default values, click &lt;strong&gt;Reset&lt;/strong&gt;. After you have reset the changes, Grafana will apply the configuration from the Grafana configuration file (if there is any configuration) or the default values.&lt;/p&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;If you run Grafana in high availability mode, configuration changes may not get applied to all Grafana instances immediately. You may need to wait a few minutes for the configuration to propagate to all Grafana instances.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;Refer to &lt;a href=&#34;#configuration-options&#34;&gt;configuration options&lt;/a&gt; for more information.&lt;/p&gt;
&lt;h2 id=&#34;configure-gitlab-authentication-client-using-the-terraform-provider&#34;&gt;Configure GitLab authentication client using the Terraform provider&lt;/h2&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Available in Public Preview in Grafana 10.4 behind the &lt;code&gt;ssoSettingsApi&lt;/code&gt; feature toggle. Supported in the Terraform provider since v2.12.0.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;


&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;terraform&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-terraform&#34;&gt;resource &amp;#34;grafana_sso_settings&amp;#34; &amp;#34;gitlab_sso_settings&amp;#34; {
  provider_name = &amp;#34;gitlab&amp;#34;
  oauth2_settings {
    name                  = &amp;#34;Gitlab&amp;#34;
    client_id             = &amp;#34;YOUR_GITLAB_APPLICATION_ID&amp;#34;
    client_secret         = &amp;#34;YOUR_GITLAB_APPLICATION_SECRET&amp;#34;
    allow_sign_up         = true
    auto_login            = false
    scopes                = &amp;#34;openid email profile&amp;#34;
    allowed_domains       = &amp;#34;mycompany.com mycompany.org&amp;#34;
    role_attribute_path   = &amp;#34;contains(groups[*], &amp;#39;example-group&amp;#39;) &amp;amp;&amp;amp; &amp;#39;Editor&amp;#39; || &amp;#39;Viewer&amp;#39;&amp;#34;
    role_attribute_strict = false
    allowed_groups        = &amp;#34;[\&amp;#34;admins\&amp;#34;, \&amp;#34;software engineers\&amp;#34;, \&amp;#34;developers/frontend\&amp;#34;]&amp;#34;
    use_pkce              = true
    use_refresh_token     = true
  }
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Go to &lt;a href=&#34;https://registry.terraform.io/providers/grafana/grafana/latest/docs/resources/sso_settings&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Terraform Registry&lt;/a&gt; for a complete reference on using the &lt;code&gt;grafana_sso_settings&lt;/code&gt; resource.&lt;/p&gt;
&lt;h2 id=&#34;configure-gitlab-authentication-client-using-the-grafana-configuration-file&#34;&gt;Configure GitLab authentication client using the Grafana configuration file&lt;/h2&gt;
&lt;p&gt;Ensure that you have access to the &lt;a href=&#34;../../../configure-grafana/#configuration-file-location&#34;&gt;Grafana configuration file&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;steps&#34;&gt;Steps&lt;/h3&gt;
&lt;p&gt;To configure GitLab authentication with Grafana, follow these steps:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Create an OAuth application in GitLab.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Set the redirect URI to &lt;code&gt;http://&amp;lt;my_grafana_server_name_or_ip&amp;gt;:&amp;lt;grafana_server_port&amp;gt;/login/gitlab&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Ensure that the Redirect URI is the complete HTTP address that you use to access Grafana via your browser, but with the appended path of &lt;code&gt;/login/gitlab&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;For the Redirect URI to be correct, it might be necessary to set the &lt;code&gt;root_url&lt;/code&gt; option in the &lt;code&gt;[server]&lt;/code&gt;section of the Grafana configuration file. For example, if you are serving Grafana behind a proxy.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Set the OAuth2 scopes to &lt;code&gt;openid&lt;/code&gt;, &lt;code&gt;email&lt;/code&gt; and &lt;code&gt;profile&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Refer to the following table to update field values located in the &lt;code&gt;[auth.gitlab]&lt;/code&gt; section of the Grafana configuration file:&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Field&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;client_id&lt;/code&gt;, &lt;code&gt;client_secret&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;These values must match the client ID and client secret from your GitLab OAuth2 application.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;enabled&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Enables GitLab authentication. Set this value to &lt;code&gt;true&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;Review the list of other GitLab &lt;a href=&#34;#configuration-options&#34;&gt;configuration options&lt;/a&gt; and complete them, as necessary.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Optional: &lt;a href=&#34;#configure-a-refresh-token&#34;&gt;Configure a refresh token&lt;/a&gt;:&lt;/p&gt;
&lt;p&gt;a. Set &lt;code&gt;use_refresh_token&lt;/code&gt; to &lt;code&gt;true&lt;/code&gt; in &lt;code&gt;[auth.gitlab]&lt;/code&gt; section in Grafana configuration file.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&#34;#configure-role-mapping&#34;&gt;Configure role mapping&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Optional: &lt;a href=&#34;#configure-team-synchronization&#34;&gt;Configure team synchronization&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Restart Grafana.&lt;/p&gt;
&lt;p&gt;You should now see a GitLab login button on the login page and be able to log in or sign up with your GitLab accounts.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;configure-a-refresh-token&#34;&gt;Configure a refresh token&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;Available in Grafana v9.3 and later versions.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;When a user logs in using an OAuth provider, Grafana verifies that the access token has not expired. When an access token expires, Grafana uses the provided refresh token (if any exists) to obtain a new access token.&lt;/p&gt;
&lt;p&gt;Grafana uses a refresh token to obtain a new access token without requiring the user to log in again. If a refresh token doesn&amp;rsquo;t exist, Grafana logs the user out of the system after the access token has expired.&lt;/p&gt;
&lt;p&gt;By default, GitLab provides a refresh token.&lt;/p&gt;
&lt;p&gt;Refresh token fetching and access token expiration check is enabled by default for the GitLab provider since Grafana v10.1.0. If you would like to disable access token expiration check then set the &lt;code&gt;use_refresh_token&lt;/code&gt; configuration value to &lt;code&gt;false&lt;/code&gt;.&lt;/p&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;The &lt;code&gt;accessTokenExpirationCheck&lt;/code&gt; feature toggle has been removed in Grafana v10.3.0 and the &lt;code&gt;use_refresh_token&lt;/code&gt; configuration value will be used instead for configuring refresh token fetching and access token expiration check.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h3 id=&#34;configure-allowed-groups&#34;&gt;Configure allowed groups&lt;/h3&gt;
&lt;p&gt;To limit access to authenticated users that are members of one or more &lt;a href=&#34;https://docs.gitlab.com/ce/user/group/index.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;GitLab
groups&lt;/a&gt;, set &lt;code&gt;allowed_groups&lt;/code&gt;
to a comma or space-separated list of groups.&lt;/p&gt;
&lt;p&gt;GitLab&amp;rsquo;s groups are referenced by the group name. For example, &lt;code&gt;developers&lt;/code&gt;. To reference a subgroup &lt;code&gt;frontend&lt;/code&gt;, use &lt;code&gt;developers/frontend&lt;/code&gt;.
Note that in GitLab, the group or subgroup name does not always match its display name, especially if the display name contains spaces or special characters.
Make sure you always use the group or subgroup name as it appears in the URL of the group or subgroup.&lt;/p&gt;
&lt;h3 id=&#34;configure-role-mapping&#34;&gt;Configure role mapping&lt;/h3&gt;
&lt;p&gt;Unless &lt;code&gt;skip_org_role_sync&lt;/code&gt; option is enabled, the user&amp;rsquo;s role will be set to the role retrieved from GitLab upon user login.&lt;/p&gt;
&lt;p&gt;The user&amp;rsquo;s role is retrieved using a &lt;a href=&#34;http://jmespath.org/examples.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;JMESPath&lt;/a&gt; expression from the &lt;code&gt;role_attribute_path&lt;/code&gt; configuration option.
To map the server administrator role, use the &lt;code&gt;allow_assign_grafana_admin&lt;/code&gt; configuration option.
Refer to &lt;a href=&#34;#configuration-options&#34;&gt;configuration options&lt;/a&gt; for more information.&lt;/p&gt;
&lt;p&gt;If no valid role is found, the user is assigned the role specified by &lt;a href=&#34;../../../configure-grafana/#auto_assign_org_role&#34;&gt;the &lt;code&gt;auto_assign_org_role&lt;/code&gt; option&lt;/a&gt;.
You can disable this default role assignment by setting &lt;code&gt;role_attribute_strict = true&lt;/code&gt;.
This setting denies user access if no role or an invalid role is returned.&lt;/p&gt;
&lt;p&gt;To ease configuration of a proper JMESPath expression, go to &lt;a href=&#34;http://jmespath.org/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;JMESPath&lt;/a&gt; to test and evaluate expressions with custom payloads.&lt;/p&gt;
&lt;h3 id=&#34;role-mapping-examples&#34;&gt;Role mapping examples&lt;/h3&gt;
&lt;p&gt;This section includes examples of JMESPath expressions used for role mapping.&lt;/p&gt;
&lt;h4 id=&#34;map-roles-using-user-information-from-oauth-token&#34;&gt;Map roles using user information from OAuth token&lt;/h4&gt;
&lt;p&gt;In this example, the user with email &lt;code&gt;admin@company.com&lt;/code&gt; has been granted the &lt;code&gt;Admin&lt;/code&gt; role.
All other users are granted the &lt;code&gt;Viewer&lt;/code&gt; role.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;ini&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-ini&#34;&gt;role_attribute_path = email==&amp;#39;admin@company.com&amp;#39; &amp;amp;&amp;amp; &amp;#39;Admin&amp;#39; || &amp;#39;Viewer&amp;#39;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;map-roles-using-groups&#34;&gt;Map roles using groups&lt;/h4&gt;
&lt;p&gt;In this example, the user from GitLab group &amp;rsquo;example-group&amp;rsquo; have been granted the &lt;code&gt;Editor&lt;/code&gt; role.
All other users are granted the &lt;code&gt;Viewer&lt;/code&gt; role.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;ini&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-ini&#34;&gt;role_attribute_path = contains(groups[*], &amp;#39;example-group&amp;#39;) &amp;amp;&amp;amp; &amp;#39;Editor&amp;#39; || &amp;#39;Viewer&amp;#39;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;map-server-administrator-role&#34;&gt;Map server administrator role&lt;/h4&gt;
&lt;p&gt;In this example, the user with email &lt;code&gt;admin@company.com&lt;/code&gt; has been granted the &lt;code&gt;Admin&lt;/code&gt; organization role as well as the Grafana server admin role.
All other users are granted the &lt;code&gt;Viewer&lt;/code&gt; role.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;role_attribute_path = email==&amp;#39;admin@company.com&amp;#39; &amp;amp;&amp;amp; &amp;#39;GrafanaAdmin&amp;#39; || &amp;#39;Viewer&amp;#39;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h4 id=&#34;map-one-role-to-all-users&#34;&gt;Map one role to all users&lt;/h4&gt;
&lt;p&gt;In this example, all users will be assigned &lt;code&gt;Viewer&lt;/code&gt; role regardless of the user information received from the identity provider.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;ini&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-ini&#34;&gt;role_attribute_path = &amp;#34;&amp;#39;Viewer&amp;#39;&amp;#34;
skip_org_role_sync = false&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;example-of-gitlab-configuration-in-grafana&#34;&gt;Example of GitLab configuration in Grafana&lt;/h3&gt;
&lt;p&gt;This section includes an example of GitLab configuration in the Grafana configuration file.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;[auth.gitlab]
enabled = true
allow_sign_up = true
auto_login = false
client_id = YOUR_GITLAB_APPLICATION_ID
client_secret = YOUR_GITLAB_APPLICATION_SECRET
scopes = openid email profile
auth_url = https://gitlab.com/oauth/authorize
token_url = https://gitlab.com/oauth/token
api_url = https://gitlab.com/api/v4
role_attribute_path = contains(groups[*], &amp;#39;example-group&amp;#39;) &amp;amp;&amp;amp; &amp;#39;Editor&amp;#39; || &amp;#39;Viewer&amp;#39;
role_attribute_strict = false
allow_assign_grafana_admin = false
allowed_groups = [&amp;#34;admins&amp;#34;, &amp;#34;software engineers&amp;#34;, &amp;#34;developers/frontend&amp;#34;]
allowed_domains = mycompany.com mycompany.org
tls_skip_verify_insecure = false
use_pkce = true
use_refresh_token = true&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;configure-team-synchronization&#34;&gt;Configure team synchronization&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Available in &lt;a href=&#34;../../../../introduction/grafana-enterprise/&#34;&gt;Grafana Enterprise&lt;/a&gt; and &lt;a href=&#34;/docs/grafana-cloud/&#34;&gt;Grafana Cloud&lt;/a&gt;.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;By using Team Sync, you can map GitLab groups to teams within Grafana. This will automatically assign users to the appropriate teams.
Teams for each user are synchronized when the user logs in.&lt;/p&gt;
&lt;p&gt;GitLab groups are referenced by the group name. For example, &lt;code&gt;developers&lt;/code&gt;. To reference a subgroup &lt;code&gt;frontend&lt;/code&gt;, use &lt;code&gt;developers/frontend&lt;/code&gt;.
Note that in GitLab, the group or subgroup name does not always match its display name, especially if the display name contains spaces or special characters.
Make sure you always use the group or subgroup name as it appears in the URL of the group or subgroup.&lt;/p&gt;
&lt;p&gt;To learn more about Team Sync, refer to &lt;a href=&#34;../../configure-team-sync/&#34;&gt;Configure team sync&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;configuration-options&#34;&gt;Configuration options&lt;/h2&gt;
&lt;p&gt;The table below describes all GitLab OAuth configuration options. Like any other Grafana configuration, you can apply these options as environment variables.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Setting&lt;/th&gt;
              &lt;th&gt;Required&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Default&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;enabled&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Yes&lt;/td&gt;
              &lt;td&gt;Whether GitLab OAuth authentication is allowed.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;false&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;client_id&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Yes&lt;/td&gt;
              &lt;td&gt;Client ID provided by your GitLab OAuth app.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;client_secret&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Yes&lt;/td&gt;
              &lt;td&gt;Client secret provided by your GitLab OAuth app.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;auth_url&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Yes&lt;/td&gt;
              &lt;td&gt;Authorization endpoint of your GitLab OAuth provider. If you use your own instance of GitLab instead of gitlab.com, adjust &lt;code&gt;auth_url&lt;/code&gt; by replacing the &lt;code&gt;gitlab.com&lt;/code&gt; hostname with your own.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;https://gitlab.com/oauth/authorize&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;token_url&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Yes&lt;/td&gt;
              &lt;td&gt;Endpoint used to obtain GitLab OAuth access token. If you use your own instance of GitLab instead of gitlab.com, adjust &lt;code&gt;token_url&lt;/code&gt; by replacing the &lt;code&gt;gitlab.com&lt;/code&gt; hostname with your own.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;https://gitlab.com/oauth/token&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;api_url&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Grafana uses &lt;code&gt;&amp;lt;api_url&amp;gt;/user&lt;/code&gt; endpoint to obtain GitLab user information compatible with &lt;a href=&#34;https://connect2id.com/products/server/docs/api/userinfo&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;OpenID UserInfo&lt;/a&gt;.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;https://gitlab.com/api/v4&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;name&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Name used to refer to the GitLab authentication in the Grafana user interface.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;GitLab&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;icon&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Icon used for GitLab authentication in the Grafana user interface.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;gitlab&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;scopes&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;List of comma or space-separated GitLab OAuth scopes.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;openid email profile&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;allow_sign_up&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Whether to allow new Grafana user creation through GitLab login. If set to &lt;code&gt;false&lt;/code&gt;, then only existing Grafana users can log in with GitLab OAuth.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;true&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;auto_login&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Set to &lt;code&gt;true&lt;/code&gt; to enable users to bypass the login screen and automatically log in. This setting is ignored if you configure multiple auth providers to use auto-login.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;false&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;role_attribute_path&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;http://jmespath.org/examples.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;JMESPath&lt;/a&gt; expression to use for Grafana role lookup. Grafana will first evaluate the expression using the GitLab OAuth token. If no role is found, Grafana creates a JSON data with &lt;code&gt;groups&lt;/code&gt; key that maps to groups obtained from GitLab&amp;rsquo;s &lt;code&gt;/oauth/userinfo&lt;/code&gt; endpoint, and evaluates the expression using this data. Finally, if a valid role is still not found, the expression is evaluated against the user information retrieved from &lt;code&gt;api_url/users&lt;/code&gt; endpoint and groups retrieved from &lt;code&gt;api_url/groups&lt;/code&gt; endpoint. The result of the evaluation should be a valid Grafana role (&lt;code&gt;Viewer&lt;/code&gt;, &lt;code&gt;Editor&lt;/code&gt;, &lt;code&gt;Admin&lt;/code&gt; or &lt;code&gt;GrafanaAdmin&lt;/code&gt;). For more information on user role mapping, refer to &lt;a href=&#34;#configure-role-mapping&#34;&gt;Configure role mapping&lt;/a&gt;.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;role_attribute_strict&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Set to &lt;code&gt;true&lt;/code&gt; to deny user login if the Grafana role cannot be extracted using &lt;code&gt;role_attribute_path&lt;/code&gt;. For more information on user role mapping, refer to &lt;a href=&#34;#configure-role-mapping&#34;&gt;Configure role mapping&lt;/a&gt;.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;false&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;allow_assign_grafana_admin&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Set to &lt;code&gt;true&lt;/code&gt; to enable automatic sync of the Grafana server administrator role. If this option is set to &lt;code&gt;true&lt;/code&gt; and the result of evaluating &lt;code&gt;role_attribute_path&lt;/code&gt; for a user is &lt;code&gt;GrafanaAdmin&lt;/code&gt;, Grafana grants the user the server administrator privileges and organization administrator role. If this option is set to &lt;code&gt;false&lt;/code&gt; and the result of evaluating &lt;code&gt;role_attribute_path&lt;/code&gt; for a user is &lt;code&gt;GrafanaAdmin&lt;/code&gt;, Grafana grants the user only organization administrator role. For more information on user role mapping, refer to &lt;a href=&#34;#configure-role-mapping&#34;&gt;Configure role mapping&lt;/a&gt;.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;false&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;skip_org_role_sync&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Set to &lt;code&gt;true&lt;/code&gt; to stop automatically syncing user roles.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;false&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;allowed_domains&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;List of comma or space-separated domains. User must belong to at least one domain to log in.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;allowed_groups&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;List of comma or space-separated groups. The user should be a member of at least one group to log in.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;tls_skip_verify_insecure&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;If set to &lt;code&gt;true&lt;/code&gt;, the client accepts any certificate presented by the server and any host name in that certificate. &lt;em&gt;You should only use this for testing&lt;/em&gt;, because this mode leaves SSL/TLS susceptible to man-in-the-middle attacks.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;false&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;tls_client_cert&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;The path to the certificate.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;tls_client_key&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;The path to the key.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;tls_client_ca&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;The path to the trusted certificate authority list.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;use_pkce&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Set to &lt;code&gt;true&lt;/code&gt; to use &lt;a href=&#34;https://datatracker.ietf.org/doc/html/rfc7636&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Proof Key for Code Exchange (PKCE)&lt;/a&gt;. Grafana uses the SHA256 based &lt;code&gt;S256&lt;/code&gt; challenge method and a 128 bytes (base64url encoded) code verifier.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;true&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;use_refresh_token&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Set to &lt;code&gt;true&lt;/code&gt; to use refresh token and check access token expiration. The &lt;code&gt;accessTokenExpirationCheck&lt;/code&gt; feature toggle should also be enabled to use refresh token.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;true&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;]]></content><description>&lt;h1 id="configure-gitlab-oauth2-authentication">Configure GitLab OAuth2 authentication&lt;/h1>
&lt;div data-shared="auth/intro.md">
&lt;p>There are numerous authentication methods available in Grafana to verify user identity. The authentication configuration dictates which users can access Grafana and the methods they can use for logging in.
You can also configure Grafana to automatically update users&amp;rsquo; roles and team memberships in Grafana based on the information returned by the auth provider integration.&lt;/p></description></item><item><title>Configure Google OAuth2 authentication</title><link>https://grafana.com/docs/grafana/v10.4/setup-grafana/configure-security/configure-authentication/google/</link><pubDate>Fri, 07 Mar 2025 09:39:42 +0000</pubDate><guid>https://grafana.com/docs/grafana/v10.4/setup-grafana/configure-security/configure-authentication/google/</guid><content><![CDATA[&lt;h1 id=&#34;configure-google-oauth2-authentication&#34;&gt;Configure Google OAuth2 authentication&lt;/h1&gt;
&lt;p&gt;To enable Google OAuth2 you must register your application with Google. Google will generate a client ID and secret key for you to use.&lt;/p&gt;
&lt;h2 id=&#34;create-google-oauth-keys&#34;&gt;Create Google OAuth keys&lt;/h2&gt;
&lt;p&gt;First, you need to create a Google OAuth Client:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Go to &lt;a href=&#34;https://console.developers.google.com/apis/credentials&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;https://console.developers.google.com/apis/credentials&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Create Credentials&lt;/strong&gt;, then click &lt;strong&gt;OAuth Client ID&lt;/strong&gt; in the drop-down menu&lt;/li&gt;
&lt;li&gt;Enter the following:
&lt;ul&gt;
&lt;li&gt;Application Type: Web Application&lt;/li&gt;
&lt;li&gt;Name: Grafana&lt;/li&gt;
&lt;li&gt;Authorized JavaScript Origins: &lt;a href=&#34;https://grafana.mycompany.com&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;https://grafana.mycompany.com&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Authorized Redirect URLs: &lt;a href=&#34;https://grafana.mycompany.com/login/google&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;https://grafana.mycompany.com/login/google&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Replace &lt;a href=&#34;https://grafana.mycompany.com&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;https://grafana.mycompany.com&lt;/a&gt; with the URL of your Grafana instance.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Click Create&lt;/li&gt;
&lt;li&gt;Copy the Client ID and Client Secret from the &amp;lsquo;OAuth Client&amp;rsquo; modal&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;configure-google-authentication-client-using-the-grafana-ui&#34;&gt;Configure Google authentication client using the Grafana UI&lt;/h2&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Available in Public Preview in Grafana 10.4 behind the &lt;code&gt;ssoSettingsApi&lt;/code&gt; feature toggle.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;As a Grafana Admin, you can configure Google OAuth2 client from within Grafana using the Google UI. To do this, navigate to &lt;strong&gt;Administration &amp;gt; Authentication &amp;gt; Google&lt;/strong&gt; page and fill in the form. If you have a current configuration in the Grafana configuration file then the form will be pre-populated with those values otherwise the form will contain default values.&lt;/p&gt;
&lt;p&gt;After you have filled in the form, click &lt;strong&gt;Save&lt;/strong&gt;. If the save was successful, Grafana will apply the new configurations.&lt;/p&gt;
&lt;p&gt;If you need to reset changes made in the UI back to the default values, click &lt;strong&gt;Reset&lt;/strong&gt;. After you have reset the changes, Grafana will apply the configuration from the Grafana configuration file (if there is any configuration) or the default values.&lt;/p&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;If you run Grafana in high availability mode, configuration changes may not get applied to all Grafana instances immediately. You may need to wait a few minutes for the configuration to propagate to all Grafana instances.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h2 id=&#34;configure-google-authentication-client-using-the-terraform-provider&#34;&gt;Configure Google authentication client using the Terraform provider&lt;/h2&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Available in Public Preview in Grafana 10.4 behind the &lt;code&gt;ssoSettingsApi&lt;/code&gt; feature toggle. Supported in the Terraform provider since v2.12.0.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;


&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;terraform&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-terraform&#34;&gt;resource &amp;#34;grafana_sso_settings&amp;#34; &amp;#34;google_sso_settings&amp;#34; {
  provider_name = &amp;#34;google&amp;#34;
  oauth2_settings {
    name            = &amp;#34;Google&amp;#34;
    client_id       = &amp;#34;CLIENT_ID&amp;#34;
    client_secret   = &amp;#34;CLIENT_SECRET&amp;#34;
    allow_sign_up   = true
    auto_login      = false
    scopes          = &amp;#34;openid email profile&amp;#34;
    allowed_domains = &amp;#34;mycompany.com mycompany.org&amp;#34;
    hosted_domain   = &amp;#34;mycompany.com&amp;#34;
    use_pkce        = true
  }
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Go to &lt;a href=&#34;https://registry.terraform.io/providers/grafana/grafana/latest/docs/resources/sso_settings&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Terraform Registry&lt;/a&gt; for a complete reference on using the &lt;code&gt;grafana_sso_settings&lt;/code&gt; resource.&lt;/p&gt;
&lt;h2 id=&#34;configure-google-authentication-client-using-the-grafana-configuration-file&#34;&gt;Configure Google authentication client using the Grafana configuration file&lt;/h2&gt;
&lt;p&gt;Ensure that you have access to the &lt;a href=&#34;../../../configure-grafana/#configuration-file-location&#34;&gt;Grafana configuration file&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;enable-google-oauth-in-grafana&#34;&gt;Enable Google OAuth in Grafana&lt;/h3&gt;
&lt;p&gt;Specify the Client ID and Secret in the &lt;a href=&#34;../../../configure-grafana/#configuration-file-location&#34;&gt;Grafana configuration file&lt;/a&gt;. For example:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;[auth.google]
enabled = true
allow_sign_up = true
auto_login = false
client_id = CLIENT_ID
client_secret = CLIENT_SECRET
scopes = openid email profile
auth_url = https://accounts.google.com/o/oauth2/v2/auth
token_url = https://oauth2.googleapis.com/token
api_url = https://openidconnect.googleapis.com/v1/userinfo
allowed_domains = mycompany.com mycompany.org
hosted_domain = mycompany.com
use_pkce = true&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;You may have to set the &lt;code&gt;root_url&lt;/code&gt; option of &lt;code&gt;[server]&lt;/code&gt; for the callback URL to be
correct. For example in case you are serving Grafana behind a proxy.&lt;/p&gt;
&lt;p&gt;Restart the Grafana back-end. You should now see a Google login button
on the login page. You can now login or sign up with your Google
accounts. The &lt;code&gt;allowed_domains&lt;/code&gt; option is optional, and domains were separated by space.&lt;/p&gt;
&lt;p&gt;You may allow users to sign-up via Google authentication by setting the
&lt;code&gt;allow_sign_up&lt;/code&gt; option to &lt;code&gt;true&lt;/code&gt;. When this option is set to &lt;code&gt;true&lt;/code&gt;, any
user successfully authenticating via Google authentication will be
automatically signed up.&lt;/p&gt;
&lt;p&gt;You may specify a domain to be passed as &lt;code&gt;hd&lt;/code&gt; query parameter accepted by Google&amp;rsquo;s
OAuth 2.0 authentication API. Refer to Google&amp;rsquo;s OAuth &lt;a href=&#34;https://developers.google.com/identity/openid-connect/openid-connect#hd-param&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;documentation&lt;/a&gt;.&lt;/p&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;The &lt;code&gt;hd&lt;/code&gt; parameter retrieved from Google ID token is also used to determine the user&amp;rsquo;s hosted domain. The Google Oauth &lt;code&gt;allowed_domains&lt;/code&gt; configuration option is used to restrict access to users from a specific domain. If the &lt;code&gt;allowed_domains&lt;/code&gt; configuration option is set, the &lt;code&gt;hd&lt;/code&gt; parameter from the Google ID token must match the &lt;code&gt;allowed_domains&lt;/code&gt; configuration option. If the &lt;code&gt;hd&lt;/code&gt; parameter from the Google ID token does not match the &lt;code&gt;allowed_domains&lt;/code&gt; configuration option, the user is denied access.&lt;/p&gt;
&lt;p&gt;When an account does not belong to a Google Workspace, the &lt;code&gt;hd&lt;/code&gt; claim is not be available.&lt;/p&gt;
&lt;p&gt;This validation will be enabled by default with Grafana 11.0. To disable this validation, set the &lt;code&gt;validate_hd&lt;/code&gt; configuration option to &lt;code&gt;false&lt;/code&gt;. The &lt;code&gt;allowed_domains&lt;/code&gt; configuration option will use the email claim to validate the domain.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h4 id=&#34;pkce&#34;&gt;PKCE&lt;/h4&gt;
&lt;p&gt;IETF&amp;rsquo;s &lt;a href=&#34;https://datatracker.ietf.org/doc/html/rfc7636&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;RFC 7636&lt;/a&gt;
introduces &amp;ldquo;proof key for code exchange&amp;rdquo; (PKCE) which provides
additional protection against some forms of authorization code
interception attacks. PKCE will be required in &lt;a href=&#34;https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-03&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;OAuth 2.1&lt;/a&gt;.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;You can disable PKCE in Grafana by setting &lt;code&gt;use_pkce&lt;/code&gt; to &lt;code&gt;false&lt;/code&gt; in the&lt;code&gt;[auth.google]&lt;/code&gt; section.&lt;/p&gt;&lt;/blockquote&gt;
&lt;h4 id=&#34;configure-refresh-token&#34;&gt;Configure refresh token&lt;/h4&gt;
&lt;blockquote&gt;
&lt;p&gt;Available in Grafana v9.3 and later versions.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;When a user logs in using an OAuth provider, Grafana verifies that the access token has not expired. When an access token expires, Grafana uses the provided refresh token (if any exists) to obtain a new access token.&lt;/p&gt;
&lt;p&gt;Grafana uses a refresh token to obtain a new access token without requiring the user to log in again. If a refresh token doesn&amp;rsquo;t exist, Grafana logs the user out of the system after the access token has expired.&lt;/p&gt;
&lt;p&gt;By default, Grafana includes the &lt;code&gt;access_type=offline&lt;/code&gt; parameter in the authorization request to request a refresh token.&lt;/p&gt;
&lt;p&gt;Refresh token fetching and access token expiration check is enabled by default for the Google provider since Grafana v10.1.0. If you would like to disable access token expiration check then set the &lt;code&gt;use_refresh_token&lt;/code&gt; configuration value to &lt;code&gt;false&lt;/code&gt;.&lt;/p&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;The &lt;code&gt;accessTokenExpirationCheck&lt;/code&gt; feature toggle has been removed in Grafana v10.3.0 and the &lt;code&gt;use_refresh_token&lt;/code&gt; configuration value will be used instead for configuring refresh token fetching and access token expiration check.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h4 id=&#34;configure-automatic-login&#34;&gt;Configure automatic login&lt;/h4&gt;
&lt;p&gt;Set &lt;code&gt;auto_login&lt;/code&gt; option to true to attempt login automatically, skipping the login screen.
This setting is ignored if multiple auth providers are configured to use auto login.&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;auto_login = true&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;configure-team-sync-for-google-oauth&#34;&gt;Configure team sync for Google OAuth&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;Available in Grafana v10.1.0 and later versions.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;With team sync, you can easily add users to teams by utilizing their Google groups. To set up team sync for Google OAuth, refer to the following example.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Enable the Google Cloud Identity API on your &lt;a href=&#34;https://console.cloud.google.com/apis/api/cloudidentity.googleapis.com/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;organization&amp;rsquo;s dashboard&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Add the &lt;code&gt;https://www.googleapis.com/auth/cloud-identity.groups.readonly&lt;/code&gt; scope to your Grafana &lt;code&gt;[auth.google]&lt;/code&gt; configuration:&lt;/p&gt;
&lt;p&gt;Example:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;ini&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-ini&#34;&gt;[auth.google]
# ..
scopes = openid email profile https://www.googleapis.com/auth/cloud-identity.groups.readonly&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Configure team sync in your Grafana team&amp;rsquo;s &lt;code&gt;External group sync&lt;/code&gt; tab.
The external group ID for a Google group is the group&amp;rsquo;s email address, such as &lt;code&gt;dev@grafana.com&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;To learn more about Team Sync, refer to &lt;a href=&#34;../../configure-team-sync/&#34;&gt;Configure Team Sync&lt;/a&gt;.&lt;/p&gt;
&lt;h4 id=&#34;configure-allowed-groups&#34;&gt;Configure allowed groups&lt;/h4&gt;
&lt;blockquote&gt;
&lt;p&gt;Available in Grafana v10.2.0 and later versions.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;To limit access to authenticated users that are members of one or more groups, set &lt;code&gt;allowed_groups&lt;/code&gt;
to a comma or space separated list of groups.&lt;/p&gt;
&lt;p&gt;Google groups are referenced by the group email key. For example, &lt;code&gt;developers@google.com&lt;/code&gt;.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Note: Add the &lt;code&gt;https://www.googleapis.com/auth/cloud-identity.groups.readonly&lt;/code&gt; scope to your Grafana &lt;code&gt;[auth.google]&lt;/code&gt; scopes configuration to retrieve groups&lt;/p&gt;&lt;/blockquote&gt;
&lt;h4 id=&#34;configure-role-mapping&#34;&gt;Configure role mapping&lt;/h4&gt;
&lt;blockquote&gt;
&lt;p&gt;Available in Grafana v10.2.0 and later versions.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Unless &lt;code&gt;skip_org_role_sync&lt;/code&gt; option is enabled, the user&amp;rsquo;s role will be set to the role mapped from Google upon user login. If no mapping is set the default instance role is used.&lt;/p&gt;
&lt;p&gt;The user&amp;rsquo;s role is retrieved using a &lt;a href=&#34;http://jmespath.org/examples.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;JMESPath&lt;/a&gt; expression from the &lt;code&gt;role_attribute_path&lt;/code&gt; configuration option.
To map the server administrator role, use the &lt;code&gt;allow_assign_grafana_admin&lt;/code&gt; configuration option.&lt;/p&gt;
&lt;p&gt;If no valid role is found, the user is assigned the role specified by &lt;a href=&#34;../../../configure-grafana/#auto_assign_org_role&#34;&gt;the &lt;code&gt;auto_assign_org_role&lt;/code&gt; option&lt;/a&gt;.
You can disable this default role assignment by setting &lt;code&gt;role_attribute_strict = true&lt;/code&gt;.
This setting denies user access if no role or an invalid role is returned.&lt;/p&gt;
&lt;p&gt;To ease configuration of a proper JMESPath expression, go to &lt;a href=&#34;http://jmespath.org/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;JMESPath&lt;/a&gt; to test and evaluate expressions with custom payloads.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;By default skip_org_role_sync is enabled. skip_org_role_sync will default to false in Grafana v10.3.0 and later versions.&lt;/p&gt;&lt;/blockquote&gt;
&lt;h5 id=&#34;role-mapping-examples&#34;&gt;Role mapping examples&lt;/h5&gt;
&lt;p&gt;This section includes examples of JMESPath expressions used for role mapping.&lt;/p&gt;
&lt;h6 id=&#34;map-roles-using-user-information-from-oauth-token&#34;&gt;Map roles using user information from OAuth token&lt;/h6&gt;
&lt;p&gt;In this example, the user with email &lt;code&gt;admin@company.com&lt;/code&gt; has been granted the &lt;code&gt;Admin&lt;/code&gt; role.
All other users are granted the &lt;code&gt;Viewer&lt;/code&gt; role.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;ini&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-ini&#34;&gt;role_attribute_path = email==&amp;#39;admin@company.com&amp;#39; &amp;amp;&amp;amp; &amp;#39;Admin&amp;#39; || &amp;#39;Viewer&amp;#39;
skip_org_role_sync = false&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h6 id=&#34;map-roles-using-groups&#34;&gt;Map roles using groups&lt;/h6&gt;
&lt;p&gt;In this example, the user from Google group &amp;rsquo;&lt;a href=&#34;mailto:example-group@google.com&#34;&gt;example-group@google.com&lt;/a&gt;&amp;rsquo; have been granted the &lt;code&gt;Editor&lt;/code&gt; role.
All other users are granted the &lt;code&gt;Viewer&lt;/code&gt; role.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;ini&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-ini&#34;&gt;role_attribute_path = contains(groups[*], &amp;#39;example-group@google.com&amp;#39;) &amp;amp;&amp;amp; &amp;#39;Editor&amp;#39; || &amp;#39;Viewer&amp;#39;
skip_org_role_sync = false&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;blockquote&gt;
&lt;p&gt;Note: Add the &lt;code&gt;https://www.googleapis.com/auth/cloud-identity.groups.readonly&lt;/code&gt; scope to your Grafana &lt;code&gt;[auth.google]&lt;/code&gt; scopes configuration to retrieve groups&lt;/p&gt;&lt;/blockquote&gt;
&lt;h6 id=&#34;map-server-administrator-role&#34;&gt;Map server administrator role&lt;/h6&gt;
&lt;p&gt;In this example, the user with email &lt;code&gt;admin@company.com&lt;/code&gt; has been granted the &lt;code&gt;Admin&lt;/code&gt; organization role as well as the Grafana server admin role.
All other users are granted the &lt;code&gt;Viewer&lt;/code&gt; role.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;ini&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-ini&#34;&gt;allow_assign_grafana_admin = true
skip_org_role_sync = false
role_attribute_path = email==&amp;#39;admin@company.com&amp;#39; &amp;amp;&amp;amp; &amp;#39;GrafanaAdmin&amp;#39; || &amp;#39;Viewer&amp;#39;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h6 id=&#34;map-one-role-to-all-users&#34;&gt;Map one role to all users&lt;/h6&gt;
&lt;p&gt;In this example, all users will be assigned &lt;code&gt;Viewer&lt;/code&gt; role regardless of the user information received from the identity provider.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;ini&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-ini&#34;&gt;role_attribute_path = &amp;#34;&amp;#39;Viewer&amp;#39;&amp;#34;
skip_org_role_sync = false&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="configure-google-oauth2-authentication">Configure Google OAuth2 authentication&lt;/h1>
&lt;p>To enable Google OAuth2 you must register your application with Google. Google will generate a client ID and secret key for you to use.&lt;/p></description></item><item><title>Configure Grafana Com authentication</title><link>https://grafana.com/docs/grafana/v10.4/setup-grafana/configure-security/configure-authentication/grafana-com/</link><pubDate>Wed, 06 Mar 2024 15:13:49 +0000</pubDate><guid>https://grafana.com/docs/grafana/v10.4/setup-grafana/configure-security/configure-authentication/grafana-com/</guid><content><![CDATA[&lt;h1 id=&#34;configure-grafana-com-authentication&#34;&gt;Configure Grafana Com authentication&lt;/h1&gt;
&lt;p&gt;To enable GrafanaCom as your authentication provider, you configure it to generate a client ID and a secret key.&lt;/p&gt;
&lt;h2 id=&#34;create-grafanacom-oauth-keys&#34;&gt;Create GrafanaCom OAuth keys&lt;/h2&gt;
&lt;p&gt;To use GrafanaCom authentication:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Log in to &lt;a href=&#34;/&#34;&gt;GrafanaCom&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;To create an OAuth client, locate your organization and click &lt;strong&gt;OAuth Clients&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Add OAuth Client Application&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Add the name and URL of your running Grafana instance.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Add OAuth Client&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Copy the client ID and secret key or the configuration that has been generated.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The following snippet shows an example configuration:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;ini&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-ini&#34;&gt;[auth.grafana_com]
enabled = true
allow_sign_up = true
auto_login = false
client_id = 450bc21c10dc2194879d
client_secret = eyJ0Ijoib2F1dGgyYyIhlmlkIjoiNzUwYmMzM2MxMGRjMjE6NDh3OWQiLCJ2IjoiZmI1YzVlYmIwYzFmN2ZhYzZmNjIwOGI1NmVkYTRlNWYxMzgwM2NkMiJ9
scopes = user:email
allowed_organizations = sampleorganization
enabled = true&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;configure-automatic-login&#34;&gt;Configure automatic login&lt;/h3&gt;
&lt;p&gt;Set &lt;code&gt;auto_login&lt;/code&gt; option to true to attempt login automatically, skipping the login screen.
This setting is ignored if multiple auth providers are configured to use auto login.&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;auto_login = true&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;skip-organization-role-sync&#34;&gt;Skip organization role sync&lt;/h2&gt;
&lt;p&gt;If a user signs in with their Grafana.com credentials, their assigned org role overrides the role defined in the Grafana instance. To prevent Grafana.com roles from synchronizing, set &lt;code&gt;skip_org_role_sync&lt;/code&gt; to &lt;code&gt;true&lt;/code&gt;. This is useful if you want to manage the organization roles for your users from within Grafana.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;ini&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-ini&#34;&gt;[auth.grafana_com]
# ..
# prevents the sync of org roles from Grafana.com
skip_org_role_sync = true&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="configure-grafana-com-authentication">Configure Grafana Com authentication&lt;/h1>
&lt;p>To enable GrafanaCom as your authentication provider, you configure it to generate a client ID and a secret key.&lt;/p>
&lt;h2 id="create-grafanacom-oauth-keys">Create GrafanaCom OAuth keys&lt;/h2>
&lt;p>To use GrafanaCom authentication:&lt;/p></description></item><item><title>Configure Keycloak OAuth2 authentication</title><link>https://grafana.com/docs/grafana/v10.4/setup-grafana/configure-security/configure-authentication/keycloak/</link><pubDate>Fri, 07 Mar 2025 09:39:42 +0000</pubDate><guid>https://grafana.com/docs/grafana/v10.4/setup-grafana/configure-security/configure-authentication/keycloak/</guid><content><![CDATA[&lt;h1 id=&#34;configure-keycloak-oauth2-authentication&#34;&gt;Configure Keycloak OAuth2 authentication&lt;/h1&gt;
&lt;p&gt;Keycloak OAuth2 authentication allows users to log in to Grafana using their Keycloak credentials. This guide explains how to set up Keycloak as an authentication provider in Grafana.&lt;/p&gt;
&lt;p&gt;Refer to &lt;a href=&#34;../generic-oauth/&#34;&gt;Generic OAuth authentication&lt;/a&gt; for extra configuration options available for this provider.&lt;/p&gt;
&lt;p&gt;You may have to set the &lt;code&gt;root_url&lt;/code&gt; option of &lt;code&gt;[server]&lt;/code&gt; for the callback URL to be
correct. For example in case you are serving Grafana behind a proxy.&lt;/p&gt;
&lt;p&gt;Example config:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;ini&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-ini&#34;&gt;[auth.generic_oauth]
enabled = true
name = Keycloak-OAuth
allow_sign_up = true
client_id = YOUR_APP_CLIENT_ID
client_secret = YOUR_APP_CLIENT_SECRET
scopes = openid email profile offline_access roles
email_attribute_path = email
login_attribute_path = username
name_attribute_path = full_name
auth_url = https://&amp;lt;PROVIDER_DOMAIN&amp;gt;/realms/&amp;lt;REALM_NAME&amp;gt;/protocol/openid-connect/auth
token_url = https://&amp;lt;PROVIDER_DOMAIN&amp;gt;/realms/&amp;lt;REALM_NAME&amp;gt;/protocol/openid-connect/token
api_url = https://&amp;lt;PROVIDER_DOMAIN&amp;gt;/realms/&amp;lt;REALM_NAME&amp;gt;/protocol/openid-connect/userinfo
role_attribute_path = contains(roles[*], &amp;#39;admin&amp;#39;) &amp;amp;&amp;amp; &amp;#39;Admin&amp;#39; || contains(roles[*], &amp;#39;editor&amp;#39;) &amp;amp;&amp;amp; &amp;#39;Editor&amp;#39; || &amp;#39;Viewer&amp;#39;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;As an example, &lt;code&gt;&amp;lt;PROVIDER_DOMAIN&amp;gt;&lt;/code&gt; can be &lt;code&gt;keycloak-demo.grafana.org&lt;/code&gt;
and &lt;code&gt;&amp;lt;REALM_NAME&amp;gt;&lt;/code&gt; can be &lt;code&gt;grafana&lt;/code&gt;.&lt;/p&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;api_url is not required if the id_token contains all the necessary user information and can add latency to the login process.
It is useful as a fallback or if the user has more than 150 group memberships.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h2 id=&#34;keycloak-configuration&#34;&gt;Keycloak configuration&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;Create a client in Keycloak with the following settings:&lt;/li&gt;
&lt;/ol&gt;
&lt;ul&gt;
&lt;li&gt;Client ID: &lt;code&gt;grafana-oauth&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Enabled: &lt;code&gt;ON&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Client Protocol: &lt;code&gt;openid-connect&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Access Type: &lt;code&gt;confidential&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Standard Flow Enabled: &lt;code&gt;ON&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Implicit Flow Enabled: &lt;code&gt;OFF&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Direct Access Grants Enabled: &lt;code&gt;ON&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Root URL: &lt;code&gt;&amp;lt;grafana_root_url&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Valid Redirect URIs: &lt;code&gt;&amp;lt;grafana_root_url&amp;gt;/login/generic_oauth&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Web Origins: &lt;code&gt;&amp;lt;grafana_root_url&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Admin URL: &lt;code&gt;&amp;lt;grafana_root_url&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Base URL: &lt;code&gt;&amp;lt;grafana_root_url&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;As an example, &lt;code&gt;&amp;lt;grafana_root_url&amp;gt;&lt;/code&gt; can be &lt;code&gt;https://play.grafana.org&lt;/code&gt;.
Non-listed configuration options can be left at their default values.&lt;/p&gt;
&lt;ol start=&#34;2&#34;&gt;
&lt;li&gt;In the client scopes configuration, &lt;em&gt;Assigned Default Client Scopes&lt;/em&gt; should match:&lt;/li&gt;
&lt;/ol&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;email
offline_access
profile
roles&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;div class=&#34;admonition admonition-warning&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Warning&lt;/p&gt;&lt;p&gt;these scopes do not add group claims to the id_token. Without group claims, teamsync will not work. Teamsync is covered further down in this document.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;ol start=&#34;3&#34;&gt;
&lt;li&gt;For role mapping to work with the example configuration above,
you need to create the following roles and assign them to users:&lt;/li&gt;
&lt;/ol&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;admin
editor
viewer&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;teamsync&#34;&gt;Teamsync&lt;/h2&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Available in &lt;a href=&#34;../../../../introduction/grafana-enterprise/&#34;&gt;Grafana Enterprise&lt;/a&gt; and &lt;a href=&#34;/docs/grafana-cloud/&#34;&gt;Grafana Cloud&lt;/a&gt;.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href=&#34;../../configure-team-sync/&#34;&gt;Teamsync&lt;/a&gt; is a feature that allows you to map groups from your identity provider to Grafana teams. This is useful if you want to give your users access to specific dashboards or folders based on their group membership.&lt;/p&gt;
&lt;p&gt;To enable teamsync, you need to add a &lt;code&gt;groups&lt;/code&gt; mapper to the client configuration in Keycloak.
This will add the &lt;code&gt;groups&lt;/code&gt; claim to the id_token. You can then use the &lt;code&gt;groups&lt;/code&gt; claim to map groups to teams in Grafana.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;In the client configuration, head to &lt;code&gt;Mappers&lt;/code&gt; and create a mapper with the following settings:&lt;/li&gt;
&lt;/ol&gt;
&lt;ul&gt;
&lt;li&gt;Name: &lt;code&gt;Group Mapper&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Mapper Type: &lt;code&gt;Group Membership&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Token Claim Name: &lt;code&gt;groups&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Full group path: &lt;code&gt;OFF&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Add to ID token: &lt;code&gt;ON&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Add to access token: &lt;code&gt;OFF&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Add to userinfo: &lt;code&gt;ON&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ol start=&#34;2&#34;&gt;
&lt;li&gt;In Grafana&amp;rsquo;s configuration add the following option:&lt;/li&gt;
&lt;/ol&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;ini&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-ini&#34;&gt;[auth.generic_oauth]
groups_attribute_path = groups&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;If you use nested groups containing special characters such as quotes or colons, the JMESPath parser can perform a harmless reverse function so Grafana can properly evaluate nested groups. The following example shows a parent group named &lt;code&gt;Global&lt;/code&gt; with nested group &lt;code&gt;department&lt;/code&gt; that contains a list of groups:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;ini&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-ini&#34;&gt;[auth.generic_oauth]
groups_attribute_path = reverse(&amp;#34;Global:department&amp;#34;)&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;enable-single-logout&#34;&gt;Enable Single Logout&lt;/h2&gt;
&lt;p&gt;To enable Single Logout, you need to add the following option to the configuration of Grafana:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;ini&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-ini&#34;&gt;[auth.generic_oauth]
signout_redirect_url = https://&amp;lt;PROVIDER_DOMAIN&amp;gt;/auth/realms/&amp;lt;REALM_NAME&amp;gt;/protocol/openid-connect/logout?post_logout_redirect_uri=https%3A%2F%2F&amp;lt;GRAFANA_DOMAIN&amp;gt;%2Flogin&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;As an example, &lt;code&gt;&amp;lt;PROVIDER_DOMAIN&amp;gt;&lt;/code&gt; can be &lt;code&gt;keycloak-demo.grafana.org&lt;/code&gt;,
&lt;code&gt;&amp;lt;REALM_NAME&amp;gt;&lt;/code&gt; can be &lt;code&gt;grafana&lt;/code&gt; and &lt;code&gt;&amp;lt;GRAFANA_DOMAIN&amp;gt;&lt;/code&gt; can be &lt;code&gt;play.grafana.org&lt;/code&gt;.&lt;/p&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Grafana supports ID token hints for single logout. Grafana automatically adds the &lt;code&gt;id_token_hint&lt;/code&gt; parameter to the logout request if it detects OAuth as the authentication method.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h2 id=&#34;allow-assigning-grafana-admin&#34;&gt;Allow assigning Grafana Admin&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;Available in Grafana v9.2 and later versions.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;If the application role received by Grafana is &lt;code&gt;GrafanaAdmin&lt;/code&gt; , Grafana grants the user server administrator privileges.&lt;/p&gt;
&lt;p&gt;This is useful if you want to grant server administrator privileges to a subset of users.&lt;br /&gt;
Grafana also assigns the user the &lt;code&gt;Admin&lt;/code&gt; role of the default organization.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;ini&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-ini&#34;&gt;role_attribute_path = contains(roles[*], &amp;#39;grafanaadmin&amp;#39;) &amp;amp;&amp;amp; &amp;#39;GrafanaAdmin&amp;#39; || contains(roles[*], &amp;#39;admin&amp;#39;) &amp;amp;&amp;amp; &amp;#39;Admin&amp;#39; || contains(roles[*], &amp;#39;editor&amp;#39;) &amp;amp;&amp;amp; &amp;#39;Editor&amp;#39; || &amp;#39;Viewer&amp;#39;
allow_assign_grafana_admin = true&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;configure-refresh-token&#34;&gt;Configure refresh token&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;Available in Grafana v9.3 and later versions.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;When a user logs in using an OAuth provider, Grafana verifies that the access token has not expired. When an access token expires, Grafana uses the provided refresh token (if any exists) to obtain a new access token.&lt;/p&gt;
&lt;p&gt;Grafana uses a refresh token to obtain a new access token without requiring the user to log in again. If a refresh token doesn&amp;rsquo;t exist, Grafana logs the user out of the system after the access token has expired.&lt;/p&gt;
&lt;p&gt;To enable a refresh token for Keycloak, do the following:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Extend the &lt;code&gt;scopes&lt;/code&gt; in &lt;code&gt;[auth.generic_oauth]&lt;/code&gt; with &lt;code&gt;offline_access&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Add &lt;code&gt;use_refresh_token = true&lt;/code&gt; to &lt;code&gt;[auth.generic_oauth]&lt;/code&gt; configuration.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
]]></content><description>&lt;h1 id="configure-keycloak-oauth2-authentication">Configure Keycloak OAuth2 authentication&lt;/h1>
&lt;p>Keycloak OAuth2 authentication allows users to log in to Grafana using their Keycloak credentials. This guide explains how to set up Keycloak as an authentication provider in Grafana.&lt;/p></description></item><item><title>Configure Okta OIDC authentication</title><link>https://grafana.com/docs/grafana/v10.4/setup-grafana/configure-security/configure-authentication/okta/</link><pubDate>Fri, 07 Mar 2025 09:39:42 +0000</pubDate><guid>https://grafana.com/docs/grafana/v10.4/setup-grafana/configure-security/configure-authentication/okta/</guid><content><![CDATA[&lt;h1 id=&#34;configure-okta-oidc-authentication&#34;&gt;Configure Okta OIDC authentication&lt;/h1&gt;


&lt;div data-shared=&#34;auth/intro.md&#34;&gt;
            &lt;p&gt;There are numerous authentication methods available in Grafana to verify user identity. The authentication configuration dictates which users can access Grafana and the methods they can use for logging in.
You can also configure Grafana to automatically update users&amp;rsquo; roles and team memberships in Grafana based on the information returned by the auth provider integration.&lt;/p&gt;
&lt;p&gt;When deciding on an authentication method, it&amp;rsquo;s important to take into account your current identity and access management system as well as the specific authentication and authorization features you require.
For a complete list of the available authentication options and the features they support, refer to 
    &lt;a href=&#34;/docs/grafana/v10.4/setup-grafana/configure-security/configure-authentication/&#34;&gt;Configure authentication&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;

        
&lt;h2 id=&#34;before-you-begin&#34;&gt;Before you begin&lt;/h2&gt;
&lt;p&gt;To follow this guide, ensure you have permissions in your Okta workspace to create an OIDC app.&lt;/p&gt;
&lt;h2 id=&#34;create-an-okta-app&#34;&gt;Create an Okta app&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;From the Okta Admin Console, select &lt;strong&gt;Create App Integration&lt;/strong&gt; from the &lt;strong&gt;Applications&lt;/strong&gt; menu.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;For &lt;strong&gt;Sign-in method&lt;/strong&gt;, select &lt;strong&gt;OIDC - OpenID Connect&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;For &lt;strong&gt;Application type&lt;/strong&gt;, select &lt;strong&gt;Web Application&lt;/strong&gt; and click &lt;strong&gt;Next&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Configure &lt;strong&gt;New Web App Integration Operations&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;App integration name&lt;/strong&gt;: Choose a name for the app.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Logo (optional)&lt;/strong&gt;: Add a logo.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Grant type&lt;/strong&gt;: Select &lt;strong&gt;Authorization Code&lt;/strong&gt; and &lt;strong&gt;Refresh Token&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Sign-in redirect URIs&lt;/strong&gt;: Replace the default setting with the Grafana Cloud Okta path, replacing &amp;lt;YOUR_ORG&amp;gt; with the name of your Grafana organization: https://&amp;lt;YOUR_ORG&amp;gt;.grafana.net/login/okta. For on-premises installation, use the Grafana server URL: http://&amp;lt;my_grafana_server_name_or_ip&amp;gt;:&amp;lt;grafana_server_port&amp;gt;/login/okta.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Sign-out redirect URIs (optional)&lt;/strong&gt;: Replace the default setting with the Grafana Cloud Okta path, replacing &amp;lt;YOUR_ORG&amp;gt; with the name of your Grafana organization: https://&amp;lt;YOUR_ORG&amp;gt;.grafana.net/logout. For on-premises installation, use the Grafana server URL: http://&amp;lt;my_grafana_server_name_or_ip&amp;gt;:&amp;lt;grafana_server_port&amp;gt;/logout.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Base URIs (optional)&lt;/strong&gt;: Add any base URIs&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Controlled access&lt;/strong&gt;: Select whether to assign the app integration to everyone in your organization, or only selected groups. You can assign this option after you create the app.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Make a note of the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;ClientID&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Client Secret&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Auth URL&lt;/strong&gt;
For example: https://&amp;lt;TENANT_ID&amp;gt;.okta.com/oauth2/v1/authorize&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Token URL&lt;/strong&gt;
For example: https://&amp;lt;TENANT_ID&amp;gt;.okta.com/oauth2/v1/token&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;API URL&lt;/strong&gt;
For example: https://&amp;lt;TENANT_ID&amp;gt;.okta.com/oauth2/v1/userinfo&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;configure-okta-to-grafana-cloud-role-mapping&#34;&gt;Configure Okta to Grafana Cloud role mapping&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;In the &lt;strong&gt;Okta Admin Console&lt;/strong&gt;, select &lt;strong&gt;Directory &amp;gt; Profile Editor&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Select the Okta Application Profile you created previously (the default name for this is &lt;code&gt;&amp;lt;App name&amp;gt; User&lt;/code&gt;).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Select &lt;strong&gt;Add Attribute&lt;/strong&gt; and fill in the following fields:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Data Type&lt;/strong&gt;: string&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Display Name&lt;/strong&gt;: Meaningful name. For example, &lt;code&gt;Grafana Role&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Variable Name&lt;/strong&gt;: Meaningful name. For example, &lt;code&gt;grafana_role&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Description (optional)&lt;/strong&gt;: A description of the role.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Enum&lt;/strong&gt;: Select &lt;strong&gt;Define enumerated list of values&lt;/strong&gt; and add the following:
&lt;ul&gt;
&lt;li&gt;Display Name: Admin Value: Admin&lt;/li&gt;
&lt;li&gt;Display Name: Editor Value: Editor&lt;/li&gt;
&lt;li&gt;Display Name: Viewer Value: Viewer&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The remaining attributes are optional and can be set as needed.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Save&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;(Optional) You can add the role attribute to the default User profile. To do this, please follow the steps in the &lt;a href=&#34;#optional-add-the-role-attribute-to-the-user-default-okta-profile&#34;&gt;Optional: Add the role attribute to the User (default) Okta profile&lt;/a&gt; section.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;configure-groups-claim&#34;&gt;Configure Groups claim&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;In the &lt;strong&gt;Okta Admin Console&lt;/strong&gt;, select &lt;strong&gt;Application &amp;gt; Applications&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Select the OpenID Connect application you created.&lt;/li&gt;
&lt;li&gt;Go to the &lt;strong&gt;Sign On&lt;/strong&gt; tab and click &lt;strong&gt;Edit&lt;/strong&gt; in the &lt;strong&gt;OpenID Connect ID Token&lt;/strong&gt; section.&lt;/li&gt;
&lt;li&gt;In the &lt;strong&gt;Group claim type&lt;/strong&gt; section, select &lt;strong&gt;Filter&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;In the &lt;strong&gt;Group claim filter&lt;/strong&gt; section, leave the default name &lt;code&gt;groups&lt;/code&gt; (or add it if the box is empty), then select &lt;strong&gt;Matches regex&lt;/strong&gt; and add the following regex: &lt;code&gt;.*&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Save&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Click the &lt;strong&gt;Back to applications&lt;/strong&gt; link at the top of the page.&lt;/li&gt;
&lt;li&gt;From the &lt;strong&gt;More&lt;/strong&gt; button dropdown menu, click &lt;strong&gt;Refresh Application Data&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;h4 id=&#34;optional-add-the-role-attribute-to-the-user-default-okta-profile&#34;&gt;Optional: Add the role attribute to the User (default) Okta profile&lt;/h4&gt;
&lt;p&gt;If you want to configure the role for all users in the Okta directory, you can add the role attribute to the User (default) Okta profile.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Return to the &lt;strong&gt;Directory&lt;/strong&gt; section and select &lt;strong&gt;Profile Editor&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Select the User (default) Okta profile, and click &lt;strong&gt;Add Attribute&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Set all of the attributes in the same way you did in &lt;strong&gt;Step 3&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Select &lt;strong&gt;Add Mapping&lt;/strong&gt; to add your new attributes.
For example, &lt;strong&gt;user.grafana_role -&amp;gt; grafana_role&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;To add a role to a user, select the user from the &lt;strong&gt;Directory&lt;/strong&gt;, and click &lt;strong&gt;Profile -&amp;gt; Edit&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Select an option from your new attribute and click &lt;strong&gt;Save&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Update the Okta integration by setting the &lt;code&gt;Role attribute path&lt;/code&gt; (&lt;code&gt;role_attribute_path&lt;/code&gt; in Terraform and config file) to &lt;code&gt;&amp;lt;YOUR_ROLE_VARIABLE&amp;gt;&lt;/code&gt;. For example: &lt;code&gt;role_attribute_path = grafana_role&lt;/code&gt; (using the configuration).&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;configure-okta-authentication-client-using-the-grafana-ui&#34;&gt;Configure Okta authentication client using the Grafana UI&lt;/h2&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Available in Public Preview in Grafana 10.4 behind the &lt;code&gt;ssoSettingsApi&lt;/code&gt; feature toggle.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;As a Grafana Admin, you can configure Okta OAuth2 client from within Grafana using the Okta UI. To do this, navigate to &lt;strong&gt;Administration &amp;gt; Authentication &amp;gt; Okta&lt;/strong&gt; page and fill in the form. If you have a current configuration in the Grafana configuration file then the form will be pre-populated with those values otherwise the form will contain default values.&lt;/p&gt;
&lt;p&gt;After you have filled in the form, click &lt;strong&gt;Save&lt;/strong&gt;. If the save was successful, Grafana will apply the new configurations.&lt;/p&gt;
&lt;p&gt;If you need to reset changes you made in the UI back to the default values, click &lt;strong&gt;Reset&lt;/strong&gt;. After you have reset the changes, Grafana will apply the configuration from the Grafana configuration file (if there is any configuration) or the default values.&lt;/p&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;If you run Grafana in high availability mode, configuration changes may not get applied to all Grafana instances immediately. You may need to wait a few minutes for the configuration to propagate to all Grafana instances.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;Refer to &lt;a href=&#34;#configuration-options&#34;&gt;configuration options&lt;/a&gt; for more information.&lt;/p&gt;
&lt;h2 id=&#34;configure-okta-authentication-client-using-the-terraform-provider&#34;&gt;Configure Okta authentication client using the Terraform provider&lt;/h2&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Available in Public Preview in Grafana 10.4 behind the &lt;code&gt;ssoSettingsApi&lt;/code&gt; feature toggle. Supported in the Terraform provider since v2.12.0.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;


&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;terraform&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-terraform&#34;&gt;resource &amp;#34;grafana_sso_settings&amp;#34; &amp;#34;okta_sso_settings&amp;#34; {
  provider_name = &amp;#34;okta&amp;#34;
  oauth2_settings {
    name                  = &amp;#34;Okta&amp;#34;
    auth_url              = &amp;#34;https://&amp;lt;okta tenant id&amp;gt;.okta.com/oauth2/v1/authorize&amp;#34;
    token_url             = &amp;#34;https://&amp;lt;okta tenant id&amp;gt;.okta.com/oauth2/v1/token&amp;#34;
    api_url               = &amp;#34;https://&amp;lt;okta tenant id&amp;gt;.okta.com/oauth2/v1/userinfo&amp;#34;
    client_id             = &amp;#34;CLIENT_ID&amp;#34;
    client_secret         = &amp;#34;CLIENT_SECRET&amp;#34;
    allow_sign_up         = true
    auto_login            = false
    scopes                = &amp;#34;openid profile email offline_access&amp;#34;
    role_attribute_path   = &amp;#34;contains(groups[*], &amp;#39;Example::DevOps&amp;#39;) &amp;amp;&amp;amp; &amp;#39;Admin&amp;#39; || &amp;#39;None&amp;#39;&amp;#34;
    role_attribute_strict = true
    allowed_groups        = &amp;#34;Example::DevOps,Example::Dev,Example::QA&amp;#34;
  }
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Go to &lt;a href=&#34;https://registry.terraform.io/providers/grafana/grafana/latest/docs/resources/sso_settings&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Terraform Registry&lt;/a&gt; for a complete reference on using the &lt;code&gt;grafana_sso_settings&lt;/code&gt; resource.&lt;/p&gt;
&lt;h2 id=&#34;configure-okta-authentication-client-using-the-grafana-configuration-file&#34;&gt;Configure Okta authentication client using the Grafana configuration file&lt;/h2&gt;
&lt;p&gt;Ensure that you have access to the &lt;a href=&#34;../../../configure-grafana/#configuration-file-location&#34;&gt;Grafana configuration file&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;steps&#34;&gt;Steps&lt;/h3&gt;
&lt;p&gt;To integrate your Okta OIDC provider with Grafana using our Okta OIDC integration, follow these steps:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Follow the &lt;a href=&#34;#create-an-okta-app&#34;&gt;Create an Okta app&lt;/a&gt; steps to create an OIDC app in Okta.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Refer to the following table to update field values located in the &lt;code&gt;[auth.okta]&lt;/code&gt; section of the Grafana configuration file:&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Field&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;client_id&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;These values must match the client ID from your Okta OIDC app.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;auth_url&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The authorization endpoint of your OIDC provider. &lt;code&gt;https://&amp;lt;okta-tenant-id&amp;gt;.okta.com/oauth2/v1/authorize&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;token_url&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The token endpoint of your Okta OIDC provider. &lt;code&gt;https://&amp;lt;okta-tenant-id&amp;gt;.okta.com/oauth2/v1/token&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;api_url&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The user information endpoint of your Okta OIDC provider. &lt;code&gt;https://&amp;lt;tenant-id&amp;gt;.okta.com/oauth2/v1/userinfo&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;enabled&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Enables Okta OIDC authentication. Set this value to &lt;code&gt;true&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Review the list of other Okta OIDC &lt;a href=&#34;#configuration-options&#34;&gt;configuration options&lt;/a&gt; and complete them as necessary.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Optional: &lt;a href=&#34;#configure-a-refresh-token&#34;&gt;Configure a refresh token&lt;/a&gt;:&lt;/p&gt;
&lt;p&gt;a. Extend the &lt;code&gt;scopes&lt;/code&gt; field of &lt;code&gt;[auth.okta]&lt;/code&gt; section in Grafana configuration file with the refresh token scope used by your OIDC provider.&lt;/p&gt;
&lt;p&gt;b. Enable the &lt;a href=&#34;#configure-a-refresh-token&#34;&gt;refresh token&lt;/a&gt; at the Okta application settings.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&#34;#configure-role-mapping&#34;&gt;Configure role mapping&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Optional: &lt;a href=&#34;#configure-team-synchronization-enterprise-only&#34;&gt;Configure team synchronization&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Restart Grafana.&lt;/p&gt;
&lt;p&gt;You should now see a Okta OIDC login button on the login page and be able to log in or sign up with your OIDC provider.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The following is an example of a minimally functioning integration when
configured with the instructions above:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;ini&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-ini&#34;&gt;[auth.okta]
name = Okta
icon = okta
enabled = true
allow_sign_up = true
client_id = &amp;lt;client id&amp;gt;
scopes = openid profile email offline_access
auth_url = https://&amp;lt;okta tenant id&amp;gt;.okta.com/oauth2/v1/authorize
token_url = https://&amp;lt;okta tenant id&amp;gt;.okta.com/oauth2/v1/token
api_url = https://&amp;lt;okta tenant id&amp;gt;.okta.com/oauth2/v1/userinfo
role_attribute_path = grafana_role
role_attribute_strict = true
allowed_groups = &amp;#34;Example::DevOps&amp;#34; &amp;#34;Example::Dev&amp;#34; &amp;#34;Example::QA&amp;#34;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;configure-a-refresh-token&#34;&gt;Configure a refresh token&lt;/h3&gt;
&lt;p&gt;When a user logs in using an OAuth provider, Grafana verifies that the access token has not expired. When an access token expires, Grafana uses the provided refresh token (if any exists) to obtain a new access token without requiring the user to log in again.&lt;/p&gt;
&lt;p&gt;If a refresh token doesn&amp;rsquo;t exist, Grafana logs the user out of the system after the access token has expired.&lt;/p&gt;
&lt;p&gt;To enable the &lt;code&gt;Refresh Token&lt;/code&gt; head over the Okta application settings and:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Under &lt;code&gt;General&lt;/code&gt; tab, find the &lt;code&gt;General Settings&lt;/code&gt; section.&lt;/li&gt;
&lt;li&gt;Within the &lt;code&gt;Grant Type&lt;/code&gt; options, enable the &lt;code&gt;Refresh Token&lt;/code&gt; checkbox.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;At the configuration file, extend the &lt;code&gt;scopes&lt;/code&gt; in &lt;code&gt;[auth.okta]&lt;/code&gt; section with &lt;code&gt;offline_access&lt;/code&gt; and set &lt;code&gt;use_refresh_token&lt;/code&gt; to &lt;code&gt;true&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&#34;configure-role-mapping&#34;&gt;Configure role mapping&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Unless &lt;code&gt;skip_org_role_sync&lt;/code&gt; option is enabled, the user&amp;rsquo;s role will be set to the role retrieved from the auth provider upon user login.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;The user&amp;rsquo;s role is retrieved using a &lt;a href=&#34;http://jmespath.org/examples.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;JMESPath&lt;/a&gt; expression from the &lt;code&gt;role_attribute_path&lt;/code&gt; configuration option against the &lt;code&gt;api_url&lt;/code&gt; (&lt;code&gt;/userinfo&lt;/code&gt; OIDC endpoint) endpoint payload.&lt;/p&gt;
&lt;p&gt;If no valid role is found, the user is assigned the role specified by &lt;a href=&#34;../../../configure-grafana/#auto_assign_org_role&#34;&gt;the &lt;code&gt;auto_assign_org_role&lt;/code&gt; option&lt;/a&gt;.
You can disable this default role assignment by setting &lt;code&gt;role_attribute_strict = true&lt;/code&gt;. This setting denies user access if no role or an invalid role is returned.&lt;/p&gt;
&lt;p&gt;To allow mapping Grafana server administrator role, use the &lt;code&gt;allow_assign_grafana_admin&lt;/code&gt; configuration option.
Refer to &lt;a href=&#34;../generic-oauth/#configuration-options&#34;&gt;configuration options&lt;/a&gt; for more information.&lt;/p&gt;
&lt;p&gt;In &lt;a href=&#34;#create-an-okta-app&#34;&gt;Create an Okta app&lt;/a&gt;, you created a custom attribute in Okta to store the role. You can use this attribute to map the role to a Grafana role by setting the &lt;code&gt;role_attribute_path&lt;/code&gt; configuration option to the custom attribute name: &lt;code&gt;role_attribute_path = grafana_role&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;If you want to map the role based on the user&amp;rsquo;s group, you can use the &lt;code&gt;groups&lt;/code&gt; attribute from the user info endpoint. An example of this is &lt;code&gt;role_attribute_path = contains(groups[*], &#39;Example::DevOps&#39;) &amp;amp;&amp;amp; &#39;Admin&#39; || &#39;None&#39;&lt;/code&gt;. You can find more examples of JMESPath expressions on the Generic OAuth page for &lt;a href=&#34;../generic-oauth/#role-mapping-examples&#34;&gt;JMESPath examples&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;To learn about adding custom claims to the user info in Okta, refer to &lt;a href=&#34;https://developer.okta.com/docs/guides/customize-tokens-returned-from-okta/main/#add-a-custom-claim-to-a-token&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;add custom claims&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;configure-team-synchronization-enterprise-only&#34;&gt;Configure team synchronization (Enterprise only)&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Available in &lt;a href=&#34;../../../../introduction/grafana-enterprise/&#34;&gt;Grafana Enterprise&lt;/a&gt; and &lt;a href=&#34;../../../../introduction/grafana-cloud/&#34;&gt;Grafana Cloud&lt;/a&gt;.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;By using Team Sync, you can link your Okta groups to teams within Grafana. This will automatically assign users to the appropriate teams.&lt;/p&gt;
&lt;p&gt;Map your Okta groups to teams in Grafana so that your users will automatically be added to
the correct teams.&lt;/p&gt;
&lt;p&gt;Okta groups can be referenced by group names, like &lt;code&gt;Admins&lt;/code&gt; or &lt;code&gt;Editors&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;To learn more about Team Sync, refer to &lt;a href=&#34;../../configure-team-sync/&#34;&gt;Configure Team Sync&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;configuration-options&#34;&gt;Configuration options&lt;/h2&gt;
&lt;p&gt;The following table outlines the various Okta OIDC configuration options. You can apply these options as environment variables, similar to any other configuration within Grafana.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Setting&lt;/th&gt;
              &lt;th&gt;Required&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Default&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;enabled&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Enables Okta OIDC authentication.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;false&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;name&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Name that refers to the Okta OIDC authentication from the Grafana user interface.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;Okta&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;icon&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Icon used for the Okta OIDC authentication in the Grafana user interface.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;okta&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;client_id&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Yes&lt;/td&gt;
              &lt;td&gt;Client ID provided by your Okta OIDC app.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;client_secret&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Yes&lt;/td&gt;
              &lt;td&gt;Client secret provided by your Okta OIDC app.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;auth_url&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Yes&lt;/td&gt;
              &lt;td&gt;Authorization endpoint of your Okta OIDC provider.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;token_url&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Yes&lt;/td&gt;
              &lt;td&gt;Endpoint used to obtain the Okta OIDC access token.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;api_url&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Yes&lt;/td&gt;
              &lt;td&gt;Endpoint used to obtain user information.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;scopes&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;List of comma- or space-separated Okta OIDC scopes.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;openid profile email groups&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;allow_sign_up&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Controls Grafana user creation through the Okta OIDC login. Only existing Grafana users can log in with Okta OIDC if set to &lt;code&gt;false&lt;/code&gt;.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;true&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;auto_login&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Set to &lt;code&gt;true&lt;/code&gt; to enable users to bypass the login screen and automatically log in. This setting is ignored if you configure multiple auth providers to use auto-login.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;false&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;role_attribute_path&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;http://jmespath.org/examples.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;JMESPath&lt;/a&gt; expression to use for Grafana role lookup. Grafana will first evaluate the expression using the Okta OIDC ID token. If no role is found, the expression will be evaluated using the user information obtained from the UserInfo endpoint. The result of the evaluation should be a valid Grafana role (&lt;code&gt;Viewer&lt;/code&gt;, &lt;code&gt;Editor&lt;/code&gt;, &lt;code&gt;Admin&lt;/code&gt; or &lt;code&gt;GrafanaAdmin&lt;/code&gt;). For more information on user role mapping, refer to &lt;a href=&#34;#configure-role-mapping&#34;&gt;Configure role mapping&lt;/a&gt;.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;role_attribute_strict&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Set to &lt;code&gt;true&lt;/code&gt; to deny user login if the Grafana role cannot be extracted using &lt;code&gt;role_attribute_path&lt;/code&gt;. For more information on user role mapping, refer to &lt;a href=&#34;#configure-role-mapping&#34;&gt;Configure role mapping&lt;/a&gt;.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;false&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;skip_org_role_sync&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Set to &lt;code&gt;true&lt;/code&gt; to stop automatically syncing user roles. This will allow you to set organization roles for your users from within Grafana manually.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;false&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;allowed_groups&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;List of comma- or space-separated groups. The user should be a member of at least one group to log in.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;allowed_domains&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;List comma- or space-separated domains. The user should belong to at least one domain to log in.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;use_pkce&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Set to &lt;code&gt;true&lt;/code&gt; to use &lt;a href=&#34;https://datatracker.ietf.org/doc/html/rfc7636&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Proof Key for Code Exchange (PKCE)&lt;/a&gt;. Grafana uses the SHA256 based &lt;code&gt;S256&lt;/code&gt; challenge method and a 128 bytes (base64url encoded) code verifier.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;true&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;use_refresh_token&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
              &lt;td&gt;Set to &lt;code&gt;true&lt;/code&gt; to use refresh token and check access token expiration.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;false&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;]]></content><description>&lt;h1 id="configure-okta-oidc-authentication">Configure Okta OIDC authentication&lt;/h1>
&lt;div data-shared="auth/intro.md">
&lt;p>There are numerous authentication methods available in Grafana to verify user identity. The authentication configuration dictates which users can access Grafana and the methods they can use for logging in.
You can also configure Grafana to automatically update users&amp;rsquo; roles and team memberships in Grafana based on the information returned by the auth provider integration.&lt;/p></description></item><item><title>Configure auth proxy authentication</title><link>https://grafana.com/docs/grafana/v10.4/setup-grafana/configure-security/configure-authentication/auth-proxy/</link><pubDate>Fri, 07 Mar 2025 09:39:42 +0000</pubDate><guid>https://grafana.com/docs/grafana/v10.4/setup-grafana/configure-security/configure-authentication/auth-proxy/</guid><content><![CDATA[&lt;h1 id=&#34;configure-auth-proxy-authentication&#34;&gt;Configure auth proxy authentication&lt;/h1&gt;
&lt;p&gt;You can configure Grafana to let a HTTP reverse proxy handle authentication. Popular web servers have a very
extensive list of pluggable authentication modules, and any of them can be used with the AuthProxy feature.
Below we detail the configuration options for auth proxy.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;[auth.proxy]
# Defaults to false, but set to true to enable this feature
enabled = true
# HTTP Header name that will contain the username or email
header_name = X-WEBAUTH-USER
# HTTP Header property, defaults to `username` but can also be `email`
header_property = username
# Set to `true` to enable auto sign up of users who do not exist in Grafana DB. Defaults to `true`.
auto_sign_up = true
# Define cache time to live in minutes
# If combined with Grafana LDAP integration it is also the sync interval
sync_ttl = 60
# Limit where auth proxy requests come from by configuring a list of IP addresses.
# This can be used to prevent users spoofing the X-WEBAUTH-USER header.
# Example `whitelist = 192.168.1.1, 192.168.1.0/24, 2001::23, 2001::0/120`
whitelist =
# Optionally define more headers to sync other user attributes
# Example `headers = Name:X-WEBAUTH-NAME Role:X-WEBAUTH-ROLE Email:X-WEBAUTH-EMAIL Groups:X-WEBAUTH-GROUPS`
headers =
# Non-ASCII strings in header values are encoded using quoted-printable encoding
;headers_encoded = false
# Check out docs on this for more details on the below setting
enable_login_token = false&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;interacting-with-grafanas-authproxy-via-curl&#34;&gt;Interacting with Grafana’s AuthProxy via curl&lt;/h2&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;curl -H &amp;#34;X-WEBAUTH-USER: admin&amp;#34;  http://localhost:3000/api/users
[
    {
        &amp;#34;id&amp;#34;:1,
        &amp;#34;name&amp;#34;:&amp;#34;&amp;#34;,
        &amp;#34;login&amp;#34;:&amp;#34;admin&amp;#34;,
        &amp;#34;email&amp;#34;:&amp;#34;admin@localhost&amp;#34;,
        &amp;#34;isAdmin&amp;#34;:true
    }
]&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;We can then send a second request to the &lt;code&gt;/api/user&lt;/code&gt; method which will return the details of the logged in user. We will use this request to show how Grafana automatically adds the new user we specify to the system. Here we create a new user called “anthony”.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;curl -H &amp;#34;X-WEBAUTH-USER: anthony&amp;#34; http://localhost:3000/api/user
{
    &amp;#34;email&amp;#34;:&amp;#34;anthony&amp;#34;,
    &amp;#34;name&amp;#34;:&amp;#34;&amp;#34;,
    &amp;#34;login&amp;#34;:&amp;#34;anthony&amp;#34;,
    &amp;#34;theme&amp;#34;:&amp;#34;&amp;#34;,
    &amp;#34;orgId&amp;#34;:1,
    &amp;#34;isGrafanaAdmin&amp;#34;:false
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;making-apaches-auth-work-together-with-grafanas-authproxy&#34;&gt;Making Apache’s auth work together with Grafana’s AuthProxy&lt;/h2&gt;
&lt;p&gt;I’ll demonstrate how to use Apache for authenticating users. In this example we use BasicAuth with Apache’s text file based authentication handler, i.e. htpasswd files. However, any available Apache authentication capabilities could be used.&lt;/p&gt;
&lt;h3 id=&#34;apache-basicauth&#34;&gt;Apache BasicAuth&lt;/h3&gt;
&lt;p&gt;In this example we use Apache as a reverse proxy in front of Grafana. Apache handles the Authentication of users before forwarding requests to the Grafana backend service.&lt;/p&gt;
&lt;h4 id=&#34;apache-configuration&#34;&gt;Apache configuration&lt;/h4&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;    &amp;lt;VirtualHost *:80&amp;gt;
        ServerAdmin webmaster@authproxy
        ServerName authproxy
        ErrorLog &amp;#34;logs/authproxy-error_log&amp;#34;
        CustomLog &amp;#34;logs/authproxy-access_log&amp;#34; common

        &amp;lt;Proxy *&amp;gt;
            AuthType Basic
            AuthName GrafanaAuthProxy
            AuthBasicProvider file
            AuthUserFile /etc/apache2/grafana_htpasswd
            Require valid-user

            RewriteEngine On
            RewriteRule .* - [E=PROXY_USER:%{LA-U:REMOTE_USER},NS]
            RequestHeader set X-WEBAUTH-USER &amp;#34;%{PROXY_USER}e&amp;#34;
        &amp;lt;/Proxy&amp;gt;

        RequestHeader unset Authorization

        ProxyRequests Off
        ProxyPass / http://localhost:3000/
        ProxyPassReverse / http://localhost:3000/
    &amp;lt;/VirtualHost&amp;gt;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;The first four lines of the virtualhost configuration are standard, so we won’t go into detail on what they do.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;We use a &lt;strong&gt;&amp;lt;proxy&amp;gt;&lt;/strong&gt; configuration block for applying our authentication rules to every proxied request. These rules include requiring basic authentication where user:password credentials are stored in the &lt;strong&gt;/etc/apache2/grafana_htpasswd&lt;/strong&gt; file. This file can be created with the &lt;code&gt;htpasswd&lt;/code&gt; command.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;The next part of the configuration is the tricky part. We use Apache’s rewrite engine to create our &lt;strong&gt;X-WEBAUTH-USER header&lt;/strong&gt;, populated with the authenticated user.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;RewriteRule .* - [E=PROXY_USER:%{LA-U:REMOTE_USER}, NS]&lt;/strong&gt;: This line is a little bit of magic. What it does, is for every request use the rewriteEngines look-ahead (LA-U) feature to determine what the REMOTE_USER variable would be set to after processing the request. Then assign the result to the variable PROXY_USER. This is necessary as the REMOTE_USER variable is not available to the RequestHeader function.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;RequestHeader set X-WEBAUTH-USER “%{PROXY_USER}e”&lt;/strong&gt;: With the authenticated username now stored in the PROXY_USER variable, we create a new HTTP request header that will be sent to our backend Grafana containing the username.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The &lt;strong&gt;RequestHeader unset Authorization&lt;/strong&gt; removes the Authorization header from the HTTP request before it is forwarded to Grafana. This ensures that Grafana does not try to authenticate the user using these credentials (BasicAuth is a supported authentication handler in Grafana).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The last 3 lines are then just standard reverse proxy configuration to direct all authenticated requests to our Grafana server running on port 3000.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;full-walkthrough-using-docker&#34;&gt;Full walkthrough using Docker.&lt;/h2&gt;
&lt;p&gt;For this example, we use the official Grafana Docker image available at &lt;a href=&#34;https://hub.docker.com/r/grafana/grafana/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Docker Hub&lt;/a&gt;.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Create a file &lt;code&gt;grafana.ini&lt;/code&gt; with the following contents&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;[users]
allow_sign_up = false
auto_assign_org = true
auto_assign_org_role = Editor

[auth.proxy]
enabled = true
header_name = X-WEBAUTH-USER
header_property = username
auto_sign_up = true&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Launch the Grafana container, using our custom grafana.ini to replace &lt;code&gt;/etc/grafana/grafana.ini&lt;/code&gt;. We don&amp;rsquo;t expose
any ports for this container as it will only be connected to by our Apache container.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;docker run -i -v $(pwd)/grafana.ini:/etc/grafana/grafana.ini --name grafana grafana/grafana&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;apache-container&#34;&gt;Apache Container&lt;/h3&gt;
&lt;p&gt;For this example we use the official Apache docker image available at &lt;a href=&#34;https://hub.docker.com/_/httpd/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Docker Hub&lt;/a&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Create a file &lt;code&gt;httpd.conf&lt;/code&gt; with the following contents&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;ServerRoot &amp;#34;/usr/local/apache2&amp;#34;
Listen 80
LoadModule mpm_event_module modules/mod_mpm_event.so
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authn_core_module modules/mod_authn_core.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule env_module modules/mod_env.so
LoadModule headers_module modules/mod_headers.so
LoadModule unixd_module modules/mod_unixd.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
&amp;lt;IfModule unixd_module&amp;gt;
User daemon
Group daemon
&amp;lt;/IfModule&amp;gt;
ServerAdmin you@example.com
&amp;lt;Directory /&amp;gt;
    AllowOverride none
    Require all denied
&amp;lt;/Directory&amp;gt;
DocumentRoot &amp;#34;/usr/local/apache2/htdocs&amp;#34;
ErrorLog /proc/self/fd/2
LogLevel error
&amp;lt;IfModule log_config_module&amp;gt;
    LogFormat &amp;#34;%h %l %u %t \&amp;#34;%r\&amp;#34; %&amp;gt;s %b \&amp;#34;%{Referer}i\&amp;#34; \&amp;#34;%{User-Agent}i\&amp;#34;&amp;#34; combined
    LogFormat &amp;#34;%h %l %u %t \&amp;#34;%r\&amp;#34; %&amp;gt;s %b&amp;#34; common
    &amp;lt;IfModule logio_module&amp;gt;
    LogFormat &amp;#34;%h %l %u %t \&amp;#34;%r\&amp;#34; %&amp;gt;s %b \&amp;#34;%{Referer}i\&amp;#34; \&amp;#34;%{User-Agent}i\&amp;#34; %I %O&amp;#34; combinedio
    &amp;lt;/IfModule&amp;gt;
    CustomLog /proc/self/fd/1 common
&amp;lt;/IfModule&amp;gt;
&amp;lt;Proxy *&amp;gt;
    AuthType Basic
    AuthName GrafanaAuthProxy
    AuthBasicProvider file
    AuthUserFile /tmp/htpasswd
    Require valid-user
    RewriteEngine On
    RewriteRule .* - [E=PROXY_USER:%{LA-U:REMOTE_USER},NS]
    RequestHeader set X-WEBAUTH-USER &amp;#34;%{PROXY_USER}e&amp;#34;
&amp;lt;/Proxy&amp;gt;
RequestHeader unset Authorization
ProxyRequests Off
ProxyPass / http://grafana:3000/
ProxyPassReverse / http://grafana:3000/&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Create a htpasswd file. We create a new user &lt;strong&gt;anthony&lt;/strong&gt; with the password &lt;strong&gt;password&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;htpasswd -bc htpasswd anthony password&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Launch the httpd container using our custom httpd.conf and our htpasswd file. The container will listen on port 80, and we create a link to the &lt;strong&gt;grafana&lt;/strong&gt; container so that this container can resolve the hostname &lt;strong&gt;grafana&lt;/strong&gt; to the Grafana container’s IP address.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;docker run -i -p 80:80 --link grafana:grafana -v $(pwd)/httpd.conf:/usr/local/apache2/conf/httpd.conf -v $(pwd)/htpasswd:/tmp/htpasswd httpd:2.4&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;use-grafana&#34;&gt;Use grafana.&lt;/h3&gt;
&lt;p&gt;With our Grafana and Apache containers running, you can now connect to http://localhost/ and log in using the username/password we created in the htpasswd file.&lt;/p&gt;
&lt;h3 id=&#34;team-sync-enterprise-only&#34;&gt;Team Sync (Enterprise only)&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;Only available in Grafana Enterprise v6.3&#43;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;With Team Sync, it&amp;rsquo;s possible to set up synchronization between teams in your authentication provider and Grafana. You can send Grafana values as part of an HTTP header and have Grafana map them to your team structure. This allows you to put users into specific teams automatically.&lt;/p&gt;
&lt;p&gt;To support the feature, auth proxy allows optional headers to map additional user attributes. The specific attribute to support team sync is &lt;code&gt;Groups&lt;/code&gt;.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;# Optionally define more headers to sync other user attributes
headers = &amp;#34;Groups:X-WEBAUTH-GROUPS&amp;#34;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;You use the &lt;code&gt;X-WEBAUTH-GROUPS&lt;/code&gt; header to send the team information for each user. Specifically, the set of Grafana&amp;rsquo;s group IDs that the user belongs to.&lt;/p&gt;
&lt;p&gt;First, we need to set up the mapping between your authentication provider and Grafana. Follow &lt;a href=&#34;../../configure-team-sync/#synchronize-a-grafana-team-with-an-external-group&#34;&gt;these instructions&lt;/a&gt; to add groups to a team within Grafana.&lt;/p&gt;
&lt;p&gt;Once that&amp;rsquo;s done. You can verify your mappings by querying the API.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;# First, inspect your teams and obtain the corresponding ID of the team we want to inspect the groups for.
curl -H &amp;#34;X-WEBAUTH-USER: admin&amp;#34; -H &amp;#34;X-WEBAUTH-GROUPS: lokiteamOnExternalSystem&amp;#34; http://localhost:3000/api/teams/search
{
  &amp;#34;totalCount&amp;#34;: 2,
  &amp;#34;teams&amp;#34;: [
    {
      &amp;#34;id&amp;#34;: 1,
      &amp;#34;orgId&amp;#34;: 1,
      &amp;#34;name&amp;#34;: &amp;#34;Core&amp;#34;,
      &amp;#34;email&amp;#34;: &amp;#34;core@grafana.com&amp;#34;,
      &amp;#34;avatarUrl&amp;#34;: &amp;#34;/avatar/327a5353552d2dc3966e2e646908f540&amp;#34;,
      &amp;#34;memberCount&amp;#34;: 1,
      &amp;#34;permission&amp;#34;: 0
    },
    {
      &amp;#34;id&amp;#34;: 2,
      &amp;#34;orgId&amp;#34;: 1,
      &amp;#34;name&amp;#34;: &amp;#34;Loki&amp;#34;,
      &amp;#34;email&amp;#34;: &amp;#34;loki@grafana.com&amp;#34;,
      &amp;#34;avatarUrl&amp;#34;: &amp;#34;/avatar/102f937d5344d33fdb37b65d430f36ef&amp;#34;,
      &amp;#34;memberCount&amp;#34;: 0,
      &amp;#34;permission&amp;#34;: 0
    }
  ],
  &amp;#34;page&amp;#34;: 1,
  &amp;#34;perPage&amp;#34;: 1000
}

# Then, query the groups for that particular team. In our case, the Loki team which has an ID of &amp;#34;2&amp;#34;.
curl -H &amp;#34;X-WEBAUTH-USER: admin&amp;#34; -H &amp;#34;X-WEBAUTH-GROUPS: lokiteamOnExternalSystem&amp;#34; http://localhost:3000/api/teams/2/groups
[
  {
    &amp;#34;orgId&amp;#34;: 1,
    &amp;#34;teamId&amp;#34;: 2,
    &amp;#34;groupId&amp;#34;: &amp;#34;lokiTeamOnExternalSystem&amp;#34;
  }
]&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Finally, whenever Grafana receives a request with a header of &lt;code&gt;X-WEBAUTH-GROUPS: lokiTeamOnExternalSystem&lt;/code&gt;, the user under authentication will be placed into the specified team. Placement in multiple teams is supported by using comma-separated values e.g. &lt;code&gt;lokiTeamOnExternalSystem,CoreTeamOnExternalSystem&lt;/code&gt;.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;curl -H &amp;#34;X-WEBAUTH-USER: leonard&amp;#34; -H &amp;#34;X-WEBAUTH-GROUPS: lokiteamOnExternalSystem&amp;#34; http://localhost:3000/dashboards/home
{
  &amp;#34;meta&amp;#34;: {
    &amp;#34;isHome&amp;#34;: true,
    &amp;#34;canSave&amp;#34;: false,
    ...
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;With this, the user &lt;code&gt;leonard&lt;/code&gt; will be automatically placed into the Loki team as part of Grafana authentication.&lt;/p&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;An empty &lt;code&gt;X-WEBAUTH-GROUPS&lt;/code&gt; or the absence of a groups header will remove the user from all teams.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href=&#34;../../configure-team-sync/&#34;&gt;Learn more about Team Sync&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;login-token-and-session-cookie&#34;&gt;Login token and session cookie&lt;/h2&gt;
&lt;p&gt;With &lt;code&gt;enable_login_token&lt;/code&gt; set to &lt;code&gt;true&lt;/code&gt; Grafana will, after successful auth proxy header validation, assign the user
a login token and cookie. You only have to configure your auth proxy to provide headers for the /login route.
Requests via other routes will be authenticated using the cookie.&lt;/p&gt;
&lt;p&gt;Use settings &lt;code&gt;login_maximum_inactive_lifetime_duration&lt;/code&gt; and &lt;code&gt;login_maximum_lifetime_duration&lt;/code&gt; under &lt;code&gt;[auth]&lt;/code&gt; to control session
lifetime.&lt;/p&gt;
]]></content><description>&lt;h1 id="configure-auth-proxy-authentication">Configure auth proxy authentication&lt;/h1>
&lt;p>You can configure Grafana to let a HTTP reverse proxy handle authentication. Popular web servers have a very
extensive list of pluggable authentication modules, and any of them can be used with the AuthProxy feature.
Below we detail the configuration options for auth proxy.&lt;/p></description></item><item><title>Configure JWT authentication</title><link>https://grafana.com/docs/grafana/v10.4/setup-grafana/configure-security/configure-authentication/jwt/</link><pubDate>Fri, 07 Mar 2025 09:39:42 +0000</pubDate><guid>https://grafana.com/docs/grafana/v10.4/setup-grafana/configure-security/configure-authentication/jwt/</guid><content><![CDATA[&lt;h1 id=&#34;configure-jwt-authentication&#34;&gt;Configure JWT authentication&lt;/h1&gt;
&lt;p&gt;You can configure Grafana to accept a JWT token provided in the HTTP header. The token is verified using any of the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;PEM-encoded key file&lt;/li&gt;
&lt;li&gt;JSON Web Key Set (JWKS) in a local file&lt;/li&gt;
&lt;li&gt;JWKS provided by the configured JWKS endpoint&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This method of authentication is useful for integrating with other systems that
use JWKS but can&amp;rsquo;t directly integrate with Grafana or if you want to use pass-through
authentication in an app embedding Grafana.&lt;/p&gt;
&lt;h2 id=&#34;enable-jwt&#34;&gt;Enable JWT&lt;/h2&gt;
&lt;p&gt;To use JWT authentication:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Enable JWT in the &lt;a href=&#34;../../../configure-grafana/&#34;&gt;main config file&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Specify the header name that contains a token.&lt;/li&gt;
&lt;/ol&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;ini&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-ini&#34;&gt;[auth.jwt]
# By default, auth.jwt is disabled.
enabled = true

# HTTP header to look into to get a JWT token.
header_name = X-JWT-Assertion&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;configure-login-claim&#34;&gt;Configure login claim&lt;/h2&gt;
&lt;p&gt;To identify the user, some of the claims needs to be selected as a login info. The subject claim called &lt;code&gt;&amp;quot;sub&amp;quot;&lt;/code&gt; is mandatory and needs to identify the principal that is the subject of the JWT.&lt;/p&gt;
&lt;p&gt;Typically, the subject claim called &lt;code&gt;&amp;quot;sub&amp;quot;&lt;/code&gt; would be used as a login but it might also be set to some application specific claim.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;ini&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-ini&#34;&gt;# [auth.jwt]
# ...

# Specify a claim to use as a username to sign in.
username_claim = sub

# Specify a claim to use as an email to sign in.
email_claim = sub

# auto-create users if they are not already matched
# auto_sign_up = true&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;If &lt;code&gt;auto_sign_up&lt;/code&gt; is enabled, then the &lt;code&gt;sub&lt;/code&gt; claim is used as the &amp;ldquo;external Auth ID&amp;rdquo;. The &lt;code&gt;name&lt;/code&gt; claim is used as the user&amp;rsquo;s full name if it is present.&lt;/p&gt;
&lt;h2 id=&#34;iframe-embedding&#34;&gt;Iframe Embedding&lt;/h2&gt;
&lt;p&gt;If you want to embed Grafana in an iframe while maintaining user identity and role checks,
you can use JWT authentication to authenticate the iframe.&lt;/p&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;For Grafana Cloud, or scenarios where verifying viewer identity is not required,
embed &lt;a href=&#34;../../../../dashboards/dashboard-public/&#34;&gt;public dashboards&lt;/a&gt;.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;In this scenario, you will need to configure Grafana to accept a JWT
provided in the HTTP header and a reverse proxy should rewrite requests to the
Grafana instance to include the JWT in the request&amp;rsquo;s headers.&lt;/p&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;For embedding to work, you must enable &lt;code&gt;allow_embedding&lt;/code&gt; in the &lt;a href=&#34;../../../configure-grafana/#allow_embedding&#34;&gt;security section&lt;/a&gt;. This setting is not available in Grafana Cloud.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;In a scenario where it is not possible to rewrite the request headers you
can use URL login instead.&lt;/p&gt;
&lt;h3 id=&#34;url-login&#34;&gt;URL login&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;url_login&lt;/code&gt; allows grafana to search for a JWT in the URL query parameter
&lt;code&gt;auth_token&lt;/code&gt; and use it as the authentication token.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: You need to have enabled JWT before setting this setting see section Enabled JWT&lt;/p&gt;


&lt;div class=&#34;admonition admonition-warning&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Warning&lt;/p&gt;&lt;p&gt;this can lead to JWTs being exposed in logs and possible session hijacking if the server is not
using HTTP over TLS.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;


&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;ini&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-ini&#34;&gt;# [auth.jwt]
# ...
url_login = true # enable JWT authentication in the URL&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;An example of an URL for accessing grafana with JWT URL authentication is:&lt;/p&gt;

&lt;div class=&#34;code-snippet code-snippet__mini&#34;&gt;&lt;div class=&#34;lang-toolbar__mini&#34;&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet code-snippet__border&#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-none&#34;&gt;http://env.grafana.local/d/RciOKLR4z/board-identifier?orgId=1&amp;amp;kiosk&amp;amp;auth_token=eyJhbxxxxxxxxxxxxx&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;A sample repository using this authentication method is available
at &lt;a href=&#34;https://github.com/grafana/grafana-iframe-oauth-sample&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;grafana-iframe-oauth-sample&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;signature-verification&#34;&gt;Signature verification&lt;/h2&gt;
&lt;p&gt;JSON web token integrity needs to be verified so cryptographic signature is used for this purpose. So we expect that every token must be signed with some known cryptographic key.&lt;/p&gt;
&lt;p&gt;You have a variety of options on how to specify where the keys are located.&lt;/p&gt;
&lt;h3 id=&#34;verify-token-using-a-json-web-key-set-loaded-from-https-endpoint&#34;&gt;Verify token using a JSON Web Key Set loaded from https endpoint&lt;/h3&gt;
&lt;p&gt;For more information on JWKS endpoints, refer to &lt;a href=&#34;https://auth0.com/docs/tokens/json-web-tokens/json-web-key-sets&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Auth0 docs&lt;/a&gt;.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;ini&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-ini&#34;&gt;# [auth.jwt]
# ...

jwk_set_url = https://your-auth-provider.example.com/.well-known/jwks.json

# Cache TTL for data loaded from http endpoint.
cache_ttl = 60m&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: If the JWKS endpoint includes cache control headers and the value is less than the configured &lt;code&gt;cache_ttl&lt;/code&gt;, then the cache control header value is used instead. If the cache_ttl is not set, no caching is performed. &lt;code&gt;no-store&lt;/code&gt; and &lt;code&gt;no-cache&lt;/code&gt; cache control headers are ignored.&lt;/p&gt;&lt;/blockquote&gt;
&lt;h3 id=&#34;verify-token-using-a-json-web-key-set-loaded-from-json-file&#34;&gt;Verify token using a JSON Web Key Set loaded from JSON file&lt;/h3&gt;
&lt;p&gt;Key set in the same format as in JWKS endpoint but located on disk.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;ini&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-ini&#34;&gt;jwk_set_file = /path/to/jwks.json&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;verify-token-using-a-single-key-loaded-from-pem-encoded-file&#34;&gt;Verify token using a single key loaded from PEM-encoded file&lt;/h3&gt;
&lt;p&gt;PEM-encoded key file in PKIX, PKCS #1, PKCS #8 or SEC 1 format.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;ini&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-ini&#34;&gt;key_file = /path/to/key.pem&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;If the JWT token&amp;rsquo;s header specifies a &lt;code&gt;kid&lt;/code&gt; (Key ID), then the Key ID must be set using the &lt;code&gt;key_id&lt;/code&gt; configuration option.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;ini&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-ini&#34;&gt;key_id = my-key-id&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;validate-claims&#34;&gt;Validate claims&lt;/h2&gt;
&lt;p&gt;By default, only &lt;code&gt;&amp;quot;exp&amp;quot;&lt;/code&gt;, &lt;code&gt;&amp;quot;nbf&amp;quot;&lt;/code&gt; and &lt;code&gt;&amp;quot;iat&amp;quot;&lt;/code&gt; claims are validated.&lt;/p&gt;
&lt;p&gt;You might also want to validate that other claims are really what you expect them to be.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;ini&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-ini&#34;&gt;# This can be seen as a required &amp;#34;subset&amp;#34; of a JWT Claims Set.
expect_claims = {&amp;#34;iss&amp;#34;: &amp;#34;https://your-token-issuer&amp;#34;, &amp;#34;your-custom-claim&amp;#34;: &amp;#34;foo&amp;#34;}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;roles&#34;&gt;Roles&lt;/h2&gt;
&lt;p&gt;Grafana checks for the presence of a role using the &lt;a href=&#34;http://jmespath.org/examples.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;JMESPath&lt;/a&gt; specified via the &lt;code&gt;role_attribute_path&lt;/code&gt; configuration option. The JMESPath is applied to JWT token claims. The result after evaluation of the &lt;code&gt;role_attribute_path&lt;/code&gt; JMESPath expression should be a valid Grafana role, for example, &lt;code&gt;Viewer&lt;/code&gt;, &lt;code&gt;Editor&lt;/code&gt; or &lt;code&gt;Admin&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The organization that the role is assigned to can be configured using the &lt;code&gt;X-Grafana-Org-Id&lt;/code&gt; header.&lt;/p&gt;
&lt;h3 id=&#34;jmespath-examples&#34;&gt;JMESPath examples&lt;/h3&gt;
&lt;p&gt;To ease configuration of a proper JMESPath expression, you can test/evaluate expressions with custom payloads at &lt;a href=&#34;http://jmespath.org/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;http://jmespath.org/&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;role-mapping&#34;&gt;Role mapping&lt;/h3&gt;
&lt;p&gt;If the &lt;code&gt;role_attribute_path&lt;/code&gt; property does not return a role, then the user is assigned the &lt;code&gt;Viewer&lt;/code&gt; role by default. You can disable the role assignment by setting &lt;code&gt;role_attribute_strict = true&lt;/code&gt;. It denies user access if no role or an invalid role is returned.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Basic example:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;In the following example user will get &lt;code&gt;Editor&lt;/code&gt; as role when authenticating. The value of the property &lt;code&gt;role&lt;/code&gt; will be the resulting role if the role is a proper Grafana role, i.e. &lt;code&gt;Viewer&lt;/code&gt;, &lt;code&gt;Editor&lt;/code&gt; or &lt;code&gt;Admin&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Payload:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JSON&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-json&#34;&gt;{
    ...
    &amp;#34;role&amp;#34;: &amp;#34;Editor&amp;#34;,
    ...
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Config:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;role_attribute_path = role&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Advanced example:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;In the following example user will get &lt;code&gt;Admin&lt;/code&gt; as role when authenticating since it has a role &lt;code&gt;admin&lt;/code&gt;. If a user has a role &lt;code&gt;editor&lt;/code&gt; it will get &lt;code&gt;Editor&lt;/code&gt; as role, otherwise &lt;code&gt;Viewer&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Payload:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JSON&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-json&#34;&gt;{
    ...
    &amp;#34;info&amp;#34;: {
        ...
        &amp;#34;roles&amp;#34;: [
            &amp;#34;engineer&amp;#34;,
            &amp;#34;admin&amp;#34;,
        ],
        ...
    },
    ...
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Config:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;role_attribute_path = contains(info.roles[*], &amp;#39;admin&amp;#39;) &amp;amp;&amp;amp; &amp;#39;Admin&amp;#39; || contains(info.roles[*], &amp;#39;editor&amp;#39;) &amp;amp;&amp;amp; &amp;#39;Editor&amp;#39; || &amp;#39;Viewer&amp;#39;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;grafana-admin-role&#34;&gt;Grafana Admin Role&lt;/h3&gt;
&lt;p&gt;If the &lt;code&gt;role_attribute_path&lt;/code&gt; property returns a &lt;code&gt;GrafanaAdmin&lt;/code&gt; role, Grafana Admin is not assigned by default, instead the &lt;code&gt;Admin&lt;/code&gt; role is assigned. To allow &lt;code&gt;Grafana Admin&lt;/code&gt; role to be assigned set &lt;code&gt;allow_assign_grafana_admin = true&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&#34;skip-organization-role-mapping&#34;&gt;Skip organization role mapping&lt;/h3&gt;
&lt;p&gt;To skip the assignment of roles and permissions upon login via JWT and handle them via other mechanisms like the user interface, we can skip the organization role synchronization with the following configuration.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;ini&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-ini&#34;&gt;[auth.jwt]
# ...

skip_org_role_sync = true&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="configure-jwt-authentication">Configure JWT authentication&lt;/h1>
&lt;p>You can configure Grafana to accept a JWT token provided in the HTTP header. The token is verified using any of the following:&lt;/p></description></item></channel></rss>