~posulliv/drizzle/optimizer-style-cleanup

« back to all changes in this revision

Viewing changes to plugin/auth_http/auth_http.cc

  • Committer: Padraig O'Sullivan
  • Date: 2010-03-15 14:05:26 UTC
  • mfrom: (1237.9.99 staging)
  • Revision ID: osullivan.padraig@gmail.com-20100315140526-opbgwdwn6tfecdkq
MergeĀ fromĀ trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 */
19
19
 
20
20
#include "config.h"
21
 
#include <drizzled/session.h>
22
 
#include <drizzled/plugin/authentication.h>
23
 
#include <drizzled/gettext.h>
24
21
 
25
22
#include <curl/curl.h>
26
23
 
27
24
#include <string>
 
25
#include <cassert>
 
26
 
 
27
#include "drizzled/security_context.h"
 
28
#include "drizzled/plugin/authentication.h"
 
29
#include "drizzled/gettext.h"
28
30
 
29
31
using namespace drizzled;
30
32
using namespace std;
70
72
    curl_easy_cleanup(curl_handle);
71
73
  }
72
74
 
73
 
  virtual bool authenticate(Session *session, const char *password)
 
75
  virtual bool authenticate(const SecurityContext &sctx, const string &password)
74
76
  {
75
77
    long http_response_code;
76
78
 
77
79
    if (sysvar_auth_http_enable == false)
78
80
      return true;
79
81
 
80
 
    assert(session->getSecurityContext().getUser().c_str());
81
 
    assert(password);
 
82
    assert(sctx.getUser().c_str());
82
83
 
83
84
 
84
85
    // set the parameters: url, username, password
86
87
#if defined(HAVE_CURLOPT_USERNAME)
87
88
 
88
89
    rv= curl_easy_setopt(curl_handle, CURLOPT_USERNAME,
89
 
                         session->getSecurityContext().getUser().c_str());
90
 
    rv= curl_easy_setopt(curl_handle, CURLOPT_PASSWORD, password);
 
90
                         sctx.getUser().c_str());
 
91
    rv= curl_easy_setopt(curl_handle, CURLOPT_PASSWORD, password.c_str());
91
92
 
92
93
#else
93
94
 
94
 
    string userpwd= session->getSecurityContext().getUser();
 
95
    string userpwd(sctx.getUser());
95
96
    userpwd.append(":");
96
97
    userpwd.append(password);
97
98
    rv= curl_easy_setopt(curl_handle, CURLOPT_USERPWD, userpwd.c_str());
183
184
  PLUGIN_LICENSE_GPL,
184
185
  initialize, /* Plugin Init */
185
186
  finalize, /* Plugin Deinit */
186
 
  NULL,   /* status variables */
187
187
  auth_http_system_variables,
188
188
  NULL    /* config options */
189
189
}