Skip to content

Commit

Permalink
fixed bmuller#28
Browse files Browse the repository at this point in the history
  • Loading branch information
bmuller committed Feb 8, 2009
1 parent e140401 commit 43356d9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
2 changes: 2 additions & 0 deletions ChangeLog
Expand Up @@ -6,6 +6,8 @@
Dev Version
Fixed bug involving custom auth cookie names (issue 27)
No longer clearing attribute exchange parameters (issue 34) - see wiki page for attribute exchange
Added ability to specify external program for authorization (issues 8, 35, and 17)
Fixed bug that left openid params in referrer param after custom login page redirect (issue 28).

Version 0.3
Added support for OpenID 2.0 spec - using new libopkele
Expand Down
21 changes: 16 additions & 5 deletions mod_auth_openid.cpp
Expand Up @@ -156,16 +156,27 @@ static const command_rec mod_authopenid_cmds[] = {
{NULL}
};

/* Get the full URI of the request_rec's request location */
static void full_uri(request_rec *r, std::string& result, modauthopenid_config *s_cfg) {
// Get the full URI of the request_rec's request location
// clean_params specifies whether or not all openid.* and modauthopenid.* params should be cleared
static void full_uri(request_rec *r, std::string& result, modauthopenid_config *s_cfg, bool clean_params=false) {
std::string hostname(r->hostname);
std::string protocol(r->protocol);
std::string uri(r->uri);
apr_port_t i_port = ap_get_server_port(r);
std::string prefix = (i_port == 443) ? "https://" : "http://";
char *port = apr_psprintf(r->pool, "%lu", (unsigned long) i_port);
std::string s_port = (i_port == 80 || i_port == 443) ? "" : ":" + std::string(port);
std::string args = (r->args == NULL) ? "" : "?" + std::string(r->args);

std::string args;
if(clean_params) {
opkele::params_t params;
if(r->args != NULL) params = modauthopenid::parse_query_string(std::string(r->args));
modauthopenid::remove_openid_vars(params);
args = params.append_query("", "");
} else {
args = (r->args == NULL) ? "" : "?" + std::string(r->args);
}

if(s_cfg->server_name == NULL)
result = prefix + hostname + s_port + uri + args;
else
Expand All @@ -183,7 +194,7 @@ static int show_input(request_rec *r, modauthopenid_config *s_cfg, modauthopenid
modauthopenid::remove_openid_vars(params);

std::string uri_location;
full_uri(r, uri_location, s_cfg);
full_uri(r, uri_location, s_cfg, true);
params["modauthopenid.referrer"] = uri_location;

params["modauthopenid.error"] = modauthopenid::error_to_string(e, true);
Expand All @@ -198,7 +209,7 @@ static int show_input(request_rec *r, modauthopenid_config *s_cfg) {
params = modauthopenid::parse_query_string(std::string(r->args));
modauthopenid::remove_openid_vars(params);
std::string uri_location;
full_uri(r, uri_location, s_cfg);
full_uri(r, uri_location, s_cfg, true);
params["modauthopenid.referrer"] = uri_location;
return modauthopenid::http_redirect(r, params.append_query(s_cfg->login_page, ""));
}
Expand Down

0 comments on commit 43356d9

Please sign in to comment.