Spark authentication
The Spark connector authenticates to the Gravitino server with the setting
spark.sql.gravitino.authType. The Datastrato Enterprise server accepts Basic and OAuth, so those are
the two modes covered here. The connector's default, simple, sends a user name with no password,
which the server does not accept.
Quick start
The example signs the connector in to a server that uses OAuth, with a client registered at the
identity provider the server trusts. The connector requests a token with the client credentials
grant, sending it to serverUri joined with tokenPath.
-
Add the OAuth settings to the Spark configuration, next to the connector settings from the Spark connector Quick start.
spark-defaults.confspark.plugins=org.apache.gravitino.spark.connector.plugin.GravitinoSparkPlugin
spark.sql.gravitino.uri=https://{gravitino_host}
spark.sql.gravitino.metalake={metalake}
spark.sql.gravitino.authType=oauth2
spark.sql.gravitino.oauth2.serverUri=https://{idp_host}
spark.sql.gravitino.oauth2.tokenPath={token_path}
spark.sql.gravitino.oauth2.credential={client_id}:{client_secret}
spark.sql.gravitino.oauth2.scope={scope} -
Start Spark SQL and use a catalog. A failed sign-in stops the session at startup.
Confirm the connector is signed inUSE {catalog};
SHOW DATABASES;
Basic mode
Basic mode sends a user name and password from the server's local user store. The server must have Basic authentication enabled; see How to authenticate.
| Property | Type | Default | Description | Required |
|---|---|---|---|---|
spark.sql.gravitino.authType | string | simple | basic | Yes |
spark.sql.gravitino.basic.username | string | (none) | User name in the local user store | Yes, for Basic |
spark.sql.gravitino.basic.password | string | (none) | Password for that user | Yes, for Basic |
spark.plugins=org.apache.gravitino.spark.connector.plugin.GravitinoSparkPlugin
spark.sql.gravitino.uri=https://{gravitino_host}
spark.sql.gravitino.metalake={metalake}
spark.sql.gravitino.authType=basic
spark.sql.gravitino.basic.username={username}
spark.sql.gravitino.basic.password={password}
OAuth mode
OAuth mode requests an access token from the identity provider with the client credentials grant. The Quick start shows a complete configuration.
| Property | Type | Default | Description | Required |
|---|---|---|---|---|
spark.sql.gravitino.authType | string | simple | oauth2 | Yes |
spark.sql.gravitino.oauth2.serverUri | string | (none) | Base address of the identity provider | Yes, for OAuth |
spark.sql.gravitino.oauth2.tokenPath | string | (none) | Token endpoint path, joined to serverUri | Yes, for OAuth |
spark.sql.gravitino.oauth2.credential | string | (none) | Client credentials as {client_id}:{client_secret} | Yes, for OAuth |
spark.sql.gravitino.oauth2.scope | string | (none) | Scope to request with the token | Yes, for OAuth |