<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Vertica Documentation – OAuth 2.0 authentication</title>
    <link>/en/security-and-authentication/client-authentication/oauth-2-0-authentication/</link>
    <description>Recent content in OAuth 2.0 authentication on Vertica Documentation</description>
    <generator>Hugo -- gohugo.io</generator>
    
	  <atom:link href="/en/security-and-authentication/client-authentication/oauth-2-0-authentication/index.xml" rel="self" type="application/rss+xml" />
    
    
      
        
      
    
    
    <item>
      <title>Security-and-Authentication: Configuring OAuth authentication</title>
      <link>/en/security-and-authentication/client-authentication/oauth-2-0-authentication/configuring-oauth-authentication/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/security-and-authentication/client-authentication/oauth-2-0-authentication/configuring-oauth-authentication/</guid>
      <description>
        
        
        &lt;p&gt;For a list of ODBC OAuth connection properties, see &lt;a href=&#34;../../../../en/connecting-to/client-libraries/client-drivers/install-config/odbc/creating-an-odbc-data-source-name-dsn/odbc-dsn-connection-properties/&#34;&gt;ODBC DSN connection properties&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The following procedure:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Configures Keycloak 18.0.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Creates an OAuth authentication record.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Retrieves an access token with a POST request.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Uses a sample application &lt;a href=&#34;https://github.com/vertica/client-application-examples/tree/main/&#34;&gt;sample application&lt;/a&gt; to authenticate to Vertica, passing the access token as an argument and, optionally, parameters for token refresh.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;configuring-keycloak&#34;&gt;Configuring keycloak&lt;/h2&gt;
&lt;p&gt;The following procedure configures a Keycloak 18.0.0 server on 203.0.113.1.&lt;/p&gt;
&lt;h3 id=&#34;using-tls-optional&#34;&gt;Using TLS (optional)&lt;/h3&gt;
&lt;p&gt;If you want to use TLS, you must obtain a certificate and key for Keycloak signed by a trusted CA. This example uses a self-signed CA for convenience.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&#34;../../../../en/security-and-authentication/tls-protocol/tls-overview/generating-tls-certificates-and-keys/&#34;&gt;Generate&lt;/a&gt; the CA certificate:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE KEY SSCA_key TYPE &amp;#39;RSA&amp;#39; LENGTH 2048;
CREATE KEY

=&amp;gt; CREATE CA CERTIFICATE SSCA_cert
SUBJECT &amp;#39;/C=US/ST=Massachusetts/L=Cambridge/O=Micro Focus/OU=Vertica/C N=Vertica Root CA&amp;#39;
VALID FOR 3650
EXTENSIONS &amp;#39;nsComment&amp;#39; = &amp;#39;Self-signed root CA cert&amp;#39;
KEY SSCA_key;
CREATE CERTIFICATE
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Generate a server key and certificate, signed by your CA, setting the &lt;strong&gt;subjectAltName&lt;/strong&gt; of the certificate to the DNS server and/or IP address of your Keycloak server:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE KEY keycloak_key TYPE &amp;#39;RSA&amp;#39; LENGTH 2048;
CREATE KEY

