Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Enable authentication with smog! #22

Merged
merged 1 commit into from

2 participants

@akumpf

2 updates here:
 - if user entered a password, try to authenticate against "admin" db first then drop back to desired database.
 - if any admin operation fails (in the case of a non-admin user), keep going; don't assume we should throw an error here.

@akumpf akumpf Enable authentication with smog!
2 updates here:
 - if user entered a password, try to authenticate against "admin" db first then drop back to desired database.
 - if any admin operation fails (in the case of a non-admin user), keep going; don't assume we should throw an error here.
7b9f005
@contra contra merged commit 8053321 into wearefractal:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 29, 2012
  1. @akumpf

    Enable authentication with smog!

    akumpf authored
    2 updates here:
     - if user entered a password, try to authenticate against "admin" db first then drop back to desired database.
     - if any admin operation fails (in the case of a non-admin user), keep going; don't assume we should throw an error here.
This page is out of date. Refresh to see the latest.
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
+ out.collections = r
+
+ 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
Something went wrong with that request. Please try again.