2 * Copyright 2001-2007 Internet2
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * mod_apache.cpp -- the core Apache Module code
20 * Created by: Derek Atkins <derek@ihtfp.com>
28 #undef _XOPEN_SOURCE // causes gethostname conflict in unistd.h
32 # define _CRT_NONSTDC_NO_DEPRECATE 1
33 # define _CRT_SECURE_NO_DEPRECATE 1
36 #include <shibsp/AbstractSPRequest.h>
37 #include <shibsp/AccessControl.h>
38 #include <shibsp/exceptions.h>
39 #include <shibsp/RequestMapper.h>
40 #include <shibsp/SPConfig.h>
41 #include <shibsp/ServiceProvider.h>
42 #include <shibsp/SessionCache.h>
43 #include <shibsp/attribute/Attribute.h>
45 #include <xercesc/util/regx/RegularExpression.hpp>
46 #include <xmltooling/XMLToolingConfig.h>
47 #include <xmltooling/util/NDC.h>
48 #include <xmltooling/util/Threads.h>
49 #include <xmltooling/util/XMLConstants.h>
50 #include <xmltooling/util/XMLHelper.h>
58 // Apache specific header files
60 #include <http_config.h>
61 #include <http_protocol.h>
62 #include <http_main.h>
64 #include <http_core.h>
67 #ifndef SHIB_APACHE_13
68 #include <http_request.h>
69 #include <apr_strings.h>
70 #include <apr_pools.h>
77 #include <unistd.h> // for getpid()
80 using namespace shibsp;
81 using namespace xmltooling;
83 using xercesc::RegularExpression;
84 using xercesc::XMLException;
86 extern "C" module MODULE_VAR_EXPORT mod_shib;
89 char* g_szSHIBConfig = SHIBSP_CONFIG;
90 char* g_szSchemaDir = SHIBSP_SCHEMAS;
91 SPConfig* g_Config = NULL;
92 string g_unsetHeaderValue;
93 static const char* g_UserDataKey = "_shib_check_user_";
94 static const XMLCh path[] = UNICODE_LITERAL_4(p,a,t,h);
95 static const XMLCh validate[] = UNICODE_LITERAL_8(v,a,l,i,d,a,t,e);
98 /* Apache 2.2.x headers must be accumulated and set in the output filter.
99 Apache 2.0.49+ supports the filter method.
100 Apache 1.3.x and lesser 2.0.x must write the headers directly. */
102 #if (defined(SHIB_APACHE_20) || defined(SHIB_APACHE_22)) && AP_MODULE_MAGIC_AT_LEAST(20020903,6)
103 #define SHIB_DEFERRED_HEADERS
106 /********************************************************************************/
107 // Basic Apache Configuration code.
110 // per-server module configuration structure
111 struct shib_server_config
116 // creates the per-server configuration
117 extern "C" void* create_shib_server_config(SH_AP_POOL* p, server_rec* s)
119 shib_server_config* sc=(shib_server_config*)ap_pcalloc(p,sizeof(shib_server_config));
124 // overrides server configuration in virtual servers
125 extern "C" void* merge_shib_server_config (SH_AP_POOL* p, void* base, void* sub)
127 shib_server_config* sc=(shib_server_config*)ap_pcalloc(p,sizeof(shib_server_config));
128 shib_server_config* parent=(shib_server_config*)base;
129 shib_server_config* child=(shib_server_config*)sub;
132 sc->szScheme=ap_pstrdup(p,child->szScheme);
133 else if (parent->szScheme)
134 sc->szScheme=ap_pstrdup(p,parent->szScheme);
141 // per-dir module configuration structure
142 struct shib_dir_config
145 char* szAuthGrpFile; // Auth GroupFile name
146 int bRequireAll; // all require directives must match, otherwise OR logic
148 // Content Configuration
149 char* szApplicationId; // Shib applicationId value
150 char* szRequireWith; // require a session using a specific initiator?
151 char* szRedirectToSSL; // redirect non-SSL requests to SSL port
152 int bOff; // flat-out disable all Shib processing
153 int bBasicHijack; // activate for AuthType Basic?
154 int bRequireSession; // require a session?
155 int bExportAssertion; // export SAML assertion to the environment?
156 int bUseEnvVars; // use environment instead of headers?
159 // creates per-directory config structure
160 extern "C" void* create_shib_dir_config (SH_AP_POOL* p, char* d)
162 shib_dir_config* dc=(shib_dir_config*)ap_pcalloc(p,sizeof(shib_dir_config));
164 dc->bBasicHijack = -1;
165 dc->bRequireSession = -1;
166 dc->bExportAssertion = -1;
167 dc->bRequireAll = -1;
168 dc->szRedirectToSSL = NULL;
169 dc->szAuthGrpFile = NULL;
170 dc->szApplicationId = NULL;
171 dc->szRequireWith = NULL;
172 dc->bUseEnvVars = -1;
176 // overrides server configuration in directories
177 extern "C" void* merge_shib_dir_config (SH_AP_POOL* p, void* base, void* sub)
179 shib_dir_config* dc=(shib_dir_config*)ap_pcalloc(p,sizeof(shib_dir_config));
180 shib_dir_config* parent=(shib_dir_config*)base;
181 shib_dir_config* child=(shib_dir_config*)sub;
183 if (child->szAuthGrpFile)
184 dc->szAuthGrpFile=ap_pstrdup(p,child->szAuthGrpFile);
185 else if (parent->szAuthGrpFile)
186 dc->szAuthGrpFile=ap_pstrdup(p,parent->szAuthGrpFile);
188 dc->szAuthGrpFile=NULL;
190 if (child->szApplicationId)
191 dc->szApplicationId=ap_pstrdup(p,child->szApplicationId);
192 else if (parent->szApplicationId)
193 dc->szApplicationId=ap_pstrdup(p,parent->szApplicationId);
195 dc->szApplicationId=NULL;
197 if (child->szRequireWith)
198 dc->szRequireWith=ap_pstrdup(p,child->szRequireWith);
199 else if (parent->szRequireWith)
200 dc->szRequireWith=ap_pstrdup(p,parent->szRequireWith);
202 dc->szRequireWith=NULL;
204 if (child->szRedirectToSSL)
205 dc->szRedirectToSSL=ap_pstrdup(p,child->szRedirectToSSL);
206 else if (parent->szRedirectToSSL)
207 dc->szRedirectToSSL=ap_pstrdup(p,parent->szRedirectToSSL);
209 dc->szRedirectToSSL=NULL;
211 dc->bOff=((child->bOff==-1) ? parent->bOff : child->bOff);
212 dc->bBasicHijack=((child->bBasicHijack==-1) ? parent->bBasicHijack : child->bBasicHijack);
213 dc->bRequireSession=((child->bRequireSession==-1) ? parent->bRequireSession : child->bRequireSession);
214 dc->bExportAssertion=((child->bExportAssertion==-1) ? parent->bExportAssertion : child->bExportAssertion);
215 dc->bRequireAll=((child->bRequireAll==-1) ? parent->bRequireAll : child->bRequireAll);
216 dc->bUseEnvVars=((child->bUseEnvVars==-1) ? parent->bUseEnvVars : child->bUseEnvVars);
220 // per-request module structure
221 struct shib_request_config
223 SH_AP_TABLE *env; // environment vars
224 #ifdef SHIB_DEFERRED_HEADERS
225 SH_AP_TABLE *hdr_out; // headers to browser
226 SH_AP_TABLE *hdr_err; // err headers to browser
230 // create a request record
231 static shib_request_config *init_request_config(request_rec *r)
233 shib_request_config* rc=(shib_request_config*)ap_pcalloc(r->pool,sizeof(shib_request_config));
234 ap_set_module_config (r->request_config, &mod_shib, rc);
235 memset(rc, 0, sizeof(shib_request_config));
236 ap_log_rerror(APLOG_MARK,APLOG_DEBUG|APLOG_NOERRNO,SH_AP_R(r), "shib_init_rc");
240 // generic global slot handlers
241 extern "C" const char* ap_set_global_string_slot(cmd_parms* parms, void*, const char* arg)
243 *((char**)(parms->info))=ap_pstrdup(parms->pool,arg);
247 extern "C" const char* shib_set_server_string_slot(cmd_parms* parms, void*, const char* arg)
249 char* base=(char*)ap_get_module_config(parms->server->module_config,&mod_shib);
250 size_t offset=(size_t)parms->info;
251 *((char**)(base + offset))=ap_pstrdup(parms->pool,arg);
255 extern "C" const char* shib_ap_set_file_slot(cmd_parms* parms,
256 #ifdef SHIB_APACHE_13
257 char* arg1, char* arg2
259 void* arg1, const char* arg2
263 ap_set_file_slot(parms, arg1, arg2);
267 /********************************************************************************/
268 // Apache ShibTarget subclass(es) here.
270 class ShibTargetApache : public AbstractSPRequest
272 mutable string m_body;
273 mutable bool m_gotBody;
274 mutable vector<string> m_certs;
278 shib_dir_config* m_dc;
279 shib_server_config* m_sc;
280 shib_request_config* m_rc;
282 ShibTargetApache(request_rec* req) : m_gotBody(false) {
283 m_sc = (shib_server_config*)ap_get_module_config(req->server->module_config, &mod_shib);
284 m_dc = (shib_dir_config*)ap_get_module_config(req->per_dir_config, &mod_shib);
285 m_rc = (shib_request_config*)ap_get_module_config(req->request_config, &mod_shib);
288 virtual ~ShibTargetApache() {}
290 const char* getScheme() const {
291 return m_sc->szScheme ? m_sc->szScheme : ap_http_method(m_req);
293 const char* getHostname() const {
294 return ap_get_server_name(m_req);
296 int getPort() const {
297 return ap_get_server_port(m_req);
299 const char* getRequestURI() const {
300 return m_req->unparsed_uri;
302 const char* getMethod() const {
303 return m_req->method;
305 string getContentType() const {
306 const char* type = ap_table_get(m_req->headers_in, "Content-Type");
307 return type ? type : "";
309 long getContentLength() const {
310 return m_gotBody ? m_body.length() : m_req->remaining;
312 string getRemoteAddr() const {
313 return m_req->connection->remote_ip;
315 void log(SPLogLevel level, const string& msg) const {
316 AbstractSPRequest::log(level,msg);
319 (level == SPDebug ? APLOG_DEBUG :
320 (level == SPInfo ? APLOG_INFO :
321 (level == SPWarn ? APLOG_WARNING :
322 (level == SPError ? APLOG_ERR : APLOG_CRIT))))|APLOG_NOERRNO,
327 const char* getQueryString() const { return m_req->args; }
328 const char* getRequestBody() const {
329 if (m_gotBody || m_req->method_number==M_GET)
330 return m_body.c_str();
331 // Read the posted data
332 if (ap_setup_client_block(m_req, REQUEST_CHUNKED_DECHUNK) != OK) {
334 log(SPError, "Apache function (setup_client_block) failed while reading request body.");
335 return m_body.c_str();
337 if (!ap_should_client_block(m_req)) {
339 log(SPError, "Apache function (should_client_block) failed while reading request body.");
340 return m_body.c_str();
342 if (m_req->remaining > 1024*1024)
343 throw opensaml::SecurityPolicyException("Blocked request body larger than 1M size limit.");
346 char buff[HUGE_STRING_LEN];
347 ap_hard_timeout("[mod_shib] getRequestBody", m_req);
348 while ((len=ap_get_client_block(m_req, buff, sizeof(buff))) > 0) {
349 ap_reset_timeout(m_req);
350 m_body.append(buff, len);
352 ap_kill_timeout(m_req);
353 return m_body.c_str();
355 void clearHeader(const char* name) {
356 if (m_dc->bUseEnvVars!=0) {
357 // ap_log_rerror(APLOG_MARK,APLOG_DEBUG|APLOG_NOERRNO,SH_AP_R(m_req), "shib_clear_header: env\n");
358 if (m_rc && m_rc->env) ap_table_unset(m_rc->env, name);
360 // ap_log_rerror(APLOG_MARK,APLOG_DEBUG|APLOG_NOERRNO,SH_AP_R(m_req), "shib_clear_header: hdr\n");
361 ap_table_unset(m_req->headers_in, name);
362 ap_table_set(m_req->headers_in, name, g_unsetHeaderValue.c_str());
365 void setHeader(const char* name, const char* value) {
366 if (m_dc->bUseEnvVars!=0) {
368 // this happens on subrequests
369 // ap_log_rerror(APLOG_MARK,APLOG_DEBUG|APLOG_NOERRNO,SH_AP_R(m_req), "shib_setheader: no_m_rc\n");
370 m_rc = init_request_config(m_req);
372 if (!m_rc->env) m_rc->env = ap_make_table(m_req->pool, 10);
373 // ap_log_rerror(APLOG_MARK,APLOG_DEBUG|APLOG_NOERRNO,SH_AP_R(m_req), "shib_set_env: %s=%s\n", name, value?value:"Null");
374 ap_table_set(m_rc->env, name, value?value:"");
377 ap_table_set(m_req->headers_in, name, value);
380 string getHeader(const char* name) const {
381 const char* hdr = ap_table_get(m_req->headers_in, name);
382 return string(hdr ? hdr : "");
384 string getSecureHeader(const char* name) const {
385 if (m_dc->bUseEnvVars!=0) {
387 if (m_rc && m_rc->env)
388 hdr = ap_table_get(m_rc->env, name);
391 return string(hdr ? hdr : "");
393 return getHeader(name);
395 void setRemoteUser(const char* user) {
396 SH_AP_USER(m_req) = user ? ap_pstrdup(m_req->pool, user) : NULL;
398 string getRemoteUser() const {
399 return string(SH_AP_USER(m_req) ? SH_AP_USER(m_req) : "");
401 void setContentType(const char* type) {
402 m_req->content_type = ap_psprintf(m_req->pool, type);
404 void setResponseHeader(const char* name, const char* value) {
405 #ifdef SHIB_DEFERRED_HEADERS
407 // this happens on subrequests
408 m_rc = init_request_config(m_req);
409 ap_table_add(m_rc->hdr_err, name, value);
410 ap_table_add(m_rc->hdr_out, name, value);
412 ap_table_add(m_req->err_headers_out, name, value);
415 long sendResponse(istream& in, long status) {
416 ap_send_http_header(m_req);
420 ap_rwrite(buf,in.gcount(),m_req);
422 if (status!=XMLTOOLING_HTTP_STATUS_OK)
423 m_req->status = status;
426 long sendRedirect(const char* url) {
427 ap_table_set(m_req->headers_out, "Location", url);
430 const vector<string>& getClientCertificates() const {
431 if (m_certs.empty()) {
432 const char* cert = ap_table_get(m_req->subprocess_env, "SSL_CLIENT_CERT");
434 m_certs.push_back(cert);
437 cert = ap_table_get(m_req->subprocess_env, ap_psprintf(m_req->pool, "SSL_CLIENT_CERT_CHAIN_%d", i++));
439 m_certs.push_back(cert);
444 long returnDecline(void) { return DECLINED; }
445 long returnOK(void) { return OK; }
448 /********************************************************************************/
451 extern "C" int shib_check_user(request_rec* r)
453 // Short-circuit entirely?
454 if (((shib_dir_config*)ap_get_module_config(r->per_dir_config, &mod_shib))->bOff==1)
457 ap_log_rerror(APLOG_MARK,APLOG_DEBUG|APLOG_NOERRNO,SH_AP_R(r), "shib_check_user(%d): ENTER\n", (int)getpid());
459 ostringstream threadid;
460 threadid << "[" << getpid() << "] shib_check_user" << '\0';
461 xmltooling::NDC ndc(threadid.str().c_str());
464 ShibTargetApache sta(r);
466 // Check user authentication and export information, then set the handler bypass
467 pair<bool,long> res = sta.getServiceProvider().doAuthentication(sta,true);
468 apr_pool_userdata_setn((const void*)42,g_UserDataKey,NULL,r->pool);
469 if (res.first) return res.second;
471 // user auth was okay -- export the assertions now
472 res = sta.getServiceProvider().doExport(sta);
473 if (res.first) return res.second;
475 // export happened successfully.. this user is ok.
478 catch (exception& e) {
479 ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, SH_AP_R(r), "shib_check_user threw an exception: %s", e.what());
484 ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, SH_AP_R(r), "shib_check_user threw an uncaught exception!");
490 extern "C" int shib_handler(request_rec* r)
492 // Short-circuit entirely?
493 if (((shib_dir_config*)ap_get_module_config(r->per_dir_config, &mod_shib))->bOff==1)
496 ostringstream threadid;
497 threadid << "[" << getpid() << "] shib_handler" << '\0';
498 xmltooling::NDC ndc(threadid.str().c_str());
500 #ifndef SHIB_APACHE_13
501 // With 2.x, this handler always runs, though last.
502 // We check if shib_check_user ran, because it will detect a handler request
503 // and dispatch it directly.
505 apr_pool_userdata_get(&data,g_UserDataKey,r->pool);
506 if (data==(const void*)42) {
507 ap_log_rerror(APLOG_MARK,APLOG_DEBUG|APLOG_NOERRNO,SH_AP_R(r),"shib_handler skipped since check_user ran");
512 ap_log_rerror(APLOG_MARK,APLOG_DEBUG|APLOG_NOERRNO,SH_AP_R(r),"shib_handler(%d): ENTER: %s", (int)getpid(), r->handler);
515 ShibTargetApache sta(r);
517 pair<bool,long> res = sta.getServiceProvider().doHandler(sta);
518 if (res.first) return res.second;
520 ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, SH_AP_R(r), "doHandler() did not do anything.");
523 catch (exception& e) {
524 ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, SH_AP_R(r), "shib_handler threw an exception: %s", e.what());
529 ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, SH_AP_R(r), "shib_handler threw an uncaught exception!");
536 * shib_auth_checker() -- a simple resource manager to
537 * process the .htaccess settings
539 extern "C" int shib_auth_checker(request_rec* r)
541 // Short-circuit entirely?
542 if (((shib_dir_config*)ap_get_module_config(r->per_dir_config, &mod_shib))->bOff==1)
545 ap_log_rerror(APLOG_MARK,APLOG_DEBUG|APLOG_NOERRNO,SH_AP_R(r), "shib_auth_checker(%d): ENTER", (int)getpid());
547 ostringstream threadid;
548 threadid << "[" << getpid() << "] shib_auth_checker" << '\0';
549 xmltooling::NDC ndc(threadid.str().c_str());
552 ShibTargetApache sta(r);
554 pair<bool,long> res = sta.getServiceProvider().doAuthorization(sta);
555 if (res.first) return res.second;
560 catch (exception& e) {
561 ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, SH_AP_R(r), "shib_auth_checker threw an exception: %s", e.what());
566 ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, SH_AP_R(r), "shib_auth_checker threw an uncaught exception!");
572 // Access control plugin that enforces htaccess rules
573 class htAccessControl : virtual public AccessControl
577 ~htAccessControl() {}
578 Lockable* lock() {return this;}
580 bool authorized(const SPRequest& request, const Session* session) const;
582 bool checkAttribute(const SPRequest& request, const Attribute* attr, const char* toMatch, RegularExpression* re) const;
585 AccessControl* htAccessFactory(const xercesc::DOMElement* const & e)
587 return new htAccessControl();
590 class ApacheRequestMapper : public virtual RequestMapper, public virtual PropertySet
593 ApacheRequestMapper(const xercesc::DOMElement* e);
594 ~ApacheRequestMapper() { delete m_mapper; delete m_htaccess; delete m_staKey; delete m_propsKey; }
595 Lockable* lock() { return m_mapper->lock(); }
596 void unlock() { m_staKey->setData(NULL); m_propsKey->setData(NULL); m_mapper->unlock(); }
597 Settings getSettings(const SPRequest& request) const;
599 void setParent(const PropertySet*) {}
600 pair<bool,bool> getBool(const char* name, const char* ns=NULL) const;
601 pair<bool,const char*> getString(const char* name, const char* ns=NULL) const;
602 pair<bool,const XMLCh*> getXMLString(const char* name, const char* ns=NULL) const;
603 pair<bool,unsigned int> getUnsignedInt(const char* name, const char* ns=NULL) const;
604 pair<bool,int> getInt(const char* name, const char* ns=NULL) const;
605 const PropertySet* getPropertySet(const char* name, const char* ns="urn:mace:shibboleth:2.0:native:sp:config") const;
606 const xercesc::DOMElement* getElement() const;
609 RequestMapper* m_mapper;
611 ThreadKey* m_propsKey;
612 AccessControl* m_htaccess;
615 RequestMapper* ApacheRequestMapFactory(const xercesc::DOMElement* const & e)
617 return new ApacheRequestMapper(e);
620 ApacheRequestMapper::ApacheRequestMapper(const xercesc::DOMElement* e) : m_mapper(NULL), m_staKey(NULL), m_propsKey(NULL), m_htaccess(NULL)
622 m_mapper=SPConfig::getConfig().RequestMapperManager.newPlugin(XML_REQUEST_MAPPER,e);
623 m_htaccess=new htAccessControl();
624 m_staKey=ThreadKey::create(NULL);
625 m_propsKey=ThreadKey::create(NULL);
628 RequestMapper::Settings ApacheRequestMapper::getSettings(const SPRequest& request) const
630 Settings s=m_mapper->getSettings(request);
631 m_staKey->setData((void*)dynamic_cast<const ShibTargetApache*>(&request));
632 m_propsKey->setData((void*)s.first);
633 return pair<const PropertySet*,AccessControl*>(this,s.second ? s.second : m_htaccess);
636 pair<bool,bool> ApacheRequestMapper::getBool(const char* name, const char* ns) const
638 const ShibTargetApache* sta=reinterpret_cast<const ShibTargetApache*>(m_staKey->getData());
639 const PropertySet* s=reinterpret_cast<const PropertySet*>(m_propsKey->getData());
641 // Override Apache-settable boolean properties.
642 if (name && !strcmp(name,"requireSession") && sta->m_dc->bRequireSession==1)
643 return make_pair(true,true);
644 else if (name && !strcmp(name,"exportAssertion") && sta->m_dc->bExportAssertion==1)
645 return make_pair(true,true);
647 return s ? s->getBool(name,ns) : make_pair(false,false);
650 pair<bool,const char*> ApacheRequestMapper::getString(const char* name, const char* ns) const
652 const ShibTargetApache* sta=reinterpret_cast<const ShibTargetApache*>(m_staKey->getData());
653 const PropertySet* s=reinterpret_cast<const PropertySet*>(m_propsKey->getData());
655 // Override Apache-settable string properties.
656 if (name && !strcmp(name,"authType")) {
657 const char *auth_type=ap_auth_type(sta->m_req);
659 // Check for Basic Hijack
660 if (!strcasecmp(auth_type, "basic") && sta->m_dc->bBasicHijack == 1)
661 auth_type = "shibboleth";
662 return make_pair(true,auth_type);
665 else if (name && !strcmp(name,"applicationId") && sta->m_dc->szApplicationId)
666 return pair<bool,const char*>(true,sta->m_dc->szApplicationId);
667 else if (name && !strcmp(name,"requireSessionWith") && sta->m_dc->szRequireWith)
668 return pair<bool,const char*>(true,sta->m_dc->szRequireWith);
669 else if (name && !strcmp(name,"redirectToSSL") && sta->m_dc->szRedirectToSSL)
670 return pair<bool,const char*>(true,sta->m_dc->szRedirectToSSL);
672 return s ? s->getString(name,ns) : pair<bool,const char*>(false,NULL);
675 pair<bool,const XMLCh*> ApacheRequestMapper::getXMLString(const char* name, const char* ns) const
677 const PropertySet* s=reinterpret_cast<const PropertySet*>(m_propsKey->getData());
678 return s ? s->getXMLString(name,ns) : pair<bool,const XMLCh*>(false,NULL);
681 pair<bool,unsigned int> ApacheRequestMapper::getUnsignedInt(const char* name, const char* ns) const
683 const ShibTargetApache* sta=reinterpret_cast<const ShibTargetApache*>(m_staKey->getData());
684 const PropertySet* s=reinterpret_cast<const PropertySet*>(m_propsKey->getData());
686 // Override Apache-settable int properties.
687 if (name && !strcmp(name,"redirectToSSL") && sta->m_dc->szRedirectToSSL)
688 return pair<bool,unsigned int>(true,strtol(sta->m_dc->szRedirectToSSL,NULL,10));
690 return s ? s->getUnsignedInt(name,ns) : pair<bool,unsigned int>(false,0);
693 pair<bool,int> ApacheRequestMapper::getInt(const char* name, const char* ns) const
695 const ShibTargetApache* sta=reinterpret_cast<const ShibTargetApache*>(m_staKey->getData());
696 const PropertySet* s=reinterpret_cast<const PropertySet*>(m_propsKey->getData());
698 // Override Apache-settable int properties.
699 if (name && !strcmp(name,"redirectToSSL") && sta->m_dc->szRedirectToSSL)
700 return pair<bool,int>(true,atoi(sta->m_dc->szRedirectToSSL));
702 return s ? s->getInt(name,ns) : pair<bool,int>(false,0);
705 const PropertySet* ApacheRequestMapper::getPropertySet(const char* name, const char* ns) const
707 const PropertySet* s=reinterpret_cast<const PropertySet*>(m_propsKey->getData());
708 return s ? s->getPropertySet(name,ns) : NULL;
711 const xercesc::DOMElement* ApacheRequestMapper::getElement() const
713 const PropertySet* s=reinterpret_cast<const PropertySet*>(m_propsKey->getData());
714 return s ? s->getElement() : NULL;
717 static SH_AP_TABLE* groups_for_user(request_rec* r, const char* user, char* grpfile)
720 SH_AP_TABLE* grps=ap_make_table(r->pool,15);
721 char l[MAX_STRING_LEN];
722 const char *group_name, *ll, *w;
724 #ifdef SHIB_APACHE_13
725 if (!(f=ap_pcfg_openfile(r->pool,grpfile))) {
727 if (ap_pcfg_openfile(&f,r->pool,grpfile) != APR_SUCCESS) {
729 ap_log_rerror(APLOG_MARK,APLOG_DEBUG,SH_AP_R(r),"groups_for_user() could not open group file: %s\n",grpfile);
734 #ifdef SHIB_APACHE_13
735 sp=ap_make_sub_pool(r->pool);
737 if (apr_pool_create(&sp,r->pool) != APR_SUCCESS) {
738 ap_log_rerror(APLOG_MARK,APLOG_ERR,0,r,
739 "groups_for_user() could not create a subpool");
744 while (!(ap_cfg_getline(l,MAX_STRING_LEN,f))) {
745 if ((*l=='#') || (!*l))
750 group_name=ap_getword(sp,&ll,':');
753 w=ap_getword_conf(sp,&ll);
754 if (!strcmp(w,user)) {
755 ap_table_setn(grps,ap_pstrdup(r->pool,group_name),"in");
765 bool htAccessControl::checkAttribute(const SPRequest& request, const Attribute* attr, const char* toMatch, RegularExpression* re) const
767 bool caseSensitive = attr->isCaseSensitive();
768 const vector<string>& vals = attr->getSerializedValues();
769 for (vector<string>::const_iterator v=vals.begin(); v!=vals.end(); ++v) {
771 auto_ptr<XMLCh> trans(fromUTF8(v->c_str()));
772 if (re->matches(trans.get())) {
773 request.log(SPRequest::SPDebug,
774 string("htAccessControl plugin expecting regexp ") + toMatch + ", got " + *v + ": authorization granted"
779 else if ((caseSensitive && *v == toMatch) || (!caseSensitive && !strcasecmp(v->c_str(), toMatch))) {
780 request.log(SPRequest::SPDebug,
781 string("htAccessControl plugin expecting ") + toMatch + ", got " + *v + ": authorization granted."
786 request.log(SPRequest::SPDebug,
787 string("htAccessControl plugin expecting ") + toMatch + ", got " + *v + ": authorization not granted."
794 bool htAccessControl::authorized(const SPRequest& request, const Session* session) const
796 // Make sure the object is our type.
797 const ShibTargetApache* sta=dynamic_cast<const ShibTargetApache*>(&request);
799 throw ConfigurationException("Request wrapper object was not of correct type.");
803 int m=sta->m_req->method_number;
804 bool method_restricted=false;
807 const array_header* reqs_arr=ap_requires(sta->m_req);
811 require_line* reqs=(require_line*)reqs_arr->elts;
813 ap_log_rerror(APLOG_MARK,APLOG_DEBUG|APLOG_NOERRNO,SH_AP_R(sta->m_req),"REQUIRE nelts: %d", reqs_arr->nelts);
814 ap_log_rerror(APLOG_MARK,APLOG_DEBUG|APLOG_NOERRNO,SH_AP_R(sta->m_req),"REQUIRE all: %d", sta->m_dc->bRequireAll);
816 vector<bool> auth_OK(reqs_arr->nelts,false);
818 #define SHIB_AP_CHECK_IS_OK { \
819 if (sta->m_dc->bRequireAll < 1) \
825 for (int x=0; x<reqs_arr->nelts; x++) {
827 if (!(reqs[x].method_mask & (1 << m)))
829 method_restricted=true;
830 string remote_user = request.getRemoteUser();
832 t = reqs[x].requirement;
833 w = ap_getword_white(sta->m_req->pool, &t);
835 if (!strcasecmp(w,"shibboleth")) {
836 // This is a dummy rule needed because Apache conflates authn and authz.
837 // Without some require rule, AuthType is ignored and no check_user hooks run.
840 else if (!strcmp(w,"valid-user")) {
842 request.log(SPRequest::SPDebug,"htAccessControl plugin accepting valid-user based on active session");
846 request.log(SPRequest::SPError,"htAccessControl plugin rejecting access for valid-user rule, no session is active");
848 else if (!strcmp(w,"user") && !remote_user.empty()) {
851 w=ap_getword_conf(sta->m_req->pool,&t);
859 // To do regex matching, we have to convert from UTF-8.
860 auto_ptr<XMLCh> trans(fromUTF8(w));
861 RegularExpression re(trans.get());
862 auto_ptr<XMLCh> trans2(fromUTF8(remote_user.c_str()));
863 if (re.matches(trans2.get())) {
864 request.log(SPRequest::SPDebug, string("htAccessControl plugin accepting user (") + w + ")");
868 catch (XMLException& ex) {
869 auto_ptr_char tmp(ex.getMessage());
870 request.log(SPRequest::SPError,
871 string("htAccessControl plugin caught exception while parsing regular expression (") + w + "): " + tmp.get());
874 else if (remote_user==w) {
875 request.log(SPRequest::SPDebug, string("htAccessControl plugin accepting user (") + w + ")");
880 else if (!strcmp(w,"group")) {
881 SH_AP_TABLE* grpstatus=NULL;
882 if (sta->m_dc->szAuthGrpFile && !remote_user.empty()) {
883 request.log(SPRequest::SPDebug,string("htAccessControl plugin using groups file: ") + sta->m_dc->szAuthGrpFile);
884 grpstatus=groups_for_user(sta->m_req,remote_user.c_str(),sta->m_dc->szAuthGrpFile);
890 w=ap_getword_conf(sta->m_req->pool,&t);
891 if (ap_table_get(grpstatus,w)) {
892 request.log(SPRequest::SPDebug, string("htAccessControl plugin accepting group (") + w + ")");
898 // Map alias in rule to the attribute.
900 request.log(SPRequest::SPError, "htAccessControl plugin not given a valid session to evaluate, are you using lazy sessions?");
904 // Find the attribute(s) matching the require rule.
905 pair<multimap<string,Attribute*>::const_iterator,multimap<string,Attribute*>::const_iterator> attrs =
906 session->getAttributes().equal_range(w);
907 if (attrs.first == attrs.second) {
908 request.log(SPRequest::SPWarn, string("htAccessControl rule requires attribute (") + w + "), not found in session");
914 while (!auth_OK[x] && *t) {
915 w=ap_getword_conf(sta->m_req->pool,&t);
922 auto_ptr<RegularExpression> re;
925 auto_ptr<XMLCh> trans(fromUTF8(w));
926 auto_ptr<xercesc::RegularExpression> temp(new xercesc::RegularExpression(trans.get()));
930 for (; !auth_OK[x] && attrs.first!=attrs.second; ++attrs.first) {
931 if (checkAttribute(request, attrs.first->second, w, regexp ? re.get() : NULL)) {
936 catch (XMLException& ex) {
937 auto_ptr_char tmp(ex.getMessage());
938 request.log(SPRequest::SPError,
939 string("htAccessControl plugin caught exception while parsing regular expression (") + w + "): " + tmp.get()
946 // check if all require directives are true
947 bool auth_all_OK = true;
948 for (int i= 0; i<reqs_arr->nelts; i++) {
949 auth_all_OK &= auth_OK[i];
951 if (auth_all_OK || !method_restricted)
957 #ifndef SHIB_APACHE_13
960 * Empty cleanup hook, Apache 2.x doesn't check NULL very well...
962 extern "C" apr_status_t shib_exit(void* data)
968 ap_log_error(APLOG_MARK,APLOG_DEBUG|APLOG_NOERRNO,0,NULL,"shib_exit() done");
974 // Initial look at a request - create the per-request structure
975 static int shib_post_read(request_rec *r)
977 shib_request_config* rc = init_request_config(r);
979 ap_log_rerror(APLOG_MARK,APLOG_DEBUG|APLOG_NOERRNO,SH_AP_R(r), "shib_post_read: E=%s", rc->env?"env":"hdr");
981 #ifdef SHIB_DEFERRED_HEADERS
982 rc->hdr_out = ap_make_table(r->pool, 5);
983 rc->hdr_err = ap_make_table(r->pool, 5);
988 // fixups: set environment vars
990 extern "C" int shib_fixups(request_rec* r)
992 shib_request_config *rc = (shib_request_config*)ap_get_module_config(r->request_config, &mod_shib);
993 shib_dir_config *dc = (shib_dir_config*)ap_get_module_config(r->per_dir_config, &mod_shib);
994 if (dc->bOff==1 || dc->bUseEnvVars==0)
997 ap_log_rerror(APLOG_MARK,APLOG_DEBUG|APLOG_NOERRNO,SH_AP_R(r), "shib_fixup(%d): ENTER", (int)getpid());
999 if (rc==NULL || rc->env==NULL || ap_is_empty_table(rc->env))
1002 ap_log_rerror(APLOG_MARK,APLOG_DEBUG|APLOG_NOERRNO,SH_AP_R(r), "shib_fixup adding %d vars", ap_table_elts(rc->env)->nelts);
1003 r->subprocess_env = ap_overlay_tables(r->pool, r->subprocess_env, rc->env);
1010 * Cleanup the (per-process) pool info.
1012 #ifdef SHIB_APACHE_13
1013 extern "C" void shib_child_exit(server_rec* s, SH_AP_POOL* p)
1016 extern "C" apr_status_t shib_child_exit(void* data)
1018 server_rec* s = NULL;
1021 ap_log_error(APLOG_MARK,APLOG_DEBUG|APLOG_NOERRNO,SH_AP_R(s),"shib_child_exit(%d) dealing with g_Config..", (int)getpid());
1024 ap_log_error(APLOG_MARK,APLOG_DEBUG|APLOG_NOERRNO,SH_AP_R(s),"shib_child_exit() done");
1026 #ifndef SHIB_APACHE_13
1032 * shire_child_init()
1033 * Things to do when the child process is initialized.
1034 * (or after the configs are read in apache-2)
1036 #ifdef SHIB_APACHE_13
1037 extern "C" void shib_child_init(server_rec* s, SH_AP_POOL* p)
1039 extern "C" void shib_child_init(apr_pool_t* p, server_rec* s)
1042 // Initialize runtime components.
1044 ap_log_error(APLOG_MARK,APLOG_DEBUG|APLOG_NOERRNO,SH_AP_R(s),"shib_child_init(%d) starting", (int)getpid());
1047 ap_log_error(APLOG_MARK,APLOG_ERR|APLOG_NOERRNO,SH_AP_R(s),"shib_child_init() already initialized!");
1051 g_Config=&SPConfig::getConfig();
1052 g_Config->setFeatures(
1053 SPConfig::Listener |
1055 SPConfig::RequestMapping |
1056 SPConfig::InProcess |
1059 if (!g_Config->init(g_szSchemaDir)) {
1060 ap_log_error(APLOG_MARK,APLOG_CRIT|APLOG_NOERRNO,SH_AP_R(s),"shib_child_init() failed to initialize libraries");
1063 g_Config->AccessControlManager.registerFactory(HT_ACCESS_CONTROL,&htAccessFactory);
1064 g_Config->RequestMapperManager.registerFactory(NATIVE_REQUEST_MAPPER,&ApacheRequestMapFactory);
1067 xercesc::DOMDocument* dummydoc=XMLToolingConfig::getConfig().getParser().newDocument();
1068 XercesJanitor<xercesc::DOMDocument> docjanitor(dummydoc);
1069 xercesc::DOMElement* dummy = dummydoc->createElementNS(NULL,path);
1070 auto_ptr_XMLCh src(g_szSHIBConfig);
1071 dummy->setAttributeNS(NULL,path,src.get());
1072 dummy->setAttributeNS(NULL,validate,xmlconstants::XML_ONE);
1074 g_Config->setServiceProvider(g_Config->ServiceProviderManager.newPlugin(XML_SERVICE_PROVIDER,dummy));
1075 g_Config->getServiceProvider()->init();
1077 catch (exception& ex) {
1078 ap_log_error(APLOG_MARK,APLOG_CRIT|APLOG_NOERRNO,SH_AP_R(s),ex.what());
1079 ap_log_error(APLOG_MARK,APLOG_CRIT|APLOG_NOERRNO,SH_AP_R(s),"shib_child_init() failed to load configuration");
1083 ServiceProvider* sp=g_Config->getServiceProvider();
1084 xmltooling::Locker locker(sp);
1085 const PropertySet* props=sp->getPropertySet("Local");
1087 pair<bool,const char*> unsetValue=props->getString("unsetHeaderValue");
1088 if (unsetValue.first)
1089 g_unsetHeaderValue = unsetValue.second;
1092 // Set the cleanup handler
1093 apr_pool_cleanup_register(p, NULL, &shib_exit, &shib_child_exit);
1095 ap_log_error(APLOG_MARK,APLOG_DEBUG|APLOG_NOERRNO,SH_AP_R(s),"shib_child_init() done");
1099 #ifdef SHIB_DEFERRED_HEADERS
1100 static void set_output_filter(request_rec *r)
1102 ap_add_output_filter("SHIB_HEADERS_OUT", NULL, r, r->connection);
1105 static void set_error_filter(request_rec *r)
1107 ap_add_output_filter("SHIB_HEADERS_ERR", NULL, r, r->connection);
1110 static int _table_add(void *v, const char *key, const char *value)
1112 apr_table_addn((apr_table_t*)v, key, value);
1116 static apr_status_t do_output_filter(ap_filter_t *f, apr_bucket_brigade *in)
1118 request_rec *r = f->r;
1119 shib_request_config *rc = (shib_request_config*) ap_get_module_config(r->request_config, &mod_shib);
1122 ap_log_rerror(APLOG_MARK,APLOG_DEBUG|APLOG_NOERRNO,SH_AP_R(r),"shib_out_filter: merging %d headers", apr_table_elts(rc->hdr_out)->nelts);
1123 apr_table_do(_table_add,r->headers_out, rc->hdr_out,NULL);
1124 // can't use overlap call because it will collapse Set-Cookie headers
1125 //apr_table_overlap(r->headers_out, rc->hdr_out, APR_OVERLAP_TABLES_MERGE);
1128 /* remove ourselves from the filter chain */
1129 ap_remove_output_filter(f);
1131 /* send the data up the stack */
1132 return ap_pass_brigade(f->next,in);
1135 static apr_status_t do_error_filter(ap_filter_t *f, apr_bucket_brigade *in)
1137 request_rec *r = f->r;
1138 shib_request_config *rc = (shib_request_config*) ap_get_module_config(r->request_config, &mod_shib);
1141 ap_log_rerror(APLOG_MARK,APLOG_DEBUG|APLOG_NOERRNO,SH_AP_R(r),"shib_err_filter: merging %d headers", apr_table_elts(rc->hdr_err)->nelts);
1142 apr_table_do(_table_add,r->err_headers_out, rc->hdr_err,NULL);
1143 // can't use overlap call because it will collapse Set-Cookie headers
1144 //apr_table_overlap(r->err_headers_out, rc->hdr_err, APR_OVERLAP_TABLES_MERGE);
1147 /* remove ourselves from the filter chain */
1148 ap_remove_output_filter(f);
1150 /* send the data up the stack */
1151 return ap_pass_brigade(f->next,in);
1153 #endif // SHIB_DEFERRED_HEADERS
1155 typedef const char* (*config_fn_t)(void);
1157 #ifdef SHIB_APACHE_13
1159 // SHIB Module commands
1161 static command_rec shire_cmds[] = {
1162 {"ShibConfig", (config_fn_t)ap_set_global_string_slot, &g_szSHIBConfig,
1163 RSRC_CONF, TAKE1, "Path to shibboleth.xml config file"},
1164 {"ShibCatalogs", (config_fn_t)ap_set_global_string_slot, &g_szSchemaDir,
1165 RSRC_CONF, TAKE1, "Paths of XML schema catalogs"},
1166 {"ShibSchemaDir", (config_fn_t)ap_set_global_string_slot, &g_szSchemaDir,
1167 RSRC_CONF, TAKE1, "Paths of XML schema catalogs (deprecated in favor of ShibCatalogs)"},
1169 {"ShibURLScheme", (config_fn_t)shib_set_server_string_slot,
1170 (void *) XtOffsetOf (shib_server_config, szScheme),
1171 RSRC_CONF, TAKE1, "URL scheme to force into generated URLs for a vhost"},
1173 {"ShibDisable", (config_fn_t)ap_set_flag_slot,
1174 (void *) XtOffsetOf (shib_dir_config, bOff),
1175 OR_AUTHCFG, FLAG, "Disable all Shib module activity here to save processing effort"},
1176 {"ShibApplicationId", (config_fn_t)ap_set_string_slot,
1177 (void *) XtOffsetOf (shib_dir_config, szApplicationId),
1178 OR_AUTHCFG, TAKE1, "Set Shibboleth applicationId property for content"},
1179 {"ShibBasicHijack", (config_fn_t)ap_set_flag_slot,
1180 (void *) XtOffsetOf (shib_dir_config, bBasicHijack),
1181 OR_AUTHCFG, FLAG, "Respond to AuthType Basic and convert to shibboleth"},
1182 {"ShibRequireSession", (config_fn_t)ap_set_flag_slot,
1183 (void *) XtOffsetOf (shib_dir_config, bRequireSession),
1184 OR_AUTHCFG, FLAG, "Initiates a new session if one does not exist"},
1185 {"ShibRequireSessionWith", (config_fn_t)ap_set_string_slot,
1186 (void *) XtOffsetOf (shib_dir_config, szRequireWith),
1187 OR_AUTHCFG, TAKE1, "Initiates a new session if one does not exist using a specific SessionInitiator"},
1188 {"ShibExportAssertion", (config_fn_t)ap_set_flag_slot,
1189 (void *) XtOffsetOf (shib_dir_config, bExportAssertion),
1190 OR_AUTHCFG, FLAG, "Export SAML attribute assertion(s) to Shib-Attributes header"},
1191 {"ShibRedirectToSSL", (config_fn_t)ap_set_string_slot,
1192 (void *) XtOffsetOf (shib_dir_config, szRedirectToSSL),
1193 OR_AUTHCFG, TAKE1, "Redirect non-SSL requests to designated port" },
1194 {"AuthGroupFile", (config_fn_t)shib_ap_set_file_slot,
1195 (void *) XtOffsetOf (shib_dir_config, szAuthGrpFile),
1196 OR_AUTHCFG, TAKE1, "text file containing group names and member user IDs"},
1197 {"ShibRequireAll", (config_fn_t)ap_set_flag_slot,
1198 (void *) XtOffsetOf (shib_dir_config, bRequireAll),
1199 OR_AUTHCFG, FLAG, "All require directives must match"},
1200 {"ShibUseEnvironment", (config_fn_t)ap_set_flag_slot,
1201 (void *) XtOffsetOf (shib_dir_config, bUseEnvVars),
1202 OR_AUTHCFG, FLAG, "Export data in environment instead of headers (default)"},
1208 handler_rec shib_handlers[] = {
1209 { "shib-handler", shib_handler },
1213 module MODULE_VAR_EXPORT mod_shib = {
1214 STANDARD_MODULE_STUFF,
1215 NULL, /* initializer */
1216 create_shib_dir_config, /* dir config creater */
1217 merge_shib_dir_config, /* dir merger --- default is to override */
1218 create_shib_server_config, /* server config */
1219 merge_shib_server_config, /* merge server config */
1220 shire_cmds, /* command table */
1221 shib_handlers, /* handlers */
1222 NULL, /* filename translation */
1223 shib_check_user, /* check_user_id */
1224 shib_auth_checker, /* check auth */
1225 NULL, /* check access */
1226 NULL, /* type_checker */
1227 shib_fixups, /* fixups */
1229 NULL, /* header parser */
1230 shib_child_init, /* child_init */
1231 shib_child_exit, /* child_exit */
1232 shib_post_read /* post read-request */
1235 #elif defined(SHIB_APACHE_20) || defined(SHIB_APACHE_22)
1237 extern "C" void shib_register_hooks (apr_pool_t *p)
1239 #ifdef SHIB_DEFERRED_HEADERS
1240 ap_register_output_filter("SHIB_HEADERS_OUT", do_output_filter, NULL, AP_FTYPE_CONTENT_SET);
1241 ap_hook_insert_filter(set_output_filter, NULL, NULL, APR_HOOK_LAST);
1242 ap_register_output_filter("SHIB_HEADERS_ERR", do_error_filter, NULL, AP_FTYPE_CONTENT_SET);
1243 ap_hook_insert_error_filter(set_error_filter, NULL, NULL, APR_HOOK_LAST);
1244 ap_hook_post_read_request(shib_post_read, NULL, NULL, APR_HOOK_MIDDLE);
1246 ap_hook_child_init(shib_child_init, NULL, NULL, APR_HOOK_MIDDLE);
1247 ap_hook_check_user_id(shib_check_user, NULL, NULL, APR_HOOK_MIDDLE);
1248 ap_hook_auth_checker(shib_auth_checker, NULL, NULL, APR_HOOK_FIRST);
1249 ap_hook_handler(shib_handler, NULL, NULL, APR_HOOK_LAST);
1250 ap_hook_fixups(shib_fixups, NULL, NULL, APR_HOOK_MIDDLE);
1253 // SHIB Module commands
1256 static command_rec shib_cmds[] = {
1257 AP_INIT_TAKE1("ShibConfig",
1258 (config_fn_t)ap_set_global_string_slot, &g_szSHIBConfig,
1259 RSRC_CONF, "Path to shibboleth.xml config file"),
1260 AP_INIT_TAKE1("ShibCatalogs",
1261 (config_fn_t)ap_set_global_string_slot, &g_szSchemaDir,
1262 RSRC_CONF, "Paths of XML schema catalogs"),
1263 AP_INIT_TAKE1("ShibSchemaDir",
1264 (config_fn_t)ap_set_global_string_slot, &g_szSchemaDir,
1265 RSRC_CONF, "Paths of XML schema catalogs (deprecated in favor of ShibCatalogs)"),
1267 AP_INIT_TAKE1("ShibURLScheme",
1268 (config_fn_t)shib_set_server_string_slot,
1269 (void *) offsetof (shib_server_config, szScheme),
1270 RSRC_CONF, "URL scheme to force into generated URLs for a vhost"),
1272 AP_INIT_FLAG("ShibDisable", (config_fn_t)ap_set_flag_slot,
1273 (void *) offsetof (shib_dir_config, bOff),
1274 OR_AUTHCFG, "Disable all Shib module activity here to save processing effort"),
1275 AP_INIT_TAKE1("ShibApplicationId", (config_fn_t)ap_set_string_slot,
1276 (void *) offsetof (shib_dir_config, szApplicationId),
1277 OR_AUTHCFG, "Set Shibboleth applicationId property for content"),
1278 AP_INIT_FLAG("ShibBasicHijack", (config_fn_t)ap_set_flag_slot,
1279 (void *) offsetof (shib_dir_config, bBasicHijack),
1280 OR_AUTHCFG, "Respond to AuthType Basic and convert to shibboleth"),
1281 AP_INIT_FLAG("ShibRequireSession", (config_fn_t)ap_set_flag_slot,
1282 (void *) offsetof (shib_dir_config, bRequireSession),
1283 OR_AUTHCFG, "Initiates a new session if one does not exist"),
1284 AP_INIT_TAKE1("ShibRequireSessionWith", (config_fn_t)ap_set_string_slot,
1285 (void *) offsetof (shib_dir_config, szRequireWith),
1286 OR_AUTHCFG, "Initiates a new session if one does not exist using a specific SessionInitiator"),
1287 AP_INIT_FLAG("ShibExportAssertion", (config_fn_t)ap_set_flag_slot,
1288 (void *) offsetof (shib_dir_config, bExportAssertion),
1289 OR_AUTHCFG, "Export SAML attribute assertion(s) to Shib-Attributes header"),
1290 AP_INIT_TAKE1("ShibRedirectToSSL", (config_fn_t)ap_set_string_slot,
1291 (void *) offsetof (shib_dir_config, szRedirectToSSL),
1292 OR_AUTHCFG, "Redirect non-SSL requests to designated port"),
1293 AP_INIT_TAKE1("AuthGroupFile", (config_fn_t)shib_ap_set_file_slot,
1294 (void *) offsetof (shib_dir_config, szAuthGrpFile),
1295 OR_AUTHCFG, "Text file containing group names and member user IDs"),
1296 AP_INIT_FLAG("ShibRequireAll", (config_fn_t)ap_set_flag_slot,
1297 (void *) offsetof (shib_dir_config, bRequireAll),
1298 OR_AUTHCFG, "All require directives must match"),
1299 AP_INIT_FLAG("ShibUseEnvironment", (config_fn_t)ap_set_flag_slot,
1300 (void *) offsetof (shib_dir_config, bUseEnvVars),
1301 OR_AUTHCFG, "Export data in environment instead of headers (default)"),
1306 module AP_MODULE_DECLARE_DATA mod_shib = {
1307 STANDARD20_MODULE_STUFF,
1308 create_shib_dir_config, /* create dir config */
1309 merge_shib_dir_config, /* merge dir config --- default is to override */
1310 create_shib_server_config, /* create server config */
1311 merge_shib_server_config, /* merge server config */
1312 shib_cmds, /* command table */
1313 shib_register_hooks /* register hooks */
1317 #error "undefined APACHE version"