Comments (4)
I was able to get this to work as needed by hacking the mongodb_backend.py file and changing it to this:
# added optional 'username' and 'password' in constructor
class MongoDBBackend(Backend):
def __init__(self, db_name='cork', hostname='localhost', port=27017, initialize=False, username=None, password=None):
"""Initialize MongoDB Backend"""
connection = MongoClient(host=hostname, port=port)
db = connection[db_name]
# if username and password are present than authenticate...
if username and password:
db.authenticate(username, password)
self.users = MongoMultiValueTable('users', 'login', db.users)
self.pending_registrations = MongoMultiValueTable(
'pending_registrations',
'pending_registration',
db.pending_registrations
)
self.roles = MongoSingleValueTable('roles', 'role', db.roles)
if initialize:
self._initialize_storage()
from bottle-cork.
MongoDB supports URIs in the "host" parameter as in:
http://api.mongodb.org/python/current/examples/authentication.html
Given that the "hostname" parameter in MongoDBBackend is simply passed to MongoClient as "host", you should be already able to perform authentication.
Example:
uri = "mongodb://admin:admin@localhost/"
mb = MongoDBBackend(hostname=uri)
Does that work for you? Certainly "hostname" is a misleading name for an URI, I'll update it.
from bottle-cork.
That does not work. That results in the following:
Traceback (most recent call last):
File "server.py", line 94, in
port=auth_db_port
File "build/bdist.macosx-10.9-intel/egg/cork/mongodb_backend.py", line 141, in init
File "/Library/Python/2.7/site-packages/pymongo/mongo_client.py", line 369, in init
raise ConfigurationError(str(exc))
pymongo.errors.ConfigurationError: command SON([('authenticate', 1), ('user', u'user_admin'), ('nonce', u'2cbbb43173e169de'), ('key', u'4b8df11693f429caa4e3cd506e241470')]) failed: auth fails
from bottle-cork.
I will just stick with my two line modification for now because it works perfectly and has no other impact on the code.
from bottle-cork.
Related Issues (20)
- SQLiteBackend.Table.iteritems() yields wrong data HOT 2
- Doco links to dead-ish downloads page on Github
- Best way to add more user fields to user profile? HOT 1
- Registration email fails if TEMPLATE_PATH is not /views/ HOT 2
- Login timeout too short HOT 1
- make doc error HOT 1
- Subclassing User HOT 2
- Security issue? problematic defaults for hashlib.pbkdf2_hmac HOT 1
- Registration does not check pending_registrations collection for existence of the user name HOT 4
- http://cork.firelet.net/ is down HOT 1
- Missing logging for auditing HOT 5
- pip update? HOT 1
- Documentation website is down HOT 1
- mongo backend doesn't work with mongdb 3.4
- Email Not Sent - Auth Error HOT 6
- TypeError @ _setup_cookie when signing/logging in HOT 1
- Docs not accessible
- Question ? Cork without beaker
- There's an error when installing
- MySQL server has gone away HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bottle-cork.