Linux DSN Configuration
This section describes how to set up ODBC connectivity and configure DSNs on several Linux distributions: Debian-based systems, like Ubuntu, and Red Hat Linux platforms, like Red Hat Enterprise Linux (RHEL) and Fedora.
Minimum Linux Versions
Here are the minimum supported versions for Red Hat-based and Debian-based systems:
| OS | Min. Version |
| Ubuntu | 18.04 |
| Debian | 10 |
| RHEL | 8 |
| Fedora | 28 |
| SUSE | 15 |
Installing the Driver Dependencies
Run the following commands as root or with sudo to install the necessary dependencies:
- Debian/Ubuntu:
apt-get install libc6 libstdc++6 zlib1g libgcc1
- RHEL/Fedora:
yum install glibc libstdc++ zlib libgcc
Installing the Driver
You can use standard package management systems to install the driver.
On Debian-based systems, like Ubuntu, run the following command with root or sudo:
dpkg -i /path/to/driver/setup/ApacheCouchDBODBCDriverforUnix.deb
On systems that support the RPM package format, run the following command with root or sudo:
rpm -ivh /path/to/driver/ApacheCouchDBODBCDriverforUnix.rpm
Licensing the Driver
Run the following commands to license the driver. To activate a trial, omit the <key> input.
cd /opt/cdata/cdata-odbc-driver-for-apachecouchdb/bin/
sudo ./install-license.sh <key>
Connecting through the Driver Manager
The driver manager loads the driver and passes function calls from the application to the driver. You need to register the driver with the driver manager and you define DSNs in the driver manager's configuration files.
The driver installation registers the driver with the unixODBC driver manager and creates a system DSN. The unixODBC driver manager can be used from Python and from many other applications. Your application may embed another driver manager.
Creating the DSN
See Using unixODBC to install unixODBC and configure DSNs. See Using the DataDirect Driver Manager to create a DSN to connect to OBIEE, Informatica, and SAS.
Connecting to Apache CouchDB
Set the URL connection property to the URL of your Apache CouchDB instance. For example: http://localhost:5984
If you want your users (or JWTs) to have access only to specific databases, configure the admin_only_all_dbs option in your Apache CouchDB instance to grant all users access to the "/_all_dbs" endpoint, which is required by the driver for listing tables.
Authenticating to Apache CouchDB
Apache CouchDB supports three types of authentication:- Basic: Basic username/password authentication.
- JWT: Authentication with a JWT.
- None: Anonymous access for databases that are public.
Basic Authentication
Set the following to connect to data:
- AuthScheme: Basic.
- User The Apache CouchDB user account used to authenticate.
- Password The Apache CouchDB password associated with the authenticating user.
JWT Authentication
Set AuthScheme to JWT.
You can either automatically generate (and, if applicable, refresh) a JWT or manually generate one:
Automatic Token Generation
Configure the driver to automatically generate the tokens:Required
- JWTSubject: The name of the user to assign to the JWT.
- JWTAlgorithm: The algorithm to use for the JWT signature.
- JWTKeyType: The encryption key's type.
- JWTKey: The encryption key used to sign the JWT generated by the driver.
Optional
- JWTIssuer: The issuer of the JWT.
- JWTExpiration: The duration for which the JWT remains valid, in seconds.
- JWTHeaders: A collection of extra headers to include in the JWT header.
- JWTClaims: A collection of extra claims to include in the JWT payload.
- CredentialsLocation: The filepath of the settings file containing the JWT. If a settings file does not exist in this location, the driver creates a new settings file when it retrieves a JWT.
Manual Token Generation
You can generate the tokens yourself manually and pass them to the driver by using the JWTToken connection property.
Generating the Key Pair
When using asymmetric algorithms to sign the tokens, you must generate a private/public key pair. For that, a cryptographic library like OpenSSL can be used. For example:
# generate private key openssl genrsa --out private_rsa256.pem 2048 # extract public key openssl rsa -in private_rsa256.pem -pubout > public_rsa256.pem
JWT Configurations
Refer to CouchDB JWT Authentication Documentation for the following.
The alg and sub are required claims and will always be validated by the Apache CouchDB instance. Other required claims can be configured in the server (see required_claims). In that case, you must use JWTHeaders and JWTClaims so that the driver can include those additional claims when generating the JWT.
You can use roles_claim_name or the roles_claim_path options to assign roles to the JWTs.
An example configuration of the server and corresponding sample connection string are shown below:
Example Server Configuration
[chttpd]
...
authentication_handlers = {chttpd_auth, jwt_authentication_handler}, {chttpd_auth, cookie_authentication_handler}, {chttpd_auth, default_authentication_handler}
admin_only_all_dbs = false
...
[jwt_auth]
...
required_claims = exp
roles_claim_path = my.nested._couchdb\.roles
rsa:rsa_256 = -----BEGIN PUBLIC KEY-----\nYOUR_PUBLIC_KEY\n-----END PUBLIC KEY-----\n
...
Example Connection String
Url=http://localhost:5984; JWTSubject=JWT User 1; JWTAlgorithm=RS256; JWTKeyType=PEMKEY_FILE; JWTKey=PATH_TO_FOLDER\private_rsa256.pem; JWTHeaders=kid : rsa_256 | Custom Header 1 : Test 1; JWTClaims= my : eyJuZXN0ZWQiOnsiX2NvdWNoZGIucm9sZXMiOlsidXNlcjIiXX19 | Custom Claim 1 : Test 1;
Anonymous Authentication
Set the following to connect to data:
- AuthScheme: None.
- PublicDatabases: A comma-separated list of public databases to list as tables.
Set the Driver Encoding
The ODBC drivers need to specify which encoding to use with the ODBC Driver Manager. By default, the CData ODBC Drivers for Unix are configured to use UTF-16 which is compatible with unixODBC, but other Driver Managers may require alternative encoding.
Alternatively, if you are using the ODBC driver from an application that uses the ANSI ODBC API it may be necessary to set the ANSI code page. For example, to import Japanese characters in an ANSI application, you can specify the code page in the config file '/opt/cdata/cdata-odbc-driver-for-apachecouchdb/lib/cdata.odbc.apachecouchdb.ini':
[Driver]
AnsiCodePage = 932