[shibboleth-sp2] 54/119: Consume SHIBSP variables earlier in the process.
Ferenc Wágner
wferi-guest at moszumanska.debian.org
Tue Jan 26 21:29:49 UTC 2016
This is an automated email from the git hooks/post-receive script.
wferi-guest pushed a commit to annotated tag 1.3.1
in repository shibboleth-sp2.
commit 9c26986880f2332fee4c99fa01bbe747e1a16da1
Author: Scott Cantor <cantor.2 at osu.edu>
Date: Fri Sep 14 19:35:34 2007 +0000
Consume SHIBSP variables earlier in the process.
---
fastcgi/shibauthorizer.cpp | 45 ++++++++++++++++++++++++++++++---------------
fastcgi/shibresponder.cpp | 46 +++++++++++++++++++++++++++++++---------------
2 files changed, 61 insertions(+), 30 deletions(-)
diff --git a/fastcgi/shibauthorizer.cpp b/fastcgi/shibauthorizer.cpp
index db16d85..d0edc56 100644
--- a/fastcgi/shibauthorizer.cpp
+++ b/fastcgi/shibauthorizer.cpp
@@ -47,28 +47,29 @@ class ShibTargetFCGIAuth : public ShibTarget
public:
map<string,string> m_headers;
- ShibTargetFCGIAuth(FCGX_Request* req) : m_req(req) {
- char* server_name_str = FCGX_GetParam("SHIBSP_SERVER_NAME", req->envp);
+ ShibTargetFCGIAuth(FCGX_Request* req, const char* scheme=NULL, const char* hostname=NULL, int port=0) : m_req(req) {
+ const char* server_name_str = hostname;
if (!server_name_str || !*server_name_str)
server_name_str = FCGX_GetParam("SERVER_NAME", req->envp);
- char* server_port_str = FCGX_GetParam("SHIBSP_SERVER_PORT", req->envp);
- if (!server_port_str || !*server_port_str)
- server_port_str = FCGX_GetParam("SERVER_PORT", req->envp);
- int server_port = strtol(server_port_str, &server_port_str, 10);
- if (*server_port_str) {
- cerr << "can't parse SERVER_PORT (" << FCGX_GetParam("SERVER_PORT", req->envp) << ")" << endl;
- throw SAMLException("Unable to determine server port.");
+ int server_port = port;
+ if (!port) {
+ char* server_port_str = FCGX_GetParam("SERVER_PORT", req->envp);
+ server_port = strtol(server_port_str, &server_port_str, 10);
+ if (*server_port_str) {
+ cerr << "can't parse SERVER_PORT (" << FCGX_GetParam("SERVER_PORT", req->envp) << ")" << endl;
+ throw SAMLException("Unable to determine server port.");
+ }
}
- char* server_scheme_str = FCGX_GetParam("SHIBSP_SERVER_SCHEME", req->envp);
+ const char* server_scheme_str = scheme;
if (!server_scheme_str || !*server_scheme_str)
server_scheme_str = (server_port == 443 || server_port == 8443) ? "https" : "http";
- char* request_uri_str = FCGX_GetParam("REQUEST_URI", req->envp);
- char* content_type_str = FCGX_GetParam("CONTENT_TYPE", req->envp);
- char* remote_addr_str = FCGX_GetParam("REMOTE_ADDR", req->envp);
- char* request_method_str = FCGX_GetParam("REQUEST_METHOD", req->envp);
+ const char* request_uri_str = FCGX_GetParam("REQUEST_URI", req->envp);
+ const char* content_type_str = FCGX_GetParam("CONTENT_TYPE", req->envp);
+ const char* remote_addr_str = FCGX_GetParam("REMOTE_ADDR", req->envp);
+ const char* request_method_str = FCGX_GetParam("REQUEST_METHOD", req->envp);
init(server_scheme_str,
server_name_str,
@@ -202,6 +203,9 @@ int main(void)
cerr << "SHIB_CONFIG = " << shib_config << endl
<< "SHIB_SCHEMA = " << shib_schema << endl;
+ string g_ServerScheme;
+ string g_ServerName;
+ int g_ServerPort = 0;
ShibTargetConfig* g_Config;
try {
@@ -229,6 +233,17 @@ int main(void)
exit(1);
}
+ // Load "authoritative" URL fields.
+ char* var = getenv("SHIBSP_SERVER_NAME");
+ if (var)
+ g_ServerName = var;
+ var = getenv("SHIBSP_SERVER_SCHEME");
+ if (var)
+ g_ServerScheme = var;
+ var = getenv("SHIBSP_SERVER_PORT");
+ if (var)
+ g_ServerPort = atoi(var);
+
streambuf* cout_streambuf = cout.rdbuf();
streambuf* cerr_streambuf = cerr.rdbuf();
@@ -251,7 +266,7 @@ int main(void)
try {
saml::NDC ndc("FastCGI shibauthorizer");
- ShibTargetFCGIAuth sta(&request);
+ ShibTargetFCGIAuth sta(&request, g_ServerScheme.c_str(), g_ServerName.c_str(), g_ServerPort);
pair<bool,void*> res = sta.doCheckAuthN();
if (res.first) {
diff --git a/fastcgi/shibresponder.cpp b/fastcgi/shibresponder.cpp
index 682dcd5..23e25ef 100644
--- a/fastcgi/shibresponder.cpp
+++ b/fastcgi/shibresponder.cpp
@@ -48,29 +48,31 @@ class ShibTargetFCGI : public ShibTarget
map<string, string> m_headers;
public:
- ShibTargetFCGI(FCGX_Request* req, char* post_data) : m_req(req), m_body(post_data) {
+ ShibTargetFCGI(FCGX_Request* req, char* post_data, const char* scheme=NULL, const char* hostname=NULL, int port=0)
+ : m_req(req), m_body(post_data) {
- char* server_name_str = FCGX_GetParam("SHIBSP_SERVER_NAME", req->envp);
+ const char* server_name_str = hostname;
if (!server_name_str || !*server_name_str)
server_name_str = FCGX_GetParam("SERVER_NAME", req->envp);
- char* server_port_str = FCGX_GetParam("SHIBSP_SERVER_PORT", req->envp);
- if (!server_port_str || !*server_port_str)
- server_port_str = FCGX_GetParam("SERVER_PORT", req->envp);
- int server_port = strtol(server_port_str, &server_port_str, 10);
- if (*server_port_str) {
- cerr << "can't parse SERVER_PORT (" << FCGX_GetParam("SERVER_PORT", req->envp) << ")" << endl;
- throw SAMLException("Unable to determine server port.");
+ int server_port = port;
+ if (!port) {
+ char* server_port_str = FCGX_GetParam("SERVER_PORT", req->envp);
+ server_port = strtol(server_port_str, &server_port_str, 10);
+ if (*server_port_str) {
+ cerr << "can't parse SERVER_PORT (" << FCGX_GetParam("SERVER_PORT", req->envp) << ")" << endl;
+ throw SAMLException("Unable to determine server port.");
+ }
}
- char* server_scheme_str = FCGX_GetParam("SHIBSP_SERVER_SCHEME", req->envp);
+ const char* server_scheme_str = scheme;
if (!server_scheme_str || !*server_scheme_str)
server_scheme_str = (server_port == 443 || server_port == 8443) ? "https" : "http";
- char* request_uri_str = FCGX_GetParam("REQUEST_URI", req->envp);
- char* content_type_str = FCGX_GetParam("CONTENT_TYPE", req->envp);
- char* remote_addr_str = FCGX_GetParam("REMOTE_ADDR", req->envp);
- char* request_method_str = FCGX_GetParam("REQUEST_METHOD", req->envp);
+ const char* request_uri_str = FCGX_GetParam("REQUEST_URI", req->envp);
+ const char* content_type_str = FCGX_GetParam("CONTENT_TYPE", req->envp);
+ const char* remote_addr_str = FCGX_GetParam("REMOTE_ADDR", req->envp);
+ const char* request_method_str = FCGX_GetParam("REQUEST_METHOD", req->envp);
#ifdef _DEBUG
cerr << "server_name = " << server_name_str << endl
@@ -235,6 +237,9 @@ int main(void)
cerr << "SHIB_CONFIG = " << shib_config << endl
<< "SHIB_SCHEMA = " << shib_schema << endl;
+ string g_ServerScheme;
+ string g_ServerName;
+ int g_ServerPort=0;
ShibTargetConfig* g_Config;
try {
@@ -261,6 +266,17 @@ int main(void)
exit(1);
}
+ // Load "authoritative" URL fields.
+ char* var = getenv("SHIBSP_SERVER_NAME");
+ if (var)
+ g_ServerName = var;
+ var = getenv("SHIBSP_SERVER_SCHEME");
+ if (var)
+ g_ServerScheme = var;
+ var = getenv("SHIBSP_SERVER_PORT");
+ if (var)
+ g_ServerPort = atoi(var);
+
streambuf* cin_streambuf = cin.rdbuf();
streambuf* cout_streambuf = cout.rdbuf();
streambuf* cerr_streambuf = cerr.rdbuf();
@@ -291,7 +307,7 @@ int main(void)
try {
saml::NDC ndc("FastCGI shibresponder");
- ShibTargetFCGI stf(&request, content);
+ ShibTargetFCGI stf(&request, content, g_ServerScheme.c_str(), g_ServerName.c_str(), g_ServerPort);
pair<bool,void*> res = stf.doHandler();
if (res.first) {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-shibboleth/shibboleth-sp2.git
More information about the Pkg-shibboleth-devel
mailing list