Authenticator callbacks are not working

9 views
Skip to first unread message

David Grinberg

unread,
Jul 27, 2022, 5:06:53 AM7/27/22
to DataStax C++ Driver for Apache Cassandra User Mailing List
 https://github.com/datastax/cpp-driver/tree/master/examples/auth - you can extend callbacks with some logging and see that they are not called 

Michael Penick

unread,
Aug 5, 2022, 9:57:47 AM8/5/22
to cpp-dri...@lists.datastax.com
Are you sure you have authentication enabled on your cassandra cluster?

Modified with logging:

```
diff --git a/examples/auth/auth.c b/examples/auth/auth.c
index 7cc8491e..7a0880f1 100644
--- a/examples/auth/auth.c
+++ b/examples/auth/auth.c
@@ -65,6 +65,8 @@ void on_auth_initial(CassAuthenticator* auth, void* data) {
 
   response[username_size + 1] = '\0';
   memcpy(response + username_size + 2, credentials->password, password_size);
+
+  printf("Auth initialization\n");
 }
 
 void on_auth_challenge(CassAuthenticator* auth, void* data, const char* token, size_t token_size) {
@@ -72,6 +74,7 @@ void on_auth_challenge(CassAuthenticator* auth, void* data, const char* token, s
    * Not used for plain text authentication, but this is to be used
    * for handling an authentication challenge initiated by the server.
    */
+  printf("Auth challenge\n");
 }
 
 void on_auth_success(CassAuthenticator* auth, void* data, const char* token, size_t token_size) {
@@ -79,6 +82,7 @@ void on_auth_success(CassAuthenticator* auth, void* data, const char* token, siz
    * Not used for plain text authentication, but this is to be used
    * for handling the success phase of an exchange.
    */
+  printf("Auth success\n");
 }
 
 void on_auth_cleanup(CassAuthenticator* auth, void* data) {
@@ -87,6 +91,7 @@ void on_auth_cleanup(CassAuthenticator* auth, void* data) {
    * this is used to cleanup resources acquired during the authentication
    * exchange.
    */
+  printf("Auth cleanup\n");
 }
 
 int main(int argc, char* argv[]) {
```

Output:

```
$ ./examples/auth/auth
Auth initialization
Auth success
Auth cleanup
Auth initialization
Auth success
Successfully connected!
Auth cleanup
```

On Wed, Jul 27, 2022 at 5:06 AM David Grinberg <green....@gmail.com> wrote:
 https://github.com/datastax/cpp-driver/tree/master/examples/auth - you can extend callbacks with some logging and see that they are not called 

--
To unsubscribe from this group and stop receiving emails from it, send an email to cpp-driver-us...@lists.datastax.com.


--
Reply all
Reply to author
Forward
0 new messages