Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added gridfs authentication

  • Loading branch information...
commit ece03922d6cb82e31debbf9c87c8a8101e33896d 1 parent 47bb827
@unbit authored
Showing with 13 additions and 0 deletions.
  1. +13 −0 plugins/gridfs/gridfs.cc
View
13 plugins/gridfs/gridfs.cc
@@ -19,6 +19,8 @@ struct uwsgi_gridfs_mountpoint {
uint16_t itemname_len;
char *skip_slash;
uint16_t prefix_len;
+ char *username;
+ char *password;
};
struct uwsgi_gridfs {
@@ -40,6 +42,15 @@ static void uwsgi_gridfs_do(struct wsgi_request *wsgi_req, struct uwsgi_gridfs_m
try {
mongo::scoped_ptr<mongo::ScopedDbConnection> conn( mongo::ScopedDbConnection::getScopedDbConnection(ugm->server, ugm->timeout) );
try {
+ if (ugm->username && ugm->password) {
+ std::string errmsg;
+ if ((*conn).conn().auth(ugm->db, ugm->username, ugm->password, errmsg)) {
+ uwsgi_log("[uwsgi-gridfs]: %s\n", errmsg.c_str());
+ (*conn).done();
+ uwsgi_403(wsgi_req);
+ return;
+ }
+ }
mongo::GridFS gridfs((*conn).conn(), ugm->db);
mongo::GridFile gfile = gridfs.findFile(itemname);
if (need_free) {
@@ -131,6 +142,8 @@ static struct uwsgi_gridfs_mountpoint *uwsgi_gridfs_add_mountpoint(char *arg, si
"etag", &ugm->etag,
"itemname", &ugm->itemname,
"item", &ugm->itemname,
+ "username", &ugm->username,
+ "password", &ugm->password,
NULL)) {
uwsgi_log("invalid gridfs mountpoint syntax\n");
free(ugm);
Please sign in to comment.
Something went wrong with that request. Please try again.