Skip to main content
Version: 3.13

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 as follows, replacing the contents in the angle brackets as described:

{
"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.