=&amp;gt; CREATE CERTIFICATE keycloak_cert
SUBJECT &amp;#39;/C=US/ST=Massachussets/L=Cambridge/O=Micro Focus/OU=Vertica/CN=Vertica Server&amp;#39;
SIGNED BY SSCA_cert
EXTENSIONS &amp;#39;nsComment&amp;#39; = &amp;#39;Keycloak CA&amp;#39;, &amp;#39;extendedKeyUsage&amp;#39; = &amp;#39;serverAuth&amp;#39;, &lt;span class=&#34;code-input&#34;&gt;&#39;subjectAltName&#39; = &#39;DNS.1:dnsserver,IP:203.0.113.1&#39;&lt;/span&gt;
KEY keycloak_key;
CREATE CERTIFICATE
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Create the file &lt;em&gt;&lt;code&gt;keycloak_directory&lt;/code&gt;&lt;/em&gt;&lt;code&gt;/conf/keyfile.pem&lt;/code&gt; with the content from the &lt;code&gt;key&lt;/code&gt; column for the generated key:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT key FROM cryptographic_keys WHERE name = &amp;#39;keycloak_key&amp;#39;;
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Create the file &lt;em&gt;&lt;code&gt;keycloak_directory&lt;/code&gt;&lt;/em&gt;&lt;code&gt;/conf/certfile.pem&lt;/code&gt; with the content from the &lt;code&gt;certificate_text&lt;/code&gt; column for the generated certificate:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT certificate_text FROM certificates WHERE name = &amp;#39;keycloak_cert&amp;#39;;
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Append to your system&#39;s CA bundle the content from the &lt;code&gt;certificate_text&lt;/code&gt; column for the generated CA certificate. The default CA bundle path and format varies between distributions; for details, see &lt;a href=&#34;../../../../en/sql-reference/config-parameters/security-parameters/&#34;&gt;SystemCABundlePath&lt;/a&gt;:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT certificate_text FROM certificates WHERE name = &amp;#39;SSCA_cert&amp;#39;;
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Set the &lt;a href=&#34;../../../../en/sql-reference/config-parameters/security-parameters/&#34;&gt;SystemCABundlePath&lt;/a&gt; configuration parameter:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; ALTER DATABASE DEFAULT SET SystemCABundlePath = &amp;#39;path/to/ca_bundle&amp;#39;;
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;starting-keycloak&#34;&gt;Starting keycloak&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Enter the following commands for a minimal configuration to create the Keycloak admin and to start Keycloak in start-dev mode:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;$ KEYCLOAK_ADMIN=kcadmin
$ export KEYCLOAK_ADMIN
$ KEYCLOAK_ADMIN_PASSWORD=password
$ export KEYCLOAK_ADMIN_PASSWORD
$ cd &lt;span class=&#34;code-variable&#34;&gt;keycloak_directory&lt;/span&gt;/bin/
$ ./kc.sh start-dev --hostname &lt;span class=&#34;code-input&#34;&gt;203.0.113.1&lt;/span&gt; --https-certificate-file ../conf/certfile.pem --https-certificate-key-file=../conf/keyfile.pem
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Open the Keycloak console with your browser (these examples use the default ports):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;For HTTP: http://203.0.113.1:8080&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;For HTTPS: http://203.0.113.1:8443&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Sign in as the admin.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;(Optional) To make testing OAuth more convenient, navigate to &lt;strong&gt;Realm Settings&lt;/strong&gt; &amp;gt; &lt;strong&gt;Tokens&lt;/strong&gt; and increase &lt;strong&gt;Access Token Lifespan&lt;/strong&gt; to a greater value (the default is 5 minutes).&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;creating-the-vertica-client&#34;&gt;Creating the Vertica client&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Navigate to &lt;strong&gt;Clients&lt;/strong&gt; and click on &lt;strong&gt;Create&lt;/strong&gt;. The &lt;strong&gt;Add Client&lt;/strong&gt; page appears.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;In &lt;strong&gt;Client ID&lt;/strong&gt;, enter 
&lt;code&gt;vertica&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Save&lt;/strong&gt;. The client configuration page appears.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;In the &lt;strong&gt;Settings&lt;/strong&gt; tab, use the &lt;strong&gt;Access Type&lt;/strong&gt; dropdown to select &lt;strong&gt;confidential&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;In the &lt;strong&gt;Credentials&lt;/strong&gt; tab, make a note of the &lt;strong&gt;Secret&lt;/strong&gt;. This is the client secret used to refresh the token when it expires.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;creating-a-keycloak-user&#34;&gt;Creating a keycloak user&lt;/h3&gt;
&lt;p&gt;Keycloak users map to Vertica users with the same name. This example creates a the Keycloak user &lt;code&gt;oauth_user&lt;/code&gt;.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;In the &lt;strong&gt;Users&lt;/strong&gt; tab, click &lt;strong&gt;Add user&lt;/strong&gt;. The &lt;strong&gt;Add user&lt;/strong&gt; page appears.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;In &lt;strong&gt;Username&lt;/strong&gt;, enter &lt;code&gt;oauth_user&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;In the &lt;strong&gt;Credentials&lt;/strong&gt; tab, enter a password.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;configuring-vertica&#34;&gt;Configuring Vertica&lt;/h2&gt;
&lt;h3 id=&#34;creating-the-authentication-record&#34;&gt;Creating the authentication record&lt;/h3&gt;
&lt;p&gt;Create an authentication record for OAuth.&lt;/p&gt;
&lt;p&gt;The following &lt;a href=&#34;../../../../en/sql-reference/statements/alter-statements/alter-authentication/&#34;&gt;authentication record&lt;/a&gt; &lt;code&gt;v_oauth&lt;/code&gt; authenticates users from any IP address by contacting the identity provider (Keycloak 18.0.0) to validate the OAuth token (rather than a username and password) and uses the following parameters:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;validate_type&lt;/code&gt;: The method used to validate the OAuth token. This should be set to &lt;code&gt;IDP&lt;/code&gt; (default) to validate the OAuth token by contacting the identity provider.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;client_id&lt;/code&gt;: The confidential client, 
&lt;code&gt;vertica&lt;/code&gt;, registered in Keycloak.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;client_secret&lt;/code&gt;: The client secret, generated by Keycloak.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;discovery_url&lt;/code&gt;: Also known as the &lt;a href=&#34;https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderConfigurationRequest&#34;&gt;OpenID Provider Configuration Document&lt;/a&gt;, Vertica uses this endpoint to retrieve information about the identity provider&#39;s configuration and other endpoints.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;introspect_url&lt;/code&gt;: Used by Vertica to introspect (validate) access tokens. You must specify the &lt;code&gt;introspect_url&lt;/code&gt; if you do not specify the &lt;code&gt;discovery_url&lt;/code&gt; and are not using JSON Web Token validation.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If &lt;code&gt;discovery_url&lt;/code&gt; and &lt;code&gt;introspect_url&lt;/code&gt; are both set, &lt;code&gt;discovery_url&lt;/code&gt; takes precedence. The following example sets both for demonstration purposes; in general, you should prefer to set the &lt;code&gt;discovery_url&lt;/code&gt;:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE AUTHENTICATION v_oauth METHOD &amp;#39;oauth&amp;#39; HOST &amp;#39;0.0.0.0/0&amp;#39;;
=&amp;gt; ALTER AUTHENTICATION v_oauth SET validate_type = &amp;#39;IDP&amp;#39;;
=&amp;gt; ALTER AUTHENTICATION v_oauth SET client_id = &amp;#39;vertica&amp;#39;;
=&amp;gt; ALTER AUTHENTICATION v_oauth SET client_secret = &amp;#39;&lt;span class=&#34;code-variable&#34;&gt;client_secret&lt;/span&gt;&amp;#39;;
=&amp;gt; ALTER AUTHENTICATION v_oauth SET discovery_url = &amp;#39;https://203.0.113.1:8443/realms/myrealm/.well-known/openid-configuration&amp;#39;;
=&amp;gt; ALTER AUTHENTICATION v_oauth SET introspect_url = &amp;#39;https://203.0.113.1:8443/realms/myrealm/protocol/openid-connect/token/introspect&amp;#39;;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Alternatively, if your identity provider supports the OpenID Connect protocol, Vertica can validate OAuth tokens by verifying that it was signed by the identity provider&#39;s private key. This is useful if you do not want the database to contact the identity provider to validate every token.&lt;/p&gt;
&lt;p&gt;JWT validation requires the following parameters:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;validate_type&lt;/code&gt;: The validation method, &lt;code&gt;IDP&lt;/code&gt; by default. Setting this to &lt;code&gt;JWT&lt;/code&gt; enables JWT validation.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;jwt_rsa_public_key&lt;/code&gt;: In PEM format, the public key used to sign the client&#39;s OAuth token. Vertica uses this to validate the OAuth token.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;jwt_issuer&lt;/code&gt;: The issuer of the OAuth token. For Keycloak, this is the token endpoint.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;jwt_user_mapping&lt;/code&gt;: The name of the Vertica user.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You can also specify the following parameters to define a whitelist based on fields of the OAuth token:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;jwt_accepted_audience_list&lt;/code&gt;: Optional, a comma-delimited list of values to accept from the client JWT&#39;s &lt;code&gt;aud&lt;/code&gt; field. If set, tokens must include in &lt;code&gt;aud&lt;/code&gt; one of the accepted audiences to authenticate.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;jwt_accepted_scope_list&lt;/code&gt;: Optional, a comma-delimited list of values to accept from the client JWT&#39;s &lt;code&gt;scope&lt;/code&gt; field. If set, tokens must include in &lt;code&gt;scope&lt;/code&gt; at least one of the accepted scopes to authenticate.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The following &lt;a href=&#34;../../../../en/sql-reference/statements/alter-statements/alter-authentication/&#34;&gt;authentication record&lt;/a&gt; &lt;code&gt;v_oauth_jwt&lt;/code&gt; authenticates users from any IP address by verifying that the client&#39;s OAuth token was signed by the identity provider&#39;s private key. It also requires the user to provide the proper values in the token&#39;s &lt;code&gt;aud&lt;/code&gt; and &lt;code&gt;scope&lt;/code&gt; fields:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE AUTHENTICATION v_oauth_jwt METHOD &amp;#39;oauth&amp;#39; HOST &amp;#39;0.0.0.0/0&amp;#39;;
=&amp;gt; ALTER AUTHENTICATION v_oauth_jwt SET validate_type = &amp;#39;JWT&amp;#39;;
=&amp;gt; ALTER AUTHENTICATION v_oauth_jwt SET jwt_rsa_public_key = &amp;#39;MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAkjXjd6F8PyKkQtY5q2cJ9jNT9y+PeIJS134UvuUnuD9bQFhkBPstTBulpZV1QQivYaQ5k5bYVE2Q7n/XscrWzbRkK/qEwmztjVUH7dQAHSSKEjYcbH1fREx5nR5oNEelrUH2RrGM98Y7ln+Ch4oCl8yCS6gjI6hfaDxwqo2oImmGE+Qi06SIjoWGBCr5EIAhvlNuWe2rWD5uEe4ivaL6KoAR9sADqhGBoaYs/wIVUcv5DHtSjU+yZIz/sVspJehvmb/979eDsct2IddCHLrjUet3DiKz4imIyh+cv9VTEI6MWbk5WIiKW2fFzZ6Oei/ddzmTqVoNdn+d18tWwlf7hQIDAQAB&amp;#39;;
=&amp;gt; ALTER AUTHENTICATION v_oauth_jwt SET jwt_issuer = &amp;#39;https://203.0.113.1:8443/realms/myrealm/protocol/openid-connect/token&amp;#39;;
=&amp;gt; ALTER AUTHENTICATION v_oauth_jwt SET jwt_user_mapping = &amp;#39;oauth_user&amp;#39;;
=&amp;gt; ALTER AUTHENTICATION v_oauth_jwt SET jwt_accepted_audience_list = &amp;#39;vertica,local&amp;#39;;
=&amp;gt; ALTER AUTHENTICATION v_oauth_jwt SET jwt_accepted_scope_list = &amp;#39;email,profile,user&amp;#39;;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;For a full list of OAuth authentication parameters, see &lt;a href=&#34;../../../../en/security-and-authentication/client-authentication/oauth-2-0-authentication/oauth-authentication-parameters/&#34;&gt;OAuth authentication parameters&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;creating-a-vertica-user&#34;&gt;Creating a Vertica user&lt;/h3&gt;
&lt;p&gt;Vertica users map to Keycloak users with the same username. You can either create the user manually or enable &lt;a href=&#34;../../../../en/security-and-authentication/client-authentication/oauth-2-0-authentication/just-time-user-provisioning/&#34;&gt;just-in-time (JIT) user provisioning&lt;/a&gt; in the authentication record to automatically create users with valid tokens.&lt;/p&gt;
&lt;p&gt;To manually create the user:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;To map to the Keycloak user &lt;code&gt;oauth_user&lt;/code&gt;, &lt;a href=&#34;../../../../en/sql-reference/statements/create-statements/create-user/&#34;&gt;create&lt;/a&gt; a Vertica user with the same name. You do not need to specify a password because authentication is performed by the identity provider:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE USER oauth_user;
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Grant the OAuth authentication record to the user (or their role):&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; GRANT AUTHENTICATION v_oauth TO oauth_user;
=&amp;gt; GRANT ALL ON SCHEMA PUBLIC TO oauth_user;
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;To enable JIT user provisioning (Keycloak only):&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; ALTER AUTHENTICATION v_oauth SET oauth2_jit_enabled = &amp;#39;yes&amp;#39;;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;If the user already exists and JIT user provisioning is enabled, Vertica automatically assigns the roles associated with the user as specified by the identity provider if the roles also exist in Vertica. For details, see &lt;a href=&#34;../../../../en/security-and-authentication/client-authentication/oauth-2-0-authentication/just-time-user-provisioning/&#34;&gt;Just-in-time user provisioning&lt;/a&gt;
.&lt;/p&gt;
&lt;h2 id=&#34;retrieving-an-access-token&#34;&gt;Retrieving an access token&lt;/h2&gt;
&lt;p&gt;The simple way to get an OAuth access token is to send a POST request to the token endpoint, providing the credentials of the Keycloak user. For example, &lt;code&gt;oauth_user&lt;/code&gt;:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;$ curl --location --request POST &amp;#39;http://203.0.113.1:8080/realms/master/protocol/openid-connect/token&amp;#39; \
--header &amp;#39;Content-Type: application/x-www-form-urlencoded&amp;#39; \
--data-urlencode &amp;#39;username=oauth_user&amp;#39; \
--data-urlencode &amp;#39;password=&lt;span class=&#34;code-variable&#34;&gt;oauth_user_password&lt;/span&gt;&amp;#39; \
--data-urlencode &amp;#39;client_id=vertica&amp;#39; \
--data-urlencode &amp;#39;client_secret=&lt;span class=&#34;code-variable&#34;&gt;client_secret&lt;/span&gt;&amp;#39; \
--data-urlencode &amp;#39;grant_type=password&amp;#39;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Keycloak responds with a JSON string if you authenticated correctly. You can then use the returned access token, refresh token, and scope with the corresponding connection properties.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;{
   &amp;#34;access_token&amp;#34;:&amp;#34;&lt;span class=&#34;code-variable&#34;&gt;access_token&lt;/span&gt;&amp;#34;,
   &amp;#34;expires_in&amp;#34;:60,
   &amp;#34;refresh_expires_in&amp;#34;:1800,
   &amp;#34;refresh_token&amp;#34;:&amp;#34;&lt;span class=&#34;code-variable&#34;&gt;refresh_token&lt;/span&gt;&amp;#34;,
   &amp;#34;token_type&amp;#34;:&amp;#34;Bearer&amp;#34;,
   &amp;#34;not-before-policy&amp;#34;:0,
   &amp;#34;session_state&amp;#34;:&amp;#34;6745892a-aa74-452f-b6b9-c45637193859&amp;#34;,
   &amp;#34;scope&amp;#34;:&amp;#34;profile email&amp;#34;
}
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;running-the-sample-applications&#34;&gt;Running the sample applications&lt;/h2&gt;
&lt;p&gt;The OAuth sample applications, at a minimum, take an access token as an argument to authenticate to the database until the token expires. If you want the sample application to refresh the token after it expires, you must specify the following. The sample applications put these into a &lt;code&gt;JSON&lt;/code&gt; string, OAuthJsonConfig or (&lt;a href=&#34;../../../../en/connecting-to/client-libraries/client-drivers/install-config/odbc/creating-an-odbc-data-source-name-dsn/odbc-dsn-connection-properties/&#34;&gt;ODBC&lt;/a&gt;) oauthjsonconfig (&lt;a href=&#34;../../../../en/connecting-to/client-libraries/accessing/java/creating-and-configuring-connection/jdbc-connection-properties/&#34;&gt;JDBC&lt;/a&gt;).&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Refresh token&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Client ID&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Client secret&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Token URL&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;odbc&#34;&gt;ODBC&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Follow the instructions in the &lt;a href=&#34;https://github.com/vertica/client-application-examples/tree/main/ODBC&#34;&gt;README&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&#34;https://github.com/vertica/client-application-examples/tree/main/ODBC&#34;&gt;Run the sample application&lt;/a&gt;, passing the OAuth parameters as arguments:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;To authenticate until the token expires:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;$ ./a.out --access-token &lt;span class=&#34;code-variable&#34;&gt;OAuthAccessToken&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;To authenticate and silently refresh the access token when it expires:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;$ ./a.out --access-token &lt;span class=&#34;code-variable&#34;&gt;OAuthAccessToken&lt;/span&gt;
    --refresh-token &lt;span class=&#34;code-variable&#34;&gt;OAuthRefreshToken&lt;/span&gt;
    --client-id &lt;span class=&#34;code-variable&#34;&gt;OAuthClientID&lt;/span&gt;
    --client-secret &lt;span class=&#34;code-variable&#34;&gt;OAuthClientSecret&lt;/span&gt;
    --token-url &lt;span class=&#34;code-variable&#34;&gt;OAuthTokenURL&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;For a list of all ODBC OAuth parameters, see &lt;a href=&#34;../../../../en/connecting-to/client-libraries/client-drivers/install-config/odbc/creating-an-odbc-data-source-name-dsn/odbc-dsn-connection-properties/&#34;&gt;ODBC DSN connection properties&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;jdbc&#34;&gt;JDBC&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Follow the instructions in the &lt;a href=&#34;https://github.com/vertica/client-application-examples/tree/main/JDBC&#34;&gt;README&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&#34;https://github.com/vertica/client-application-examples/tree/main/JDBC&#34;&gt;Run the sample application&lt;/a&gt;, passing the OAuth parameters as arguments:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;To authenticate until the token expires:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;$ mvn compile exec:java -Dexec.mainClass=OAuthSampleApp -Dexec.args=&amp;#34;&lt;span class=&#34;code-variable&#34;&gt;vertica_host&lt;/span&gt; &lt;span class=&#34;code-variable&#34;&gt;database_name&lt;/span&gt; --access-token &lt;span class=&#34;code-variable&#34;&gt;oauthaccesstoken&lt;/span&gt;&amp;#34;
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;To authenticate and silently refresh the access token when it expires:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;$ mvn compile exec:java -Dexec.mainClass=OAuthSampleApp -Dexec.args=&amp;#34;&lt;span class=&#34;code-variable&#34;&gt;vertica_host&lt;/span&gt; &lt;span class=&#34;code-variable&#34;&gt;database_name&lt;/span&gt; --access-token &lt;span class=&#34;code-variable&#34;&gt;oauthaccesstoken&lt;/span&gt;
    --refresh_token &lt;span class=&#34;code-variable&#34;&gt;oauthrefreshtoken&lt;/span&gt;
    --client-id &lt;span class=&#34;code-variable&#34;&gt;oauthclientid&lt;/span&gt;
    --client-secret &lt;span class=&#34;code-variable&#34;&gt;oauthclientsecret&lt;/span&gt;
    --token-url &lt;span class=&#34;code-variable&#34;&gt;oauthtokenurl&lt;/span&gt;&amp;#34;
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;For a list of all JDBC OAuth parameters, see &lt;a href=&#34;../../../../en/connecting-to/client-libraries/accessing/java/creating-and-configuring-connection/jdbc-connection-properties/&#34;&gt;JDBC connection properties&lt;/a&gt;.&lt;/p&gt;
&lt;h4 id=&#34;troubleshooting&#34;&gt;Troubleshooting&lt;/h4&gt;
&lt;p&gt;To get debugging information for TLS, use the &lt;code&gt;-Djavax.net.debug=ssl&lt;/code&gt; flag.&lt;/p&gt;
&lt;h4 id=&#34;custom-ca-certificates&#34;&gt;Custom CA certificates&lt;/h4&gt;
&lt;p&gt;A truststore is a container for trusted certificate authority (CA) certificates. These CA certificates are used to verify the identities of other systems when establishing a TLS connection. When your JDBC client connects to the identity provider through an HTTPS endpoint, the JDBC client verifies the identity provider&#39;s certificate by making sure that it was issued by a CA in the truststore.&lt;/p&gt;
&lt;p&gt;If you configure your identity provider with TLS (that is, if you use HTTPS endpoints for your token or refresh URLs) and its certificate is not issued by a well-known CA, you must either specify a custom truststore or import the issuer&#39;s CA certificate into the system truststore with &lt;a href=&#34;https://docs.oracle.com/javase/8/docs/technotes/tools/unix/keytool.html&#34;&gt;&lt;code&gt;keytool&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;To specify a custom truststore, set the JDBC connection properties &lt;code&gt;oauthtruststorepath&lt;/code&gt; and &lt;code&gt;oauthtruststorepassword&lt;/code&gt;:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;connProps = new Properties(connProps);
connProps.setProperty(&amp;#34;oauthtruststorepath&amp;#34;, &amp;#34;/path/to/truststore/customoauth.truststore&amp;#34;);
connProps.setProperty(&amp;#34;oauthtruststorepassword&amp;#34;, &amp;#34;password&amp;#34;);
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;To add the certificate &lt;code&gt;keycloak/cert.crt&lt;/code&gt; to the Java truststore:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;$ keytool -trustcacerts -keystore /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.261-2.6.22.2.el7_8.x86_64/jre/lib/security/cacerts -storepass changeit -importcert -alias keycloak -file /keycloak/cert.crt
&lt;/code&gt;&lt;/pre&gt;
      </description>
    </item>
    
    <item>
      <title>Security-and-Authentication: Just-in-time user provisioning</title>
      <link>/en/security-and-authentication/client-authentication/oauth-2-0-authentication/just-time-user-provisioning/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/security-and-authentication/client-authentication/oauth-2-0-authentication/just-time-user-provisioning/</guid>
      <description>
        
        
        
&lt;div class=&#34;alert admonition note&#34; role=&#34;alert&#34;&gt;
&lt;h4 class=&#34;admonition-head&#34;&gt;Note&lt;/h4&gt;

To use this feature, you must use Keycloak as your identity provider.

&lt;/div&gt;
&lt;p&gt;Just-in-time (JIT) user provisioning is the act of automatically configuring an authenticated user and their roles based on information provided by the identity provider. When a client &lt;a href=&#34;../../../../en/security-and-authentication/client-authentication/&#34;&gt;authenticates&lt;/a&gt; to Vertica with an OAuth token the &lt;a href=&#34;../../../../en/sql-reference/statements/create-statements/create-authentication/&#34;&gt;authentication record&lt;/a&gt; enables JIT user provisioning, Vertica automatically performs the following actions:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;
Creates the user if they do not already exist in the database. The length of the username in the identity provider cannot be greater than 128 characters.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;
Grants to the user and sets as 
default the roles associated with the user (as specified by the identity provider), provided the roles already exist in Vertica.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;
Grants to the user the authentication record used to authenticate them if neither their user nor role has a grant on that record.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For example, if a client presents an OAuth token to authenticate as user &lt;code&gt;Alice&lt;/code&gt; with role &lt;code&gt;director&lt;/code&gt;, and &lt;code&gt;Alice&lt;/code&gt; does not exist in Vertica, Vertica automatically creates the user &lt;code&gt;Alice&lt;/code&gt;, grants to her the authentication record, and grants to her the &lt;code&gt;director&lt;/code&gt; role as a &lt;a href=&#34;../../../../en/admin/db-users-and-privileges/db-roles/enabling-roles-automatically/&#34;&gt;default role&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;To view users created by JIT user provisioning and which authentication record they use, query the &lt;a href=&#34;../../../../en/sql-reference/system-tables/v-catalog-schema/users/&#34;&gt;USERS&lt;/a&gt; system table:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT user_name, managed_by_oauth2_auth_id FROM users;
 user_name |  managed_by_oauth2_auth_id
-----------+-----------------------------
 dbadmin   |
 Bob       | 45035996273853300
 Margie    |
 Alice     | 45035996273866484
(4 rows)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;For details on using JIT user provisioning with OAuth authentication, see &lt;a href=&#34;../../../../en/security-and-authentication/client-authentication/oauth-2-0-authentication/configuring-oauth-authentication/&#34;&gt;Configuring OAuth authentication&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;enabling-just-in-time-user-provisioning&#34;&gt;Enabling just-in-time user provisioning&lt;/h2&gt;
&lt;p&gt;JIT user provisioning is enabled at the authentication record level by setting the &lt;a href=&#34;../../../../en/security-and-authentication/client-authentication/oauth-2-0-authentication/oauth-authentication-parameters/&#34;&gt;&lt;code&gt;oauth2_jit_enabled&lt;/code&gt; parameter&lt;/a&gt;:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE AUTHENTICATION v_oauth METHOD &amp;#39;v_oauth_jit&amp;#39; HOST &amp;#39;0.0.0.0/0&amp;#39;;
=&amp;gt; ALTER AUTHENTICATION v_oauth SET oauth2_jit_enabled = &amp;#39;yes&amp;#39;;

=&amp;gt; SELECT auth_name, is_oauth2_jit_enabled FROM client_auth WHERE auth_name=&amp;#39;v_oauth&amp;#39;;
  auth_name  |  is_oauth_2_jit_enabled
-------------+--------------------------
 v_oauth     | True
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;automatic-role-assignment&#34;&gt;Automatic role assignment&lt;/h2&gt;
&lt;p&gt;The roles automatically assigned to JIT-provisioned active users are based on the information provided by the identity provider (either from the endpoints &lt;code&gt;introspect_url&lt;/code&gt; or &lt;code&gt;userinfo_url&lt;/code&gt;) and are identified by the client/application specified by the OAuth2JITClient configuration parameter (
&lt;code&gt;vertica&lt;/code&gt; by default):&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; ALTER DATABASE DEFAULT SET OAuth2JITClient = &amp;#34;vertica&amp;#34;;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;With OAuth2JITClient set to 
&lt;code&gt;vertica&lt;/code&gt;, roles that both exist in Vertica and are listed in &lt;code&gt;resource_access.vertica.roles&lt;/code&gt; are automatically &lt;a href=&#34;../../../../en/sql-reference/statements/grant-statements/grant-role/&#34;&gt;granted&lt;/a&gt; to and set as &lt;a href=&#34;../../../../en/admin/db-users-and-privileges/db-roles/enabling-roles-automatically/&#34;&gt;default roles&lt;/a&gt; for JIT-provisioned users.&lt;/p&gt;
&lt;p&gt;The identity provider shares user roles through the &lt;code&gt;introspect_url&lt;/code&gt; or &lt;code&gt;userinfo_url&lt;/code&gt; endpoints. Vertica first sends a request to the &lt;code&gt;introspect_url&lt;/code&gt;. If no roles are found in the response, Vertica sends a request to &lt;code&gt;userinfo_url&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;For example, if a client attempts to authenticate as the user &lt;code&gt;bob&lt;/code&gt; and no user with the same name exists in the database, Vertica sends the following request to the identity provider&#39;s &lt;code&gt;introspect_url&lt;/code&gt; to retrieve the roles given to &lt;code&gt;bob&lt;/code&gt; by the identity provider (this example is truncated):&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;{
    ...
    &amp;#34;resource_access&amp;#34;: {
        &amp;#34;vertica&amp;#34;: {
            &amp;#34;roles&amp;#34;: [
                &amp;#34;customer-facing&amp;#34;,
                &amp;#34;order-management&amp;#34;,
                &amp;#34;idp-exclusive-role&amp;#34;
            ]
        },
        &amp;#34;account&amp;#34;: {
            &amp;#34;roles&amp;#34;: [
                &amp;#34;manage-account&amp;#34;,
                &amp;#34;manage-account-links&amp;#34;,
                &amp;#34;view-profile&amp;#34;
            ]
        }
    },
    &amp;#34;scope&amp;#34;: &amp;#34;email profile roles&amp;#34;,
    &amp;#34;sid&amp;#34;: &amp;#34;dcdd14b1-fe47-491e-b62b-10d1e05c6ffe&amp;#34;,
    &amp;#34;client_id&amp;#34;: &amp;#34;vertica&amp;#34;,
    &amp;#34;username&amp;#34;: &amp;#34;bob&amp;#34;,
    &amp;#34;active&amp;#34;: true
}
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Because the &lt;code&gt;active&lt;/code&gt; field is true and &lt;code&gt;bob&lt;/code&gt; has no corresponding user in the Vertica server, Vertica automatically creates the user &lt;code&gt;bob&lt;/code&gt; and grants to him the roles that exist in Vertica and are listed in 
&lt;code&gt;resource_access.vertica.roles&lt;/code&gt;: &lt;code&gt;customer-facing&lt;/code&gt; and &lt;code&gt;order-management&lt;/code&gt;. The role &lt;code&gt;idp-exclusive-role&lt;/code&gt; does not exist in Vertica, so it is ignored.&lt;/p&gt;
&lt;h2 id=&#34;automatic-user-pruning&#34;&gt;Automatic user pruning&lt;/h2&gt;
&lt;p&gt;You can enable automatic user pruning to periodically drop users created by JIT user provisioning if they do not log in after a certain period of time. This cleanup service is managed by the following &lt;a href=&#34;../../../../en/sql-reference/config-parameters/security-parameters/&#34;&gt;database-level configuration parameters&lt;/a&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;EnableOAuthJITCleanup: Whether to enable cleanup (disabled by default).&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; ALTER DATABASE DEFAULT SET EnableOAuthJITCleanup = 1; --enables the pruning service
=&amp;gt; ALTER DATABASE DEFAULT SET EnableOAuthJITCleanup = 0; --disables the pruning service
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;OAuth2UserExpiredInterval: The number of days a user must be inactive before it is dropped (14 by default). This is calculated based on the current date and the &lt;code&gt;LAST_LOGIN_TIME&lt;/code&gt; in the &lt;a href=&#34;../../../../en/sql-reference/system-tables/v-catalog-schema/users/&#34;&gt;USERS&lt;/a&gt; system table.

