File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed
Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change 4040 >> _standalone()
4141
4242Caso queira rodar em outra porta, basta passá-la como parametro no chamado do _ standalone
43+
44+
45+ MongoDB com autenticação
46+ ------------------------
47+
48+ Se o seu MongoDB possui autenticação habilitada você deverá configurar o banco do postmon
49+ e também exportar duas variavéis de ambiente.
50+
51+ ``` javascript
52+ mongo
53+ > use postmon
54+ > db .addUser (' admin' , ' 123456' )
55+ ```
56+
57+ Agora que seu Mongo está com password exporte as variaveis de ambiente.
58+
59+ ``` bash
60+ export POSTMON_DB_USER=admin
61+ export POSTMON_DB_PASSWORD=123456
62+ ```
Original file line number Diff line number Diff line change 11#!/usr/bin/env python
22# -*- coding: utf-8 -*-
3+ import os
34import pymongo
45
56
@@ -15,6 +16,10 @@ class MongoDb(object):
1516
1617 def __init__ (self , address = 'localhost' ):
1718 self ._client = pymongo .MongoClient (address )
19+ USERNAME = os .environ .get ('POSTMON_DB_USER' )
20+ PASSWORD = os .environ .get ('POSTMON_DB_PASSWORD' )
21+ if all ((USERNAME , PASSWORD )):
22+ self ._client .postmon .authenticate (USERNAME , PASSWORD )
1823 self ._db = self ._client .postmon
1924
2025 def get_one (self , cep , ** kwargs ):
You can’t perform that action at this time.
0 commit comments