Use the following information to configure your Pulsar clients to use the OAuth2 authentication mechanism for connecting to StreamNative Cloud clusters.
In order to connect to a StreamNative Cloud cluster, you need to get its service URLs.
You can get a cluster’s service URLs by following the steps below:
Navigate to the Details tab, and in the Access Points section, you can find all the available service URLs of this cluster. Click Copy at the end of the row of the service URL to copy the URL.
HTTP Service URL (TLS)
: The URL of Pulsar Admin HTTP service.Broker Service URL (TLS)
: The URL of Pulsar broker service.You can get a cluster’s service URLs by following the steps below:
Navigate to the Details tab, and in the Access Points section, you can find all the available service URLs of this cluster. Click Copy at the end of the row of the service URL to copy the URL.
HTTP Service URL (TLS)
: The URL of Pulsar Admin HTTP service.Broker Service URL (TLS)
: The URL of Pulsar broker service.Before configuring your Pulsar clients to use OAuth 2.0 for connecting to StreamNative Cloud clusters, you need to prepare an OAuth 2.0 credential file for your clients by following the steps below.
If you are using StreamNative’s built-in OAuth2 service, you can download the OAuth2 credential file for the service account that you want to use for your clients by following these steps:
Navigate to the Accounts & Accesses page.
On the left navigation pane, click Service Accounts.
In the row of the service account you want to use, click ...
.
In the dropdown menu, click Download OAuth2 Key to download the OAuth2 credential file to your local directory.
The downloaded credentials file contains the service account credentials used for client authentication. The following is an example of the credentials file for a service account sa
of organization my_org
. Both client_id
and client_secret
are required while the other fields are optional. Since the credentials file contains client_secret
, please make sure the credentials file is stored in a safe place.
Navigate to the Accounts & Accesses page.
On the left navigation pane, click Service Accounts.
In the row of the service account you want to use, click ...
.
In the dropdown menu, click Download OAuth2 Key to download the OAuth2 credential file to your local directory.
The downloaded credentials file contains the service account credentials used for client authentication. The following is an example of the credentials file for a service account sa
of organization my_org
. Both client_id
and client_secret
are required while the other fields are optional. Since the credentials file contains client_secret
, please make sure the credentials file is stored in a safe place.
If you are using an OIDC-compliant identity provider via OIDC Federation, you can prepare the credentials information to configure your Pulsar clients to use OAuth 2.0 for connecting to StreamNative Cloud clusters. Create a credentials file containing the client_id
and client_secret
of your service account:
Once you have the credentials file, you can follow the steps below to configure your Pulsar applications to use OAuth2 authentication.
First of all, since Pulsar clients support different authentication plugins, you need to configure the Pulsar clients to use OAuth2 authentication plugin. For example, you can configure the Pulsar Java clients to use org.apache.pulsar.client.impl.auth.oauth2.AuthenticationOAuth2
.
Secondly, you need to prepare the authentication parameters for OAuth2 authentication. The following table outlines the parameters required for configuring OAuth2 authentication.
Parameter | Description | Example | Required or not |
---|---|---|---|
type | OAuth 2.0 authentication type. Currently, Pulsar clients only support the client_credentials authentication type. | client_credentials (default) | Optional |
issuerUrl | The URL of the authentication provider which allows the Pulsar client to obtain an access token. Currently, StreamNative Cloud only support Auth0 as the identity provider. So the value here should be https://auth.streamnative.cloud . | https://auth.streamnative.cloud | Required |
credentialsUrl | The URL to the JSON credentials file. It supports the following pattern formats: file:///path/to/file data:application/json;base64,<base64-encoded value> | file:///path/to/my_service_account_key.json | Required |
audience | The OAuth 2.0 resource server identifier for a Pulsar cluster. In StreamNative Cloud, a Pulsar cluster is identified by a Uniform Resource Name (URN), which is in the following format urn:sn:pulsar:${your_orgnization_id}:${instance_name} . | urn:sn:pulsar:my_org:my_instance | Required for StreamNative OAuth2 but optional for OIDC Federation |
scope | The scope of an access request. For more information, see access token scope | api://pulsar-cluster-1/.default | Optional |
This section describes how to configure Pulsar clients to connect to a StreamNative Cloud cluster urn:sn:pulsar:my_org:my_instance
using OAuth2. Please notes:
audience
is required.scope
and/or audience
parameters accordingly.In the example above:
Replace <PULSAR_ADMIN_URL>
and/or <PULSAR_BROKER_URL>
with the right admin and/or broker URL of your Pulsar cluster. You can get the service URLs in the Cluster Details page of the StreamNative Cloud Console.
Replace urn:sn:pulsar:my_org:my_instance
with the right URN of your Pulsar cluster.
Replace file:///path/to/credentials.json
with the right file path of your downloaded credentials file from the StreamNative Cloud Console.
You can find detailed examples in Build Applications with Pulsar.
This section describes how to use Pulsar command-line tools to connect to a StreamNative Cloud cluster urn:sn:pulsar:my_org:my_instance
using OAuth2.
In order to use snctl
to connect to a StreamNative Cloud cluster using OAuth2, you can follow the steps below:
snctl
current service contextsnctl
provided client and admin toolsYou will be able to use snctl pulsar admin
or snctl pulsar client
to access to the StreamNative Cloud cluster.
In order to use pulsarctl
to connect to a StreamNative Cloud cluster using OAuth2, you can follow the steps below:
You need to activate the service account used in the context before running other Pulsar commands.
After successfully running the command, you should see a similar output as below:
In the example above:
Replace <PULSAR_ADMIN_URL>
and/or <PULSAR_BROKER_URL>
with the right admin and/or broker URL of your Pulsar cluster. You can get the service URLs in the Cluster Details page of the StreamNative Cloud Console.
Replace urn:sn:pulsar:my_org:my_instance
with the right URN of your Pulsar cluster.
Replace file:///path/to/credentials.json
with the right file path of your downloaded credentials file from the StreamNative Cloud Console.
Use the following information to configure your Pulsar clients to use the OAuth2 authentication mechanism for connecting to StreamNative Cloud clusters.
In order to connect to a StreamNative Cloud cluster, you need to get its service URLs.
You can get a cluster’s service URLs by following the steps below:
Navigate to the Details tab, and in the Access Points section, you can find all the available service URLs of this cluster. Click Copy at the end of the row of the service URL to copy the URL.
HTTP Service URL (TLS)
: The URL of Pulsar Admin HTTP service.Broker Service URL (TLS)
: The URL of Pulsar broker service.You can get a cluster’s service URLs by following the steps below:
Navigate to the Details tab, and in the Access Points section, you can find all the available service URLs of this cluster. Click Copy at the end of the row of the service URL to copy the URL.
HTTP Service URL (TLS)
: The URL of Pulsar Admin HTTP service.Broker Service URL (TLS)
: The URL of Pulsar broker service.Before configuring your Pulsar clients to use OAuth 2.0 for connecting to StreamNative Cloud clusters, you need to prepare an OAuth 2.0 credential file for your clients by following the steps below.
If you are using StreamNative’s built-in OAuth2 service, you can download the OAuth2 credential file for the service account that you want to use for your clients by following these steps:
Navigate to the Accounts & Accesses page.
On the left navigation pane, click Service Accounts.
In the row of the service account you want to use, click ...
.
In the dropdown menu, click Download OAuth2 Key to download the OAuth2 credential file to your local directory.
The downloaded credentials file contains the service account credentials used for client authentication. The following is an example of the credentials file for a service account sa
of organization my_org
. Both client_id
and client_secret
are required while the other fields are optional. Since the credentials file contains client_secret
, please make sure the credentials file is stored in a safe place.
Navigate to the Accounts & Accesses page.
On the left navigation pane, click Service Accounts.
In the row of the service account you want to use, click ...
.
In the dropdown menu, click Download OAuth2 Key to download the OAuth2 credential file to your local directory.
The downloaded credentials file contains the service account credentials used for client authentication. The following is an example of the credentials file for a service account sa
of organization my_org
. Both client_id
and client_secret
are required while the other fields are optional. Since the credentials file contains client_secret
, please make sure the credentials file is stored in a safe place.
If you are using an OIDC-compliant identity provider via OIDC Federation, you can prepare the credentials information to configure your Pulsar clients to use OAuth 2.0 for connecting to StreamNative Cloud clusters. Create a credentials file containing the client_id
and client_secret
of your service account:
Once you have the credentials file, you can follow the steps below to configure your Pulsar applications to use OAuth2 authentication.
First of all, since Pulsar clients support different authentication plugins, you need to configure the Pulsar clients to use OAuth2 authentication plugin. For example, you can configure the Pulsar Java clients to use org.apache.pulsar.client.impl.auth.oauth2.AuthenticationOAuth2
.
Secondly, you need to prepare the authentication parameters for OAuth2 authentication. The following table outlines the parameters required for configuring OAuth2 authentication.
Parameter | Description | Example | Required or not |
---|---|---|---|
type | OAuth 2.0 authentication type. Currently, Pulsar clients only support the client_credentials authentication type. | client_credentials (default) | Optional |
issuerUrl | The URL of the authentication provider which allows the Pulsar client to obtain an access token. Currently, StreamNative Cloud only support Auth0 as the identity provider. So the value here should be https://auth.streamnative.cloud . | https://auth.streamnative.cloud | Required |
credentialsUrl | The URL to the JSON credentials file. It supports the following pattern formats: file:///path/to/file data:application/json;base64,<base64-encoded value> | file:///path/to/my_service_account_key.json | Required |
audience | The OAuth 2.0 resource server identifier for a Pulsar cluster. In StreamNative Cloud, a Pulsar cluster is identified by a Uniform Resource Name (URN), which is in the following format urn:sn:pulsar:${your_orgnization_id}:${instance_name} . | urn:sn:pulsar:my_org:my_instance | Required for StreamNative OAuth2 but optional for OIDC Federation |
scope | The scope of an access request. For more information, see access token scope | api://pulsar-cluster-1/.default | Optional |
This section describes how to configure Pulsar clients to connect to a StreamNative Cloud cluster urn:sn:pulsar:my_org:my_instance
using OAuth2. Please notes:
audience
is required.scope
and/or audience
parameters accordingly.In the example above:
Replace <PULSAR_ADMIN_URL>
and/or <PULSAR_BROKER_URL>
with the right admin and/or broker URL of your Pulsar cluster. You can get the service URLs in the Cluster Details page of the StreamNative Cloud Console.
Replace urn:sn:pulsar:my_org:my_instance
with the right URN of your Pulsar cluster.
Replace file:///path/to/credentials.json
with the right file path of your downloaded credentials file from the StreamNative Cloud Console.
You can find detailed examples in Build Applications with Pulsar.
This section describes how to use Pulsar command-line tools to connect to a StreamNative Cloud cluster urn:sn:pulsar:my_org:my_instance
using OAuth2.
In order to use snctl
to connect to a StreamNative Cloud cluster using OAuth2, you can follow the steps below:
snctl
current service contextsnctl
provided client and admin toolsYou will be able to use snctl pulsar admin
or snctl pulsar client
to access to the StreamNative Cloud cluster.
In order to use pulsarctl
to connect to a StreamNative Cloud cluster using OAuth2, you can follow the steps below:
You need to activate the service account used in the context before running other Pulsar commands.
After successfully running the command, you should see a similar output as below:
In the example above:
Replace <PULSAR_ADMIN_URL>
and/or <PULSAR_BROKER_URL>
with the right admin and/or broker URL of your Pulsar cluster. You can get the service URLs in the Cluster Details page of the StreamNative Cloud Console.
Replace urn:sn:pulsar:my_org:my_instance
with the right URN of your Pulsar cluster.
Replace file:///path/to/credentials.json
with the right file path of your downloaded credentials file from the StreamNative Cloud Console.