[SERVER-1698] A shell function should be implemented to see if the client is authenticated with the db Created: 29/Aug/10  Updated: 19/Mar/13  Resolved: 11/Mar/13

Status: Closed
Project: Core Server
Component/s: Internal Client, Shell
Affects Version/s: 1.6.1
Fix Version/s: None

Type: New Feature Priority: Minor - P4
Reporter: Fabian Becker Assignee: Spencer Brody (Inactive)
Resolution: Duplicate Votes: 2
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-7124 connectionStatus command Closed
Related
related to SERVER-1677 A shell function should be implemente... Closed
Participants:

 Description   

A shell function should be available and return true if a user is authenticated against a database. I propose to use "isAuthorized" as name. A function with this name exists in security.h and can be re-used for this issue.

bool isAuthorized(const string& dbname)

{ return _isAuthorized( dbname,2 ); }

 Comments   
Comment by Spencer Brody (Inactive) [ 11/Mar/13 ]

This has been solved with the introduction of the connectionStatus command, which lists all authenticated users on all databases. If you just want to check if you are authenticated as some user, you can check

db.runCommand('connectionStatus').authInfo.authenticatedUsers.length

Comment by Rodrigo Coelho [ 05/Jan/12 ]

Note: Authentication != Authorization

Ref: http://en.wikipedia.org/wiki/Authentication#Authentication_vs._authorization

Comment by Fabian Becker [ 04/Oct/10 ]

Brian Gianforcaro created a nice patch that implements the above feature. He also created a pull request on Github (http://github.com/mongodb/mongo/pull/5). I tested the patch and it works nicely.

Generated at Thu Feb 08 02:57:46 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.