2022-05-26 10:06:25 -05:00
---
aliases:
2022-12-09 10:36:04 -06:00
- ../../../auth/okta/
2022-06-02 11:57:22 -05:00
description: Grafana Okta OAuth Guide
Explicitly set all front matter labels in the source files (#71548)
* Set every page to have defaults of 'Enterprise' and 'Open source' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration pages to have of 'Cloud', 'Enterprise', and 'Open source' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/enterprise-licensing pages to have 'Enterprise' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/organization-management pages to have 'Enterprise' and 'Open source' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/provisioning pages to have 'Enterprise' and 'Open source' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/recorded-queries pages to have labels cloud,enterprise
* Set administration/roles-and-permissions/access-control pages to have labels cloud,enterprise
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/stats-and-license pages to have labels cloud,enterprise
* Set alerting pages to have labels cloud,enterprise,oss
* Set breaking-changes pages to have labels cloud,enterprise,oss
* Set dashboards pages to have labels cloud,enterprise,oss
* Set datasources pages to have labels cloud,enterprise,oss
* Set explore pages to have labels cloud,enterprise,oss
* Set fundamentals pages to have labels cloud,enterprise,oss
* Set introduction/grafana-cloud pages to have labels cloud
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Fix introduction pages products
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set panels-visualizations pages to have labels cloud,enterprise,oss
* Set release-notes pages to have labels cloud,enterprise,oss
* Set search pages to have labels cloud,enterprise,oss
* Set setup-grafana/configure-security/audit-grafana pages to have labels cloud,enterprise
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set setup-grafana/configure-security/configure-authentication pages to have labels cloud,enterprise,oss
* Set setup-grafana/configure-security/configure-authentication/enhanced-ldap pages to have labels cloud,enterprise
* Set setup-grafana/configure-security/configure-authentication/saml pages to have labels cloud,enterprise
* Set setup-grafana/configure-security/configure-database-encryption/encrypt-secrets-using-hashicorp-key-vault pages to have labels cloud,enterprise
* Set setup-grafana/configure-security/configure-request-security pages to have labels cloud,enterprise,oss
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set setup-grafana/configure-security/configure-team-sync pages to have labels cloud,enterprise
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set setup-grafana/configure-security/export-logs pages to have labels cloud,enterprise
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set troubleshooting pages to have labels cloud,enterprise,oss
* Set whatsnew pages to have labels cloud,enterprise,oss
* Apply updated labels from review
Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com>
Co-authored-by: Isabel <76437239+imatwawana@users.noreply.github.com>
---------
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com>
Co-authored-by: Isabel <76437239+imatwawana@users.noreply.github.com>
2023-07-18 03:10:12 -05:00
labels:
products:
- cloud
- enterprise
- oss
2023-06-29 07:44:33 -05:00
menuTitle: Okta OAuth2
Explicitly set all front matter labels in the source files (#71548)
* Set every page to have defaults of 'Enterprise' and 'Open source' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration pages to have of 'Cloud', 'Enterprise', and 'Open source' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/enterprise-licensing pages to have 'Enterprise' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/organization-management pages to have 'Enterprise' and 'Open source' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/provisioning pages to have 'Enterprise' and 'Open source' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/recorded-queries pages to have labels cloud,enterprise
* Set administration/roles-and-permissions/access-control pages to have labels cloud,enterprise
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/stats-and-license pages to have labels cloud,enterprise
* Set alerting pages to have labels cloud,enterprise,oss
* Set breaking-changes pages to have labels cloud,enterprise,oss
* Set dashboards pages to have labels cloud,enterprise,oss
* Set datasources pages to have labels cloud,enterprise,oss
* Set explore pages to have labels cloud,enterprise,oss
* Set fundamentals pages to have labels cloud,enterprise,oss
* Set introduction/grafana-cloud pages to have labels cloud
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Fix introduction pages products
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set panels-visualizations pages to have labels cloud,enterprise,oss
* Set release-notes pages to have labels cloud,enterprise,oss
* Set search pages to have labels cloud,enterprise,oss
* Set setup-grafana/configure-security/audit-grafana pages to have labels cloud,enterprise
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set setup-grafana/configure-security/configure-authentication pages to have labels cloud,enterprise,oss
* Set setup-grafana/configure-security/configure-authentication/enhanced-ldap pages to have labels cloud,enterprise
* Set setup-grafana/configure-security/configure-authentication/saml pages to have labels cloud,enterprise
* Set setup-grafana/configure-security/configure-database-encryption/encrypt-secrets-using-hashicorp-key-vault pages to have labels cloud,enterprise
* Set setup-grafana/configure-security/configure-request-security pages to have labels cloud,enterprise,oss
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set setup-grafana/configure-security/configure-team-sync pages to have labels cloud,enterprise
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set setup-grafana/configure-security/export-logs pages to have labels cloud,enterprise
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set troubleshooting pages to have labels cloud,enterprise,oss
* Set whatsnew pages to have labels cloud,enterprise,oss
* Apply updated labels from review
Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com>
Co-authored-by: Isabel <76437239+imatwawana@users.noreply.github.com>
---------
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com>
Co-authored-by: Isabel <76437239+imatwawana@users.noreply.github.com>
2023-07-18 03:10:12 -05:00
title: Configure Okta OAuth2 authentication
2023-06-29 07:44:33 -05:00
weight: 1400
2022-05-26 10:06:25 -05:00
---
2020-04-02 09:35:48 -05:00
2022-06-02 11:57:22 -05:00
# Configure Okta OAuth2 authentication
2020-04-02 09:35:48 -05:00
> Only available in Grafana v7.0+
The Okta authentication allows your Grafana users to log in by using an external Okta authorization server.
## Create an Okta application
Before you can sign a user in, you need to create an Okta application from the Okta Developer Console.
1. Log in to the [Okta portal ](https://login.okta.com/ ).
1. Go to Admin and then select **Developer Console** .
1. Select **Applications** , then **Add Application** .
1. Pick **Web** as the platform.
1. Enter a name for your application (or leave the default value).
1. Add the **Base URI** of your application, such as https://grafana.example.com.
1. Enter values for the **Login redirect URI** . Use **Base URI** and append it with `/login/okta` , for example: https://grafana.example.com/login/okta.
1. Click **Done** to finish creating the Okta application.
2020-05-13 04:23:01 -05:00
## Enable Okta OAuth in Grafana
2020-04-02 09:35:48 -05:00
2023-05-18 09:50:20 -05:00
1. Add the following to the [Grafana configuration file ]({{< relref "../../../configure-grafana#configuration-file-location" >}} ):
2020-04-02 09:35:48 -05:00
```ini
[auth.okta]
name = Okta
2022-02-16 10:35:00 -06:00
icon = okta
2020-04-02 09:35:48 -05:00
enabled = true
allow_sign_up = true
client_id = some_id
client_secret = some_secret
scopes = openid profile email groups
auth_url = https://< tenant-id > .okta.com/oauth2/v1/authorize
token_url = https://< tenant-id > .okta.com/oauth2/v1/token
api_url = https://< tenant-id > .okta.com/oauth2/v1/userinfo
allowed_domains =
allowed_groups =
role_attribute_path =
2023-05-30 11:17:45 -05:00
use_pkce = true
2020-04-02 09:35:48 -05:00
```
2023-05-30 11:17:45 -05:00
### PKCE
IETF's [RFC 7636 ](https://datatracker.ietf.org/doc/html/rfc7636 )
introduces "proof key for code exchange" (PKCE) which provides
additional protection against some forms of authorization code
interception attacks. PKCE will be required in [OAuth 2.1 ](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-03 ).
> You can disable PKCE in Grafana by setting `use_pkce` to `false` in the`[auth.okta]` section.
2022-11-14 09:47:46 -06:00
### Configure refresh token
> Available in Grafana v9.3 and later versions.
> **Note:** This feature is behind the `accessTokenExpirationCheck` feature toggle.
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.
Grafana uses a refresh token to obtain a new access token without requiring the user to log in again. If a refresh token doesn't exist, Grafana logs the user out of the system after the access token has expired.
1. To enable the `Refresh Token` , grant type in the `General Settings` section.
2023-07-14 07:03:01 -05:00
1. Extend the `scopes` in `[auth.okta]` with `offline_access` for Grafana versions between v9.3 and v10.0.x.
1. Set `use_refresh_token` in `[auth.okta]` to `true` for Grafana versions v10.1.0 and later.
> **Note:** The `accessTokenExpirationCheck` feature toggle will be removed in Grafana v10.2.0 and the `use_refresh_token` configuration value will be used instead for configuring refresh token fetching and access token expiration check.
2022-11-14 09:47:46 -06:00
2020-04-02 09:35:48 -05:00
### Configure allowed groups and domains
To limit access to authenticated users that are members of one or more groups, set `allowed_groups`
to a comma- or space-separated list of Okta groups.
```ini
allowed_groups = Developers, Admins
```
The `allowed_domains` option limits access to the users belonging to the specific domains. Domains should be separated by space or comma.
```ini
allowed_domains = mycompany.com mycompany.org
```
2023-01-16 07:03:20 -06:00
To put values containing spaces in the list, use the following JSON syntax:
```ini
allowed_groups = ["Admins", "Software Engineers"]
```
2020-04-02 09:35:48 -05:00
### Map roles
Grafana can attempt to do role mapping through Okta OAuth. In order to achieve this, Grafana checks for the presence of a role using the [JMESPath ](http://jmespath.org/examples.html ) specified via the `role_attribute_path` configuration option.
2023-05-18 09:50:20 -05:00
Grafana uses JSON obtained from querying the `/userinfo` endpoint for the path lookup. The result after evaluating the `role_attribute_path` JMESPath expression needs to be a valid Grafana role, i.e. `Viewer` , `Editor` or `Admin` . For more information about roles and permissions in Grafana, refer to [Roles and permissions ]({{< relref "../../../../administration/roles-and-permissions" >}} ).
2020-04-02 09:35:48 -05:00
2023-05-22 15:45:28 -05:00
{{% admonition type="warning" %}}
Currently if no organization role mapping is found for a user, Grafana doesn't
update the user's organization role. This is going to change in Grafana 10. To avoid overriding manually set roles,
enable the `skip_org_role_sync` option.
See [Configure Grafana ]({{< relref "../../../configure-grafana#authokta" >}} ) for more information.
{{% /admonition %}}
2022-09-15 10:35:59 -05:00
On first login, if the`role_attribute_path` property does not return a role, then the user is assigned the role
2022-10-17 15:24:33 -05:00
specified by [the `auto_assign_org_role` option ]({{< relref "../../../configure-grafana#auto_assign_org_role" >}} ).
2022-09-15 10:35:59 -05:00
You can disable this default role assignment by setting `role_attribute_strict = true` .
It denies user access if no role or an invalid role is returned.
2023-05-22 15:45:28 -05:00
{{% admonition type="warning" %}}
With Grafana 10, **on every login** , if the`role_attribute_path` property does not return a role,
then the user is assigned the role specified by
[the `auto_assign_org_role` option ]({{< relref "../../../configure-grafana#auto_assign_org_role" >}} ).
{{% /admonition %}}
2022-09-15 10:35:59 -05:00
2023-07-10 08:00:05 -05:00
Read about how to [add custom claims ](https://developer.okta.com/docs/guides/customize-tokens-returned-from-okta/add-custom-claim/ ) to the user info in Okta. Also, check Generic OAuth page for [Role mapping examples ]({{< relref "../generic-oauth#role-mapping-examples" >}} ) with JMESPath.
2020-04-02 09:35:48 -05:00
2022-09-08 05:11:00 -05:00
#### Map server administrator privileges
> Available in Grafana v9.2 and later versions.
2023-05-18 09:50:20 -05:00
If the application role received by Grafana is `GrafanaAdmin` , Grafana grants the user server administrator privileges.
This is useful if you want to grant server administrator privileges to a subset of users.
2022-09-08 05:11:00 -05:00
Grafana also assigns the user the `Admin` role of the default organization.
2023-05-18 09:50:20 -05:00
The setting `allow_assign_grafana_admin` under `[auth.okta]` must be set to `true` for this to work.
2022-09-08 05:11:00 -05:00
If the setting is set to `false` , the user is assigned the role of `Admin` of the default organization, but not server administrator privileges.
```ini
allow_assign_grafana_admin = true
```
Example:
```ini
role_attribute_path = contains(groups[*], 'admin') & & 'GrafanaAdmin' || contains(groups[*], 'editor') & & 'Editor' || 'Viewer'
```
2023-01-30 04:54:14 -06:00
## Skip organization role sync
To prevent the sync of org roles from Okta, set `skip_org_role_sync` to `true` . This is useful if you want to manage the organization roles for your users from within Grafana.
```ini
[auth.okta]
# ..
# prevents the sync of org roles from Okta
skip_org_role_sync = true
```
2020-04-02 09:35:48 -05:00
### Team Sync (Enterprise only)
Map your Okta groups to teams in Grafana so that your users will automatically be added to
the correct teams.
Okta groups can be referenced by group name, like `Admins` .
2023-05-18 09:50:20 -05:00
[Learn more about Team Sync ]({{< relref "../../configure-team-sync" >}} )