&lt;div class=&#34;alert admonition note&#34; role=&#34;alert&#34;&gt;
&lt;h4 class=&#34;admonition-head&#34;&gt;Note&lt;/h4&gt;

&lt;p&gt;The &lt;code&gt;LAST_LOGIN_TIME&lt;/code&gt; as recorded by the &lt;a href=&#34;../../../../en/sql-reference/system-tables/v-catalog-schema/users/&#34;&gt;USERS&lt;/a&gt; system table is not persistent; if the database is restarted, the &lt;code&gt;LAST_LOGIN_TIME&lt;/code&gt; for users created by just-in-time user provisioning is set to the database start time (this appears as an empty value in &lt;code&gt;LAST_LOGIN_TIME&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;You can view the database start time by querying the &lt;a href=&#34;../../../../en/sql-reference/system-tables/v-catalog-schema/dbs/&#34;&gt;DATABASES&lt;/a&gt; system table:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT database_name, start_time FROM databases;
 database_name |          start_time
---------------+-------------------------------
 VMart         | 2023-02-06 14:26:50.630054-05
(1 row)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; ALTER DATABASE DEFAULT SET OAuth2UserExpiredInterval = 20;
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;GlobalHeirUsername: The user to reassign objects to if the owner is a JIT-provisioned (or LDAP) user that got dropped by the pruning service. If set to &lt;code&gt;&amp;lt;auto&amp;gt;&lt;/code&gt;, objects are reassigned to the &lt;code&gt;dbadmin&lt;/code&gt;.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; ALTER DATABASE DEFAULT SET GlobalHeirUsername = &amp;lt;auto&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The cleanup service runs daily and there can be a delay of up to 24 hours for dropping an expired user.&lt;/p&gt;

      </description>
    </item>
    
    <item>
      <title>Security-and-Authentication: OAuth authentication parameters</title>
      <link>/en/security-and-authentication/client-authentication/oauth-2-0-authentication/oauth-authentication-parameters/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/security-and-authentication/client-authentication/oauth-2-0-authentication/oauth-authentication-parameters/</guid>
      <description>
        
        
        &lt;p&gt;Vertica OAuth &lt;a href=&#34;../../../../en/sql-reference/statements/create-statements/create-authentication/&#34;&gt;authentication records&lt;/a&gt; use the following parameters to determine how to validate client OAuth tokens and how to contact the identity provider during the validation process. These parameters should be set with &lt;a href=&#34;../../../../en/sql-reference/statements/alter-statements/alter-authentication/&#34;&gt;ALTER AUTHENTICATION&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;just-in-time-provisioning-parameters-keycloak-only&#34;&gt;Just-in-time provisioning parameters (keycloak only)&lt;/h2&gt;
