Thrift sasl with username/password authentication for C++

Edwin Vivek N

I've been trying to add security to my project which uses Apache Thrift. In C#, there is a class TSASLClientTransport which accepts the parameters TSocket, username and password. Similarly I need a cpp class so that I can implement the same in C++.

I came across this task https://issues.apache.org/jira/browse/THRIFT-1667, which is still in Open state. There's a patch available in this task though. Using this patch I imported the TsaslTransport class, but I don't find a way to provide username/password here. If possible can anyone share any examples on this.

Or is there a way to provide simple username/password authentication in thrift using C++?

Can Cyrus-SASL be used here?

Any help is greatly appreciated.

Edwin Vivek N

After some investigation I found out a working solution. I’ve used cyrus-sasl project along with the patch from Apache THRIFT.

First create a TTransport with a hive service running in a secure cluster.

boost::shared_ptr<TTransport> socket(new TSocket("hive_host", hive_port));
boost::shared_ptr<TTransport> transport(new TBufferedTransport(socket));

Create array of Callbacks to get the username from &simple and password from &getsecret in client.

  static sasl_callback_t callbacks[] ={
           {
            SASL_CB_USER, (sasl_callback_ft)&simple, NULL 
           }, {
            SASL_CB_AUTHNAME, (sasl_callback_ft)&simple, NULL 
           }, {
            SASL_CB_PASS, (sasl_callback_ft)&getsecret, NULL
           }, {
            SASL_CB_LIST_END, NULL, NULL
           }
};

Use libSaslClient from saslimpl.cpp to choose the mechanism and service. This initializes the client. And use this client in TSaslTransport to open a connection and communicate with the server.

map<string, string> props; 
sasl::libSaslClient libSaslClient("PLAIN", "", "ldap", "host", props, callbacks);
boost::shared_ptr<TSaslTransport> tsaslTransport(new TSaslTransport(&libSaslClient, transport));
tsaslTransport->open();
tsaslTransport->close();

On successful open you will be able to communicate with a secure cluster given the right username and password.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

SASL LDAP authentication failure

From Dev

Smack 4.1 SASL authentication error

From Dev

kafka SASL/SCRAM Failed authentication

From Dev

Python Cassandra 2 authentication with SASL

From Dev

how to configure svn client on OSX for SASL authentication?

From Dev

XMPP SASL SCRAM-SHA1 Authentication

From Dev

SASL authentication failed using mechanism DIGEST

From Java

server returned error on SASL authentication step: Authentication failed

From Dev

Ejabberd SASL external authentication for client SSL Authentication using certificates

From Dev

Postfix + Ubuntu: SASL LOGIN authentication failed: authentication failure

From Dev

Mac OS X 10.10 Yosemite Postfix SASL authentication failed

From Dev

Postfix Dovecot SASL Authentication not enabled/working ubuntu 12.04 server

From Dev

Postfix Dovecot SASL Authentication not enabled/working ubuntu 12.04 server

From Dev

Cannot send mail from command line, sasl authentication error

From Dev

Thrift Required Field C++

From Dev

Thrift: Is it possible to do only serialization with the C (GLib) Thrift library?

From Dev

Golang and MongoDb remote access fail (server returned error on SASL authentication step: Authentication failed.)

From Dev

Issue compiling thrift 0.9.0 c++ client

From Dev

How to add Thrift dependencies to a C# project?

From Dev

how to make "new ASCIIEncoding().GetBytes(usernamePassword)" to read a "§" sign

From Dev

JBoss JMS: ERROR: JBREM000200: Remote connection failed: javax.security.sasl.SaslException: Authentication failed: the server presented

From Dev

JBoss JMS: ERROR: JBREM000200: Remote connection failed: javax.security.sasl.SaslException: Authentication failed: the server presented

From Dev

Union in thrift shows all values setted in c++

From Dev

C# Compilation error in Visual Studio 2010 (Thrift 0.9.1 compilation)

From Dev

c++ thrift client not working with ssl (SSL_connect hangs)

From Dev

Generated thrift file giving me compilation error - C#

From Dev

Which Data Type is most appropriate for datetime in thrift communication in c++?

From Dev

C# WebAPI Authentication

From Dev

PowerBI authentication C#

Related Related

  1. 1

    SASL LDAP authentication failure

  2. 2

    Smack 4.1 SASL authentication error

  3. 3

    kafka SASL/SCRAM Failed authentication

  4. 4

    Python Cassandra 2 authentication with SASL

  5. 5

    how to configure svn client on OSX for SASL authentication?

  6. 6

    XMPP SASL SCRAM-SHA1 Authentication

  7. 7

    SASL authentication failed using mechanism DIGEST

  8. 8

    server returned error on SASL authentication step: Authentication failed

  9. 9

    Ejabberd SASL external authentication for client SSL Authentication using certificates

  10. 10

    Postfix + Ubuntu: SASL LOGIN authentication failed: authentication failure

  11. 11

    Mac OS X 10.10 Yosemite Postfix SASL authentication failed

  12. 12

    Postfix Dovecot SASL Authentication not enabled/working ubuntu 12.04 server

  13. 13

    Postfix Dovecot SASL Authentication not enabled/working ubuntu 12.04 server

  14. 14

    Cannot send mail from command line, sasl authentication error

  15. 15

    Thrift Required Field C++

  16. 16

    Thrift: Is it possible to do only serialization with the C (GLib) Thrift library?

  17. 17

    Golang and MongoDb remote access fail (server returned error on SASL authentication step: Authentication failed.)

  18. 18

    Issue compiling thrift 0.9.0 c++ client

  19. 19

    How to add Thrift dependencies to a C# project?

  20. 20

    how to make "new ASCIIEncoding().GetBytes(usernamePassword)" to read a "§" sign

  21. 21

    JBoss JMS: ERROR: JBREM000200: Remote connection failed: javax.security.sasl.SaslException: Authentication failed: the server presented

  22. 22

    JBoss JMS: ERROR: JBREM000200: Remote connection failed: javax.security.sasl.SaslException: Authentication failed: the server presented

  23. 23

    Union in thrift shows all values setted in c++

  24. 24

    C# Compilation error in Visual Studio 2010 (Thrift 0.9.1 compilation)

  25. 25

    c++ thrift client not working with ssl (SSL_connect hangs)

  26. 26

    Generated thrift file giving me compilation error - C#

  27. 27

    Which Data Type is most appropriate for datetime in thrift communication in c++?

  28. 28

    C# WebAPI Authentication

  29. 29

    PowerBI authentication C#

HotTag

Archive