Skip to content
This repository

Enable authentication with smog! #22

Merged
merged 1 commit into from over 1 year ago

2 participants

Adam Kumpf Eric Schoffstall
Adam Kumpf

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.

Adam Kumpf 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
Eric Schoffstall contra merged commit 8053321 into from
Eric Schoffstall contra closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Oct 29, 2012
Adam Kumpf 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
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 29 additions and 21 deletions. Show diff stats Hide diff stats

  1. +29 21 lib/services/admin.coffee
50 lib/services/admin.coffee
@@ -5,26 +5,34 @@ module.exports = (cb, socket) ->
5 5 db = cb.socket.mongo.database
6 6 admin = db.admin
7 7
8   - db.collectionNames (err, r) ->
9   - return cb err.message if err?
10   - out.collections = r
  8 + # authenticate against "admin" db first, then go back to original.
  9 + if db._dbconn.options.password
  10 + dbOrig = db._dbconn.databaseName
  11 + db._dbconn.databaseName = "admin"
  12 + db.open (err, r) ->
  13 + db._dbconn.databaseName = dbOrig
  14 + db.open (err, r) ->
11 15
12   - admin.serverStatus (err, r) ->
13   - return cb err.message if err?
14   - out.serverStatus = r
15   -
16   - admin.buildInfo (err, r) ->
17   - return cb err.message if err?
18   - out.buildInfo = r
19   -
20   - admin.profilingLevel (err, r) ->
  16 + db.collectionNames (err, r) ->
21 17 return cb err.message if err?
22   - out.profilingLevel = r
23   -
24   - admin.profilingInfo (err, r) ->
25   - return cb err.message if err?
26   - out.profilingInfo = r
27   -
28   - admin.replSetGetStatus (err, r) ->
29   - out.replSetGetStatus = r unless err?
30   - return cb null, out
  18 + out.collections = r
  19 +
  20 + admin.serverStatus (err, r) ->
  21 + # return cb err.message if err?
  22 + out.serverStatus = r unless err?
  23 +
  24 + admin.buildInfo (err, r) ->
  25 + # return cb err.message if err?
  26 + out.buildInfo = r unless err?
  27 +
  28 + admin.profilingLevel (err, r) ->
  29 + # return cb err.message if err?
  30 + out.profilingLevel = r unless err?
  31 +
  32 + admin.profilingInfo (err, r) ->
  33 + # return cb err.message if err?
  34 + out.profilingInfo = r unless err?
  35 +
  36 + admin.replSetGetStatus (err, r) ->
  37 + out.replSetGetStatus = r unless err?
  38 + return cb null, out

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.