&lt;p&gt;The optional &lt;code&gt;oauth2_jit_enabled&lt;/code&gt; parameter specifies whether to enable &lt;a href=&#34;../../../../en/security-and-authentication/client-authentication/oauth-2-0-authentication/just-time-user-provisioning/&#34;&gt;just-in-time user provisioning&lt;/a&gt;. If set to &lt;code&gt;&#39;yes&#39;&lt;/code&gt;, when the user authenticates, Vertica automatically performs the following actions:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;
Creates the user if they do not already exist in the database. The length of the username in the identity provider cannot be greater than 128 characters.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;
Grants to the user and sets as 
default the roles associated with the user (as specified by the identity provider), provided the roles already exist in Vertica.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;
Grants to the user the authentication record used to authenticate them if neither their user nor role has a grant on that record.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If set to &lt;code&gt;&#39;no&#39;&lt;/code&gt; (default), users must be manually &lt;a href=&#34;../../../../en/sql-reference/statements/create-statements/create-user/&#34;&gt;created&lt;/a&gt; and &lt;a href=&#34;../../../../en/sql-reference/statements/grant-statements/grant-authentication/&#34;&gt;granted&lt;/a&gt; an &lt;code&gt;oauth&lt;/code&gt; authentication record to authenticate to Vertica with OAuth tokens.&lt;/p&gt;
&lt;h2 id=&#34;validation-modes&#34;&gt;Validation modes&lt;/h2&gt;
&lt;p&gt;OAuth authentication records have two modes for validating OAuth tokens, each specified with the authentication parameter &lt;code&gt;validate_type&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;validate_type&lt;/code&gt; parameter takes one of the following values:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;IDP&lt;/code&gt; (default): Validate OAuth tokens by contacting the identity provider.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;JWT&lt;/code&gt;: (Keycloak only) Validate OAuth tokens by verifying that it was signed by the identity provider&#39;s private key . This does not require Vertica to contact the identity provider for validation.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Each validation mode uses a different set of parameters, which are detailed in the tables below.&lt;/p&gt;
&lt;h3 id=&#34;idp-validation-parameters&#34;&gt;IDP validation parameters&lt;/h3&gt;

