From d1f2936ccbc54158831b01499554adf63ae2d6ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B5=D1=89=D0=B5=D1=80=D1=8F=D0=BA=D0=BE=D0=B2=20?= =?UTF-8?q?=D0=92=D1=8F=D1=87=D0=B5=D1=81=D0=BB=D0=B0=D0=B2=20=D0=AE=D1=80?= =?UTF-8?q?=D1=8C=D0=B5=D0=B2=D0=B8=D1=87?= Date: Thu, 4 Apr 2024 15:41:53 +0300 Subject: [PATCH] Support legacy plain_text_auth section in credentials file removed unintentionally MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit patch by Мещеряков Вячеслав Юрьевич; reviewed by Stefan Miklosovic and Brad Schoening for CASSANDRA-19498 --- CHANGES.txt | 1 + bin/cqlsh.py | 3 +-- conf/credentials.sample | 13 ++++++++++++- doc/modules/cassandra/pages/tools/cqlsh.adoc | 10 ++++++++++ 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 2f31f4a2e2..dd60eb447e 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 4.1.6 + * Support legacy plain_text_auth section in credentials file removed unintentionally (CASSANDRA-19498) Merged from 4.0: * Add timeout specifically for bootstrapping nodes (CASSANDRA-15439) * Bring Redhat packge dirs/ownership/perms in line with Debian package (CASSANDRA-19565) diff --git a/bin/cqlsh.py b/bin/cqlsh.py index 328393eb58..286a5c0949 100755 --- a/bin/cqlsh.py +++ b/bin/cqlsh.py @@ -2183,7 +2183,7 @@ def read_options(cmdlineargs, environment): credentials.read(options.credentials) # use the username from credentials file but fallback to cqlshrc if username is absent from the command line parameters - options.username = username_from_cqlshrc + options.username = option_with_default(credentials.get, 'plain_text_auth', 'username', username_from_cqlshrc) if not options.password: rawcredentials = configparser.RawConfigParser() @@ -2191,7 +2191,6 @@ def read_options(cmdlineargs, environment): # handling password in the same way as username, priority cli > credentials > cqlshrc options.password = option_with_default(rawcredentials.get, 'plain_text_auth', 'password', password_from_cqlshrc) - options.password = password_from_cqlshrc elif not options.insecure_password_without_warning: print("\nWarning: Using a password on the command line interface can be insecure." "\nRecommendation: use the credentials file to securely provide the password.\n", file=sys.stderr) diff --git a/conf/credentials.sample b/conf/credentials.sample index 23d0beb71b..99f0832689 100644 --- a/conf/credentials.sample +++ b/conf/credentials.sample @@ -17,7 +17,18 @@ ; ; Sample ~/.cassandra/credentials file. ; -; Please ensure this file is owned by the user and is not readable by group and other users +; The section name must match the classname from the cqlshrc file +; For example, if cqlshrc contains settings +; +; [auth_provider] +; module = cassandra.auth +; classname = PlainTextAuthProvider +; +; then the credentials file should contain a [PlainTextAuthProvider] section with the username and password parameters, as indicated in this example. +; +; For backward compatibility, it is also possible to specify [plain_text_auth] as a header. +; +; Please ensure this file is owned by the user and is not readable by group and other users. [PlainTextAuthProvider] ; username = fred diff --git a/doc/modules/cassandra/pages/tools/cqlsh.adoc b/doc/modules/cassandra/pages/tools/cqlsh.adoc index 8050ee5df0..ba9d36e703 100644 --- a/doc/modules/cassandra/pages/tools/cqlsh.adoc +++ b/doc/modules/cassandra/pages/tools/cqlsh.adoc @@ -46,6 +46,16 @@ Example config values and documentation can be found in the You can also view the latest version of the https://github.com/apache/cassandra/blob/trunk/conf/cqlshrc.sample[cqlshrc file online]. +[[credentials]] +== credentials + +The credentials file contains a user-name and a password for cqlsh. +A user-name and a password must be located in a section whose name matches the classname from the `[auth_provider]` section of the cqlshrc file. +The credentials file must be owned by the user and no one else has permission to read the file. + +Example config values and documentation can be found in the +`conf/credentials.sample` file of a tarball installation. + [[cql_history]] == cql history