可以在 cassandra 的连接 url 中传递用户名和密码吗

Can username and password be passed in connection url for cassandra

我想请问是否可以在数据库连接中传递用户名和密码url 示例:

jdbc:cassandra:keyspace=keyspace1;host=host;port=port;user=user;password=password;

我正在为 apache cassandra 使用 cdata 驱动程序。 如果是,我如何通过连接 url 创建一个带密码的用户? 不,关于 datastax 的文档对我没有帮助。

简而言之,是的。将 AuthScheme 连接 属性 设置为 'Basic' 并设置 UserPassword 连接属性,除此之外还有其他必要的属性:

jdbc:cassandra:AuthSchem=BASIC;User=<username>;Password=<password>;...

@Aaron 提供创建第一个用户的方案:How do you create the first user in Cassandra DB

来自online CData JDBC Driver for Cassandra help

The driver supports Basic authentication with login credentials and the additional authentication features of DataStax Enterprise (DSE) Cassandra. The following sections detail connection properties your authentication method may require.

You need to set AuthScheme to the value corresponding to the authenticator configured for your system. You specify the authenticator in the authenticator property in the cassandra.yaml file. This file is typically found in /etc/dse/cassandra. or through the DSE Unified Authenticator on DSE Cassandra.

Basic Authentication

Basic authentication is supported through Cassandra's built-in default PasswordAuthenticator.

  • Set the AuthScheme property to 'BASIC' and set the User and Password properties.
  • In the cassandra.yaml file, set the authenticator property to 'PasswordAuthenticator'.

Kerberos Authentication

Kerberos authentication is supported through DataStax Enterprise Unified Authentication.

  • Set the AuthScheme property to 'KERBEROS' and set the User and Password properties.
  • Set the KerberosKDC, KerberosRealm, and KerberosSPN properties.
  • In the cassandra.yaml file, set the authenticator property to "com.datastax.bdp.cassandra.auth.DseAuthenticator".
  • Modify the authentication_options section in the dse.yaml file, specifying the default_schema and other_schemas properties as 'kerberos'.
  • Modify the kerberos_options section in the dse.yaml file, specifying the keytab, service_principle, http_principle and qop properties

LDAP Authentication

LDAP authentication is supported through DataStax Enterprise Unified Authentication.

  • Set the AuthScheme property to 'LDAP' and set the User and Password properties.
  • In the cassandra.yaml file, set the authenticator property to "com.datastax.bdp.cassandra.auth.DseAuthenticator".
  • Modify the authentication_options section in the dse.yaml file, specifying the default_schema and other_schemas properties as 'ldap'.
  • Modify the ldap_options section in the dse.yaml file, specifying the server_host, server_port, search_dn, search_password, user_search_base, and user_search_filter properties

Using PKI

You can specify a client certificate to authenticate the driver with SSLClientCert, SSLClientCertType, SSLClientCertSubject, and SSLClientCertPassword.