TL;DR: Antalya now lets you forward OAuth tokens in requests to data lake catalogs. That lets you use the same OAuth infrastructure to manage access to your ClickHouse databases and your catalogs.
Beginning with Antalya build version 26.6.8.20003, databases defined with the DataLakeCatalog engine that have a catalog_type of rest or glue can use authentication tokens. That means you can manage access to ClickHouse databases and data lake catalogs with the same OAuth infrastructure. (We have a high-level explanation of Antalya’s OAuth support here on the blog.)
For our example here, we’ll start with two things:
- An infrastructure that manages authentication tokens, and
- An AWS Glue catalog that we want to access via a token.
We’ll cover how to integrate AWS’s IAM infrastructure with our existing OAuth provider, then we’ll create the Antalya database that uses token forwarding.
Our infrastructure
We need to set up token management inside AWS. We’ll start with an example infrastructure that features a client application, an Antalya server, and a Keycloak IdP. (The existing infrastructure comes from the example in the article Managing Users and Access with OAuth and Antalya.) What we’ll do here is set up AWS to use our existing IdP and configure Antalya to pass tokens to AWS Glue.
The complete infrastructure will look like this:
Figure 1 – Our infrastructure
Here’s how tokens move through the infrastructure:
- The user of our client application logs in to the IdP (Keycloak, in this example)
- The IdP sends an ID token, access token, and refresh token back to the client application.
- When the client application needs to query our data, it sends the query and the access token to Antalya.
- Antalya validates the token.
- If the token is valid, Antalya forwards it to the AWS infrastructure.
- The AWS identity provider (the one we’re about to create) validates the token. If the token is valid, AWS runs the query against our AWS Glue catalog.
- AWS sends the results back to Antalya.
- Antalya sends the results back to the client application.
Steps 1 and 2 are our existing infrastructure, steps 3 through 8 are what we’ll set up next. Keep in mind that the diagram for steps 1 and 2 could be completely different for other IdPs. Our assumption is that our client application goes into step 3 with a valid authentication token.
Creating the AWS IAM infrastructure
We need to create an identity provider in AWS. We’ll point it to our existing IdP, integrating it with the token infrastructure we’ve already built.
From the AWS IAM dashboard, click Identity providers and click the Add provider button. We’ll create a new OpenID Connect (OIDC) provider and give it the URL of our existing IdP and the value of the Audience claim it should look for in a given token:
Figure 2 – Creating a new AWS identity provider
We’ve given our new provider the URL of our existing OIDC provider and the value clickhouse as the audience it should look for. The audience value is set in our IdP. We can define multiple audiences if necessary, and we can assign different roles to each. For our example here, we’ll keep it simple with a single audience value.
The values defined in Figure 2 are the values of the iss and aud claims in the authentication token:
The Provider URL value in Figure 2 must match the iss claim in the token exactly. The audience (aud) claim defines the audience for this token.
Note: Depending on the IdP that generates your tokens, your JWTs may also contain an azp (authorized party) claim. If it exists, the AWS identity provider will ignore the aud claim and look at the value of azp instead. Check the documentation for the IdP that generates your tokens and the IdP that consumes them to determine how aud and azp claims are generated and handled. (Figuring this out beforehand can save you hours of debugging. Trust us on that.)
With the new identity provider created, you’ll need to assign it a role:
Figure 3 – The new IdP must have a role
Click the Assign role button, then select Create a new role:
Figure 4 – Assign a new role to the IdP
Now we’ll create a Web identity to define what someone authenticated by the IdP can do. We’ll select Web identity, select the IdP we just created, and the audience we want:
Figure 5 – Creating a Web identity for an IdP / Audience
Click Next. Now we need to add the permissions an authenticated user will have. They’ll need to have permissions from AWS Glue as well as S3. Choose Create inline policy at the top of the dialog (see Figure 6 below), then edit this policy appropriately and paste it into the policy editor:
Replace us-east-1 with the AWS region you’re using. In our example, our Glue catalog is in the oauth-test/warehouse/ folder inside an S3 bucket named gluetest. Replace gluetest and oauth-test/warehouse/ with the details for your catalog. The database inside the catalog is named nyc_taxi, and we’re giving this role access to all the tables in that database; replace nyc_taxi with the name of your database. Finally, replace 123456789012 with your AWS account number. You’ll see something like this:
Figure 6 – The inline policy for the new role
Finally, give the policy a name (glue_oauth_reader) and create it. Here’s the complete definition of the role:
Figure 7 – The complete definition of the new role
The trust policy here identifies our IdP and the audience. AWS generated the name glue-oauth-readerPolicy for our inline policy, and there’s a summary of the permissions in that policy. Click the Create role button, and our infrastructure is all set! Before we go, though, we need to copy the ARN of the role we just created. Go to the Roles tab on the IAM dashboard, find the new role, and copy the ARN:
Figure 8 – The ARN of the role we just created
Creating a DataLakeCatalog database with token forwarding
Now to create our database. Here’s the ClickHouse syntax:
We have to turn on the allow_experimental_database_glue_catalog setting for this to work at all. The settings on the CREATE DATABASE command are pretty straightforward. This is an AWS Glue catalog, it’s in the us-east-1 region, we reference the role we created and our database, and we turn on token forwarding.
We’ll use the version of clickhouse-client that ships with the version of clickhouse-server that we’re using. Here’s what happens when the default user tries to look at the nyc_taxi.yellow_trips database inside the catalog:
We didn’t provide a token to clickhouse-client when we logged in, so there’s no token for Antalya to pass to AWS. However, if we use the --jwt option to authenticate with a valid token, everything works:
Antalya forwarded the authentication token to AWS Glue, which validated the token, checked the role granted to the token, and returned the data we’re looking for.
Summary
Antalya’s token forwarding capabilities for DataLakeCatalog databases give us the ability to manage access to data with the same granularity and flexibility of any OAuth-based system. Our example here was an Iceberg table in AWS Glue, but Antalya supports other DataLakeCatalog implementations:
- Databricks Unity Catalog – For Delta Lake and Iceberg tables
- Hive Metastore – Traditional Hadoop ecosystem catalog
- REST Catalogs – Any catalog supporting the Iceberg REST specification
Token forwarding lets us extend Antalya’s OAuth support to use the full power of ClickHouse ROLEs and GRANTs to control access to Iceberg tables in other environments.
Join our Slack
ClickHouse is a registered trademark of ClickHouse, Inc.; Altinity is not affiliated with or associated with ClickHouse, Inc.
Get the latest ClickHouse news straight to your inbox every month.












