Skip to main content
Version: 3.18

Getting Started with Authentication and Authorization by Using ScalarDB Cluster .NET Client SDK

The ScalarDB Cluster .NET Client SDK supports authentication and authorization, which allows you to authenticate and authorize your requests to ScalarDB Cluster.

Install the SDK​

Install the same major and minor version of the SDK as ScalarDB Cluster into the .NET project. You can do this by using the built-in NuGet package manager, replacing <MAJOR>.<MINOR> with the version that you're using:

dotnet add package ScalarDB.Client --version '<MAJOR>.<MINOR>.*'

Set credentials in the settings file​

You need to set credentials in the settings file, replacing the contents in the angle brackets as described. ScalarDB Cluster supports two authentication types: username and password authentication, and authentication that uses a JWT access token issued by an OpenID Connect (OIDC) provider. Select the tab for the authentication type that you want to use.

To authenticate by using a username and password, set Username and Password as follows:

{
"ScalarDbOptions": {
"Address": "http://<HOSTNAME_OR_IP_ADDRESS>:<PORT>",
"HopLimit": 10,
"AuthEnabled": true,
"Username": "<USERNAME>",
"Password": "<PASSWORD>"
}
}

For details about settings files and other ways to configure the client, see Client configuration.

Get a transaction manager​

You need to get a transaction manager or transaction admin object by using TransactionFactory as follows. Be sure to replace <GET_TRANSACTION_MANAGER> with GetTransactionManager(), GetTwoPhaseCommitTransactionManager(), GetSqlTransactionManager(), or GetSqlTwoPhaseCommitTransactionManager().

// Pass the path to the settings file.
var factory = TransactionFactory.Create("scalardb-options.json");

// To get a transaction manager
using var manager = factory.<GET_TRANSACTION_MANAGER>();

// To get a transaction admin
using var admin = factory.GetTransactionAdmin();

A transaction manager or transaction admin object created from TransactionFactory with the provided credentials will automatically log in to ScalarDB Cluster and can communicate with it.

Wire encryption​

Wire encryption is also supported. It can be turned on by setting Address to the URL starting with https as follows:

{
"ScalarDbOptions": {
"Address": "https://<HOSTNAME_OR_IP_ADDRESS>:<PORT>"
}
}

For details about settings files and other ways to configure the client, see Client configuration.