~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/auth_http/auth_http.cc

  • Committer: Monty Taylor
  • Date: 2010-03-02 18:33:15 UTC
  • mto: (1317.4.1) (1320.1.13 build)
  • mto: This revision was merged to the branch mainline in revision 1322.
  • Revision ID: mordred@inaugust.com-20100302183315-84c30ejnvpj2q8w1
Fixed Authentication plugin interface to use SecurityContext rather than the
whole darned Session object.

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());