Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #22 from akumpf/patch-3

Enable authentication with smog!
  • Loading branch information...
commit 805332113eedb53ad0898c26aca18ebcb77bc1e7 2 parents 32462e2 + 7b9f005
@contra contra authored
Showing with 29 additions and 21 deletions.
  1. +29 −21 lib/services/admin.coffee
View
50 lib/services/admin.coffee
@@ -5,26 +5,34 @@ module.exports = (cb, socket) ->
db = cb.socket.mongo.database
admin = db.admin
- db.collectionNames (err, r) ->
- return cb err.message if err?
- out.collections = r
+ # authenticate against "admin" db first, then go back to original.
+ if db._dbconn.options.password
+ dbOrig = db._dbconn.databaseName
+ db._dbconn.databaseName = "admin"
+ db.open (err, r) ->
+ db._dbconn.databaseName = dbOrig
+ db.open (err, r) ->
- admin.serverStatus (err, r) ->
- return cb err.message if err?
- out.serverStatus = r
-
- admin.buildInfo (err, r) ->
- return cb err.message if err?
- out.buildInfo = r
-
- admin.profilingLevel (err, r) ->
+ db.collectionNames (err, r) ->
return cb err.message if err?
- out.profilingLevel = r
-
- admin.profilingInfo (err, r) ->
- return cb err.message if err?
- out.profilingInfo = r
-
- admin.replSetGetStatus (err, r) ->
- out.replSetGetStatus = r unless err?
- return cb null, out
+
+ admin.serverStatus (err, r) ->
+ # return cb err.message if err?
+ out.serverStatus = r unless err?
+
+ admin.buildInfo (err, r) ->
+ # return cb err.message if err?
+ out.buildInfo = r unless err?
+
+ admin.profilingLevel (err, r) ->
+ # return cb err.message if err?
+ out.profilingLevel = r unless err?
+
+ admin.profilingInfo (err, r) ->
+ # return cb err.message if err?
+ out.profilingInfo = r unless err?
+
+ admin.replSetGetStatus (err, r) ->
+ out.replSetGetStatus = r unless err?
+ return cb null, out
Please sign in to comment.
Something went wrong with that request. Please try again.