&lt;table class=&#34;table table-bordered&#34; &gt;



&lt;tr&gt; 

&lt;th &gt;
Parameter name&lt;/th&gt; 

&lt;th &gt;
Description&lt;/th&gt; 

&lt;th &gt;
Required/Optional&lt;/th&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;
&lt;code&gt;client_id&lt;/code&gt;&lt;/td&gt; 

&lt;td &gt;
The ID of the confidential client application registered in the identity provider. Vertica uses this ID to call the introspection API to retrieve user grants.&lt;/td&gt; 

&lt;td &gt;
Required&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;
The secret of the confidential client application registered in the identity provider. This value is not shared with other clients.&lt;/td&gt; 

&lt;td &gt;
Required&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;
&lt;code&gt;discovery_url&lt;/code&gt; (&lt;a href=&#34;https://www.keycloak.org/docs/latest/securing_apps/#endpoints&#34;&gt;Keycloak only&lt;/a&gt;)&lt;/td&gt; 

&lt;td &gt;






&lt;p&gt;Also known as the &lt;a href=&#34;https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderConfigurationRequest&#34;&gt;OpenID Provider Configuration Document&lt;/a&gt; or the well-known configuration endpoint, this endpoint contains information about the configuration and endpoints of the identity provider.&lt;/p&gt;
&lt;p&gt;If you specify the &lt;code&gt;discovery_url&lt;/code&gt; and not the &lt;code&gt;introspect_url&lt;/code&gt;, Vertica automatically retrieves the &lt;code&gt;introspect_url&lt;/code&gt; from the identity provider.&lt;/p&gt;
&lt;p&gt;If you specify both the &lt;code&gt;discovery_url&lt;/code&gt; and &lt;code&gt;introspect_url&lt;/code&gt;, the &lt;code&gt;discovery_url&lt;/code&gt; takes precedence.&lt;/p&gt;
&lt;/td&gt; 

&lt;td &gt;
Required for &lt;code&gt;IDP&lt;/code&gt; validation if &lt;code&gt;introspect_url&lt;/code&gt; is not specified.&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;
&lt;code&gt;introspect_url&lt;/code&gt;&lt;/td&gt; 

&lt;td &gt;
Used by Vertica to introspect (validate) access tokens. You must specify this parameter if you do not specify the &lt;code&gt;discovery_url&lt;/code&gt;. For examples, see the &lt;a href=&#34;https://www.keycloak.org/docs/latest/securing_apps/#_token_introspection_endpoint&#34;&gt;Keycloak&lt;/a&gt; and &lt;a href=&#34;https://developer.okta.com/docs/reference/api/oidc/#introspect&#34;&gt;Okta&lt;/a&gt; documentation.&lt;/td&gt; 

&lt;td &gt;
Required if &lt;code&gt;discovery_url&lt;/code&gt; is not specified.&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;

&lt;h3 id=&#34;jwt-validation-parameters&#34;&gt;JWT validation parameters&lt;/h3&gt;
&lt;p&gt;The following table lists the parameters used to configure OAuth authentication records that use the &lt;code&gt;JWT&lt;/code&gt; validation mode:

&lt;table class=&#34;table table-bordered&#34; &gt;



&lt;tr&gt; 

&lt;th &gt;
Parameter name&lt;/th&gt; 

&lt;th &gt;
Description&lt;/th&gt; 

&lt;th &gt;
Required/Optional&lt;/th&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;
&lt;code&gt;jwt_rsa_public_key&lt;/code&gt;&lt;/td&gt; 

&lt;td &gt;
In PEM format, the public key that corresponds to the private key used to sign the client&#39;s OAuth token. Vertica uses this to validate the OAuth token.&lt;/td&gt; 

&lt;td &gt;
Required&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;
&lt;code&gt;jwt_issuer&lt;/code&gt;&lt;/td&gt; 

&lt;td &gt;
The issuer of the OAuth token. For Keycloak, this is the token endpoint.&lt;/td&gt; 

&lt;td &gt;
Required&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;
&lt;code&gt;jwt_user_mapping&lt;/code&gt;&lt;/td&gt; 

&lt;td &gt;
The name of the Vertica user.&lt;/td&gt; 

&lt;td &gt;
Required&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;
&lt;code&gt;jwt_accepted_audience_list&lt;/code&gt;&lt;/td&gt; 

&lt;td &gt;
A comma-delimited list of values to accept from the client OAuth token&#39;s &lt;code&gt;aud&lt;/code&gt; field. If set, tokens must include in &lt;code&gt;aud&lt;/code&gt; one of the accepted audiences to authenticate.&lt;/td&gt; 

&lt;td &gt;
Optional&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;
&lt;code&gt;jwt_accepted_scope_list&lt;/code&gt;&lt;/td&gt; 

&lt;td &gt;
A comma-delimited list of values to accept from the client OAuth token&#39;s &lt;code&gt;scope&lt;/code&gt; field. If set, tokens must include in &lt;code&gt;scope&lt;/code&gt; at least one of the accepted scopes to authenticate.&lt;/td&gt; 

&lt;td &gt;
Optional&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/p&gt;

      </description>
    </item>
    
  </channel>
</rss>
