docs/docs/enterprise/sso/config.mdx
import Thumbnail from '@site/src/components/Thumbnail';
admin or equivalent role.Create a new service provider on your identity provider with the following configuration:
http(s)://<hasura-domain>/console/oauth2/callback."x-hasura-allowed-roles": ["admin"] and "x-hasura-default-role": "admin" into the JWT custom claims. The JWT
payload should follow the Hasura JWT spec.Once created, note the client ID, login URL, request token URL, and JWT secret.
Set the --sso-providers argument
(HASURA_GRAPHQL_SSO_PROVIDERS) which takes a list of SSO provider objects.
[
{
"client_id": "<client-id-from-idp>",
"name": "<display-name>",
"scope": "openid",
"authorization_url": "<login-url>",
"request_token_url": "<request-token-url>",
"admin_roles": ["admin"],
"jwt_secret": {
"type": "RS256",
"jwk_url": "https://...",
"issuer": "myapp"
}
}
]
client_id: Client ID of the identity application.name: Display name of the SSO button in the login page of the Hasura Console.scope: The OAuth scope. It must contain openid so the identity provider can return the JWT id_token from the
request token endpoint.authorization_url: The authorization URL that the browser redirects to from the Console.request_token_url: URL the Console uses to get the ID token using the authorization code.admin_roles: By default, the role should be admin in the token issued by IdP so that Console access is provided.
But, if you have a configuration where the admin role is used for something else, set this key to indicate which
roles should be treated as admin. This is an array of strings.jwt_secret: JWT secret the server uses to verify the JWT signature. It follows the
JWT secret configuration.You can use any OpenID Connect compliant middleware service such as Dex that acts as a portal to other identity providers. Hasura talks to the middleware to authorize and verify signatures without caring about how the middleware handles external providers. Dex supports SAML 2.0, LDAP protocols, as well as identity providers like GitHub, Google, and Active Directory.
The authorization flow is similar to the OAuth / OpenID Connect flow, with an extra step to authenticate the IdP through middleware.
<Thumbnail src="/img/enterprise/sso-auth-flow-middleware.png" alt="SSO middleware authentication flow" />Create a new service provider on your SAML identity provider with the following configuration:
http(s)://<dex-url>/callback.Create a config file with a static client and a SAML connector.
# The default Dex base URL is http://localhost:5556/dex
# However the /dex path is removed in the helm chart
issuer: http(s)://<dex-url>
storage:
type: memory
# Configuration for the HTTP endpoints.
web:
http: 0.0.0.0:5556
allowedOrigins: ['*']
staticClients:
- id: hasura-app
redirectURIs:
- 'http(s)://<hasura-url>/console/oauth2/callback'
name: 'Hasura App'
public: true
connectors:
- type: saml
id: saml
name: SAML
config:
ssoURL: <SAML sign-on endpoint>
# CA to use when validating the signature of the SAML response.
ca: /path/to/saml-ca.pem
# CA's can also be provided inline as a base64'd blob.
#
# caData: ( RAW base64'd PEM encoded CA )
# To skip signature validation, uncomment the following field. This should
# only be used during testing and may be removed in the future.
#
# insecureSkipSignatureValidation: true
redirectURI: http(s)://<dex-url>/callback
# Name of attributes in the returned assertions to map to ID token claims.
usernameAttr: name
emailAttr: email
# groups are required to be mapped with x-hasura-allowed-roles
groupsAttr: groups
# Optional: Manually specify dex's Issuer value.
#
# When provided dex will include this as the Issuer value during AuthnRequest.
# It will also override the redirectURI as the required audience when evaluating
# AudienceRestriction elements in the response.
entityIssuer: http(s)://<dex-url>/callback
# Optional: Issuer value expected in the SAML response.
# ssoIssuer: https://login.microsoftonline.com/4bc01d1d-5a16-4d79-b651-5a5b592aeb57/v2.0
Set the environment variable HASURA_GRAPHQL_SSO_PROVIDERS to talk to Dex.
[
{
"client_id": "hasura-app",
"name": "SAML Login",
"scope": "openid offline_access groups",
"authorization_url": "http(s)://<dex-url>/auth",
"request_token_url": "http(s)://<dex-url>/token",
"admin_roles": ["admin"],
"jwt_secret": {
"type": "RS256",
"jwk_url": "http(s)://<dex-url>/keys",
"issuer": "http(s)://<dex-url>",
"claims_map": {
"x-hasura-allowed-roles": { "path": "$.groups" },
"x-hasura-default-role": { "path": "$.groups[0]" }
}
}
}
]
The groups scope is required to enable the groups field in the JWT claims. You also need to set the claims_map to
map the groups field to x-hasura-allowed-roles and x-hasura-default-role.