-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 
Author Message
 Post subject: Database Validation fails with cloud database
PostPosted: Fri Feb 13, 2015 3:54 pm 
Newbie

Joined: Fri Feb 13, 2015 3:41 pm
Posts: 6
The database validation will fail when using a cloud database since the authenticated user does not typically have admin privileges unless you are running on a dedicated MongoDB instance.

The following class: org.hibernate.ogm.datastore.mongodb.impl.MongoDBDatastoreProvider does the database validation and won't complete authentication. In order to work around this issue I had toe extend the MongoDBDatastoreProvider class and override the extractDatabase function to remove out the validation (if ( !mongo.getDatabaseNames().contains( databaseName ) ) {).

Since MongoDB will create the database there is no need to preform this validation so it would be a nice feature to be able to set a property that enabled validation.

I was then able to set the a property to use my MongoDBDatastoreProvider:

<property name="hibernate.ogm.datastore.provider"
value="com.MyDatastoreProvider"/>

Hibernate OGM will give a warning that the value is invalid but I was able to successfully authenticate to my cloud database instance.


Top
 Profile  
 
 Post subject: Re: Database Validation fails with cloud database
PostPosted: Mon Feb 16, 2015 4:21 am 
Hibernate Team
Hibernate Team

Joined: Sat Jan 24, 2009 12:46 pm
Posts: 388
Hi,

Thanks for giving Hibernate OGM a spin and letting us know about this issue; Glad to hear you managed to work around it for the time being. I've created https://hibernate.atlassian.net/browse/OGM-733 for fixing this.

I'm inclined to say that we just may ignore the exception raised in this case and continue. Without admin rights, as it seems there is no way to enforce CREATE_DATABASE=false, as the server won't give us the existing database names and it will be created automatically upon usage later on.

Re "Hibernate OGM will give a warning that the value is invalid": Could you give some more details (where is it raised etc.)? Specifying a FQN here is absolutely valid, so no warning should be raised at this point.

Thanks,

--Gunnar

_________________
Visit my blog at http://musingsofaprogrammingaddict.blogspot.com/


Top
 Profile  
 
 Post subject: Re: Database Validation fails with cloud database
PostPosted: Mon Feb 16, 2015 8:39 am 
Newbie

Joined: Fri Feb 13, 2015 3:41 pm
Posts: 6
Warning comes right after reading the persistence.xml:

WARN [org.hibernate.ogm.datastore.impl.DatastoreProviderInitiator] (ServerService Thread Pool -- 72) OGM000070: 'com.nowellpoint.api.mongodb.NowellpointMongoDBDatastoreProvider' is no valid datastore provider short name. Valid values are: MAP, INFINISPAN, EHCACHE, MONGODB, NEO4J_EMBEDDED, COUCHDB_EXPERIMENTAL


Top
 Profile  
 
 Post subject: Re: Database Validation fails with cloud database
PostPosted: Wed Feb 18, 2015 7:19 am 
Hibernate Team
Hibernate Team

Joined: Sat Jan 24, 2009 12:46 pm
Posts: 388
Thanks! I've filed https://hibernate.atlassian.net/browse/OGM-739 for logging this on INFO only.

--Gunnar

_________________
Visit my blog at http://musingsofaprogrammingaddict.blogspot.com/


Top
 Profile  
 
 Post subject: Re: Database Validation fails with cloud database
PostPosted: Mon Feb 23, 2015 10:37 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Hi jherson,

I'm trying to reproduce the problem by fiddling with MongoDB user and roles but so far I cannot find a way to have a user that cannot list a database.
Do you know how such a user is configured? I did create a user on a dedicated db with readWrite role.

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Re: Database Validation fails with cloud database
PostPosted: Mon Feb 23, 2015 11:58 am 
Newbie

Joined: Fri Feb 13, 2015 3:41 pm
Posts: 6
I am using a shared database on MongoLab. My database user setup is:

{
"_id": "<dbname>.admin76189",
"user": "<username>",
"db": "<dbname>",
"credentials": {
"MONGODB-CR": "xxxx"
},
"roles": [
{
"role": "readAnyDatabase",
"db": "<dbname>"
},
{
"role": "readWriteAnyDatabase",
"db": "<dbname>"
},
{
"role": "userAdminAnyDatabase",
"db": "<dbname>"
},
{
"role": "dbAdminAnyDatabase",
"db": "<dbname>"
}
]
}


Top
 Profile  
 
 Post subject: Re: Database Validation fails with cloud database
PostPosted: Tue Feb 24, 2015 3:56 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
That's kind of what I have but I would not be surprised if MongoLab had customized the vanilla MongoDB security. SaaS tend to do that.
Can you try by any change this branch and let us know if the problem is still here?

https://github.com/hibernate/hibernate-ogm/pull/482

mvn clean install -DskipTests -s settings.xml
to build it.

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Re: Database Validation fails with cloud database
PostPosted: Tue Feb 24, 2015 9:32 am 
Newbie

Joined: Fri Feb 13, 2015 3:41 pm
Posts: 6
With MongoLab they don't allow administrator access on a shared instance since that privilege would give access to all databases even the databases that are not mine.

I applied your update to my datastore provider and it worked as expected.

Thanks!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.