pharo-nosql / mongotalk

A Pharo driver for MongoDB
MIT License
19 stars 13 forks source link

Cannot connect to DB with authentication #16

Closed darth-cheney closed 6 years ago

darth-cheney commented 7 years ago

Hello. I'm trying to connect to a Mongo server that has authentication on a specific database. There is no connecting to the server at all unless I connect to this database.

Here is what I try:

mongo := Mongo host: 'my-host-name' port: 27017.
mongo username 'myUsername' password: 'myPassword' database: (mongo databaseNamed: 'dbName').

This throws the following stack trace, which is some kind of stream error:

UndefinedObject(Object)>>doesNotUnderstand: #nextPut:
LittleEndianStream>>nextBytePut:
LittleEndianStream>>nextInt32Put:
QueryOperation(MongoOperation)>>writeHeader
QueryOperation(MongoOperation)>>write
Mongo>>cursorQuery:
MongoCursor>>execute
Mongo>>queryOne:
Mongo>>command:database:
Mongo>>authenticateUsername:password:database:
Mongo>>username:password:database:
UndefinedObject>>DoIt
OpalCompiler>>evaluate
RubSmalltalkEditor>>evaluate:andDo:
RubSmalltalkEditor>>highlightEvaluateAndDo:
[ textMorph textArea editor highlightEvaluateAndDo: ann action.
textMorph shoutStyler style: textMorph text ] in [ textMorph textArea
    handleEdit: [ textMorph textArea editor highlightEvaluateAndDo: ann action.
        textMorph shoutStyler style: textMorph text ] ] in GLMMorphicPharoScriptRenderer(GLMMorphicPharoCodeRenderer)>>actOnHighlightAndEvaluate: in Block: [ textMorph textArea editor highlightEvaluateAndDo...etc...
RubEditingArea(RubAbstractTextArea)>>handleEdit:
[ textMorph textArea
    handleEdit: [ textMorph textArea editor highlightEvaluateAndDo: ann action.
        textMorph shoutStyler style: textMorph text ] ] in GLMMorphicPharoScriptRenderer(GLMMorphicPharoCodeRenderer)>>actOnHighlightAndEvaluate: in Block: [ textMorph textArea...
WorldState>>runStepMethodsIn:
WorldMorph>>runStepMethods
WorldState>>doOneCycleNowFor:
WorldState>>doOneCycleFor:
WorldMorph>>doOneCycle
[ [ World doOneCycle.
Processor yield.
false ] whileFalse: [  ] ] in MorphicUIManager>>spawnNewProcess in Block: [ [ World doOneCycle....
[ self value.
Processor terminateActive ] in BlockClosure>>newProcess in Block: [ self value....

Because I don't know the low-level operations of communicating with a Mongo server over a socket, I have no idea what's going on at this level.

Additional Info: I'm running Pharo 5 stock on OSX Sierra.

udoschneider commented 7 years ago

Could you verify which authentication method your MongoDB ist using. Currently MongoTalk does only support the old MongoDB Challenge and Response (MONGODB-CR) authentication - not the (now default) SASL-based SCRAM-SHA-1 authentication. Ensuring that you are using the old auth might be worth a try.

darth-cheney commented 7 years ago

Yes, I am using SCRAM-SHA-1 with Mongo 3. Is this a matter simply switching the encryption method?

udoschneider commented 7 years ago

Then you need to "downgrade" your authentication scheme (e.g. SO "MongoDB-CR Authentication failed"). At least until somebody implements the SCRAM based stuff in MongoTalk. As this is based on SASL though it implies a whole bunch of (to be developed) code ... so nothing short-term IMHO.

darth-cheney commented 7 years ago

Ok thanks

astares commented 7 years ago

Note that mike from pharocloud has implemented SCRAM-SHA-1 auth method for MongoTalk (according to what he wrote on #database channel on Pharo Discord) to be able to talk to Atlas cloud.

He will contribute the code.

mikefilonov commented 7 years ago

I am. Need review feedback and someone to verify: #21

tinchodias commented 6 years ago

Should we close this issue since #21 is merged?

estebanlm commented 6 years ago

oops