vscode-cql icon indicating copy to clipboard operation
vscode-cql copied to clipboard

Supporting authentications.

Open jun92 opened this issue 7 years ago • 5 comments

first of all, thanks for make this useful plugin for vs code. during I've used it as editing cql statement, I found that It supports executing the statement within vs code. but there is no way to authenticate to cassandra database. do you have any plan to add the feature at the plugin?

thanks.

jun92 avatar Aug 04 '17 06:08 jun92

Thanks for taking the time to make a feature request! That is a great idea and one that makes perfect sense. I can get this implemented and updated pretty quickly.

lawrencekgrant avatar Aug 08 '17 19:08 lawrencekgrant

Any progress on this?

stefan505 avatar Feb 12 '18 14:02 stefan505

Hi Lawrence,

May I suggest a full options Object in the user config to instantiate a cassandra-driver singleton. something like:

"cql": {
    "contactPoints": ["10.0.0.1", "10.0.0.2"]
    "auth": { // will need a factory to get a new instance of authProvider
        "provider": "PlainTextAuthProvider",
        "user": "username",
        "password": "somapassword",
    }
    "keyspace": "somekeyspace", // none if empty
    "policies": // maybe later with localDatacenter and loadbalancing
}

Thank you for the work. If I get the time I will try to fix a PR. In chrunchtime a.t.m. so it could be a while.

c

chiluap avatar Apr 25 '18 07:04 chiluap

I've written some code to support authentication in local files("cqlExecutor.js:24") It seems to be worked well, but "cql.execute" error occured. because I don't have any idea of making plugins for vscode and nodejs & typescript, I can't find where to start finding the issue. anyone suggests? or hints?

function executeCqlStatement(statement) {
    console.log('Configuring cql statement execution.');
    let cassandraAddress = vscode.workspace.getConfiguration("cql")["address"];
    let cassandraPort = vscode.workspace.getConfiguration("cql")["port"];
    let cassandraConnectionOptions = vscode.workspace.getConfiguration("cql")["connection"];
    let cassandraAuth = new cassandra.auth.PlainTextAuthProvider(workspace.getConfiguration("cql")["username"], workspace.getConfiguration("cql")["password"]);
    let cassandraKeyspace = workspace.getConfiguration("cql")["keyspace"];
    let clientOptions = !!cassandraConnectionOptions
        ? cassandraConnectionOptions
        : {
            contactPoints: [cassandraAddress],
            hosts: [cassandraAddress],
            authProvider: [cassandraAuth],
            keyspace : [cassandraKeyspace]
        };

jun92 avatar Jul 29 '18 04:07 jun92

You can run your extension in debug mode in vscode. https://code.visualstudio.com/docs/extensions/developing-extensions If you post the error we might be able to help you =)

chiluap avatar Jul 31 '18 12:07 chiluap