https://issues.shibboleth.net/jira/browse/SSPCPP-430
authorScott Cantor <cantor.2@osu.edu>
Wed, 21 Mar 2012 22:17:02 +0000 (22:17 +0000)
committerScott Cantor <cantor.2@osu.edu>
Wed, 21 Mar 2012 22:17:02 +0000 (22:17 +0000)
Shibboleth.sln
apache/Makefile.am
apache/mod_apache.cpp
apache/mod_shib24.vcxproj [new file with mode: 0644]
apache/mod_shib_24.cpp [new file with mode: 0644]
apache/mod_shib_24.rc [new file with mode: 0644]
configs/Makefile.am
configs/apache24.config.in [new file with mode: 0644]
configure.ac
shibboleth.spec.in

index afa63d0..b7c0145 100644 (file)
@@ -35,7 +35,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Config", "Config", "{2543BC
                configs\accessError.html = configs\accessError.html
                configs\apache.config.in = configs\apache.config.in
                configs\apache2.config.in = configs\apache2.config.in
-               configs\apache22.config.in = configs\apache22.config.in
+               configs\apache24.config.in = configs\apache24.config.in
                configs\attrChecker.html = configs\attrChecker.html
                configs\attribute-map.xml = configs\attribute-map.xml
                configs\attribute-policy.xml = configs\attribute-policy.xml
@@ -131,6 +131,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "memcache-store", "memcache-
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "plugins", "plugins\plugins.vcxproj", "{A2140D6E-C2C6-4329-84E3-2F530CEBE445}"
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_shib_24", "apache\mod_shib24.vcxproj", "{B44C0852-83B8-4FB2-A86E-097C9C8256D1}"
+EndProject
 Global
        GlobalSection(SolutionConfigurationPlatforms) = preSolution
                Debug|Win32 = Debug|Win32
@@ -265,6 +267,14 @@ Global
                {A2140D6E-C2C6-4329-84E3-2F530CEBE445}.Release|Win32.Build.0 = Release|Win32
                {A2140D6E-C2C6-4329-84E3-2F530CEBE445}.Release|x64.ActiveCfg = Release|x64
                {A2140D6E-C2C6-4329-84E3-2F530CEBE445}.Release|x64.Build.0 = Release|x64
+               {B44C0852-83B8-4FB2-A86E-097C9C8256D1}.Debug|Win32.ActiveCfg = Debug|Win32
+               {B44C0852-83B8-4FB2-A86E-097C9C8256D1}.Debug|Win32.Build.0 = Debug|Win32
+               {B44C0852-83B8-4FB2-A86E-097C9C8256D1}.Debug|x64.ActiveCfg = Debug|x64
+               {B44C0852-83B8-4FB2-A86E-097C9C8256D1}.Debug|x64.Build.0 = Debug|x64
+               {B44C0852-83B8-4FB2-A86E-097C9C8256D1}.Release|Win32.ActiveCfg = Release|Win32
+               {B44C0852-83B8-4FB2-A86E-097C9C8256D1}.Release|Win32.Build.0 = Release|Win32
+               {B44C0852-83B8-4FB2-A86E-097C9C8256D1}.Release|x64.ActiveCfg = Release|x64
+               {B44C0852-83B8-4FB2-A86E-097C9C8256D1}.Release|x64.Build.0 = Release|x64
        EndGlobalSection
        GlobalSection(SolutionProperties) = preSolution
                HideSolutionNode = FALSE
@@ -276,6 +286,7 @@ Global
                {68E9568B-476C-4289-B93C-893432378ADC} = {26BA8F84-6E42-41FA-9B13-5D3F4B5B2050}
                {1396D80A-8672-4224-9B02-95F3F4207CDB} = {26BA8F84-6E42-41FA-9B13-5D3F4B5B2050}
                {B44C0852-83B8-4FB2-A86E-097C9C8256D0} = {26BA8F84-6E42-41FA-9B13-5D3F4B5B2050}
+               {B44C0852-83B8-4FB2-A86E-097C9C8256D1} = {26BA8F84-6E42-41FA-9B13-5D3F4B5B2050}
                {666A63A7-983F-4C19-8411-207F24305197} = {96AE4FC9-45EF-4C18-9F3B-EDA439E26E4C}
                {26D4FABF-ACDE-4947-9C4A-7AE1B50CD83A} = {96AE4FC9-45EF-4C18-9F3B-EDA439E26E4C}
                {26D4FABF-ACDE-4947-9C4A-7AE1B50CD83B} = {96AE4FC9-45EF-4C18-9F3B-EDA439E26E4C}
index 0e010f1..4fd0f6e 100644 (file)
@@ -42,6 +42,21 @@ install-exec-hook:
 
 endif
 
-EXTRA_DIST = mod_apache.cpp mod_shib_13.cpp mod_shib_20.cpp mod_shib_22.cpp \
-       mod_shib13.vcxproj mod_shib20.vcxproj mod_shib22.vcxproj \
-       resource.h mod_shib_13.rc mod_shib_20.rc mod_shib_22.rc
+if BUILD_AP24
+modshib24dir = $(libdir)/@PACKAGE@
+modshib24_LTLIBRARIES = mod_shib_24.la
+mod_shib_24_la_SOURCES = mod_shib_24.cpp
+mod_shib_24_la_CXXFLAGS = $(APXS24_CFLAGS) -I$(APXS24_INCLUDE)
+mod_shib_24_la_LDFLAGS = -module -avoid-version
+mod_shib_24_la_LIBADD = $(LITE_LIBS) \
+  $(top_builddir)/shibsp/libshibsp-lite.la
+
+install-exec-hook:
+       for la in $(modshib24_LTLIBRARIES) ; do rm -f $(DESTDIR)$(modshib24dir)/$$la ; done
+
+endif
+
+EXTRA_DIST = mod_apache.cpp \
+       mod_shib_13.cpp mod_shib_20.cpp mod_shib_22.cpp mod_shib_24.cpp \
+       mod_shib13.vcxproj mod_shib20.vcxproj mod_shib22.vcxproj mod_shib24.vcxproj \
+       resource.h mod_shib_13.rc mod_shib_20.rc mod_shib_22.rc mod_shib_24.rc
index 6ecb324..26bc09b 100644 (file)
@@ -55,7 +55,8 @@
 #include <xmltooling/util/XMLHelper.h>
 
 #ifdef WIN32
-# include <winsock.h>
+# include <winsock2.h>
+# include <ws2tcpip.h>
 #endif
 
 #undef _XPG4_2
 #include <apr_pools.h>
 #endif
 
+#ifdef SHIB_APACHE_24
+#include <mod_auth.h>
+#endif
+
 #include <cstddef>
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>            // for getpid()
@@ -94,7 +99,12 @@ using namespace std;
 using xercesc::RegularExpression;
 using xercesc::XMLException;
 
-extern "C" module MODULE_VAR_EXPORT mod_shib;
+#ifdef APLOG_USE_MODULE
+    extern "C" module AP_MODULE_DECLARE_DATA mod_shib;
+    static int* const aplog_module_index = &(mod_shib.module_index);
+#else
+    extern "C" module MODULE_VAR_EXPORT mod_shib;
+#endif
 
 namespace {
     char* g_szSHIBConfig = nullptr;
@@ -114,7 +124,7 @@ namespace {
    Apache 2.0.49+ supports the filter method.
    Apache 1.3.x and lesser 2.0.x must write the headers directly. */
 
-#if (defined(SHIB_APACHE_20) || defined(SHIB_APACHE_22)) && AP_MODULE_MAGIC_AT_LEAST(20020903,6)
+#if (defined(SHIB_APACHE_20) || defined(SHIB_APACHE_22) || defined(SHIB_APACHE_24)) && AP_MODULE_MAGIC_AT_LEAST(20020903,6)
 #define SHIB_DEFERRED_HEADERS
 #endif
 
@@ -159,15 +169,20 @@ struct shib_dir_config
     SH_AP_TABLE* tSettings; // generic table of extensible settings
 
     // RM Configuration
+#ifdef SHIB_APACHE_24
+    int bRequestMapperAuthz;// support RequestMapper AccessControl plugins
+#else
     char* szAuthGrpFile;    // Auth GroupFile name
+       char* szAccessControl;  // path to "external" AccessControl plugin file
     int bRequireAll;        // all "known" require directives must match, otherwise OR logic
     int bAuthoritative;     // allow htaccess plugin to DECLINE when authz fails
+    int bCompatWith24;      // support 2.4-reserved require logic for compatibility
+#endif
 
     // Content Configuration
     char* szApplicationId;  // Shib applicationId value
     char* szRequireWith;    // require a session using a specific initiator?
     char* szRedirectToSSL;  // redirect non-SSL requests to SSL port
-       char* szAccessControl;  // path to "external" AccessControl plugin file
     int bOff;               // flat-out disable all Shib processing
     int bBasicHijack;       // activate for AuthType Basic?
     int bRequireSession;    // require a session?
@@ -182,13 +197,18 @@ extern "C" void* create_shib_dir_config (SH_AP_POOL* p, char* d)
 {
     shib_dir_config* dc=(shib_dir_config*)ap_pcalloc(p,sizeof(shib_dir_config));
     dc->tSettings = nullptr;
+#ifdef SHIB_APACHE_24
+    dc->bRequestMapperAuthz = -1;
+#else
     dc->szAuthGrpFile = nullptr;
+       dc->szAccessControl = nullptr;
     dc->bRequireAll = -1;
     dc->bAuthoritative = -1;
+    dc->bCompatWith24 = -1;
+#endif
     dc->szApplicationId = nullptr;
     dc->szRequireWith = nullptr;
     dc->szRedirectToSSL = nullptr;
-       dc->szAccessControl = nullptr;
     dc->bOff = -1;
     dc->bBasicHijack = -1;
     dc->bRequireSession = -1;
@@ -217,6 +237,9 @@ extern "C" void* merge_shib_dir_config (SH_AP_POOL* p, void* base, void* sub)
             dc->tSettings = ap_copy_table(p, child->tSettings);
     }
 
+#ifdef SHIB_APACHE_24
+    dc->bRequestMapperAuthz = ((child->bRequestMapperAuthz==-1) ? parent->bRequestMapperAuthz : child->bRequestMapperAuthz);
+#else
     if (child->szAuthGrpFile)
         dc->szAuthGrpFile=ap_pstrdup(p,child->szAuthGrpFile);
     else if (parent->szAuthGrpFile)
@@ -224,6 +247,14 @@ extern "C" void* merge_shib_dir_config (SH_AP_POOL* p, void* base, void* sub)
     else
         dc->szAuthGrpFile=nullptr;
 
+       if (child->szAccessControl)
+        dc->szAccessControl=ap_pstrdup(p,child->szAccessControl);
+    else if (parent->szAccessControl)
+        dc->szAccessControl=ap_pstrdup(p,parent->szAccessControl);
+    else
+        dc->szAccessControl=nullptr;
+#endif
+
     if (child->szApplicationId)
         dc->szApplicationId=ap_pstrdup(p,child->szApplicationId);
     else if (parent->szApplicationId)
@@ -245,131 +276,82 @@ extern "C" void* merge_shib_dir_config (SH_AP_POOL* p, void* base, void* sub)
     else
         dc->szRedirectToSSL=nullptr;
 
-       if (child->szAccessControl)
-        dc->szAccessControl=ap_pstrdup(p,child->szAccessControl);
-    else if (parent->szAccessControl)
-        dc->szAccessControl=ap_pstrdup(p,parent->szAccessControl);
-    else
-        dc->szAccessControl=nullptr;
-
-    dc->bOff=((child->bOff==-1) ? parent->bOff : child->bOff);
-    dc->bBasicHijack=((child->bBasicHijack==-1) ? parent->bBasicHijack : child->bBasicHijack);
-    dc->bRequireSession=((child->bRequireSession==-1) ? parent->bRequireSession : child->bRequireSession);
-    dc->bExportAssertion=((child->bExportAssertion==-1) ? parent->bExportAssertion : child->bExportAssertion);
-    dc->bRequireAll=((child->bRequireAll==-1) ? parent->bRequireAll : child->bRequireAll);
-    dc->bAuthoritative=((child->bAuthoritative==-1) ? parent->bAuthoritative : child->bAuthoritative);
-    dc->bUseEnvVars=((child->bUseEnvVars==-1) ? parent->bUseEnvVars : child->bUseEnvVars);
-    dc->bUseHeaders=((child->bUseHeaders==-1) ? parent->bUseHeaders : child->bUseHeaders);
-    dc->bExpireRedirects=((child->bExpireRedirects==-1) ? parent->bExpireRedirects : child->bExpireRedirects);
+    dc->bOff = ((child->bOff==-1) ? parent->bOff : child->bOff);
+    dc->bBasicHijack = ((child->bBasicHijack==-1) ? parent->bBasicHijack : child->bBasicHijack);
+    dc->bRequireSession = ((child->bRequireSession==-1) ? parent->bRequireSession : child->bRequireSession);
+    dc->bExportAssertion = ((child->bExportAssertion==-1) ? parent->bExportAssertion : child->bExportAssertion);
+#ifndef SHIB_APACHE_24
+    dc->bRequireAll = ((child->bRequireAll==-1) ? parent->bRequireAll : child->bRequireAll);
+    dc->bAuthoritative = ((child->bAuthoritative==-1) ? parent->bAuthoritative : child->bAuthoritative);
+    dc->bCompatWith24 = ((child->bCompatWith24==-1) ? parent->bCompatWith24 : child->bCompatWith24);
+#endif
+    dc->bUseEnvVars = ((child->bUseEnvVars==-1) ? parent->bUseEnvVars : child->bUseEnvVars);
+    dc->bUseHeaders = ((child->bUseHeaders==-1) ? parent->bUseHeaders : child->bUseHeaders);
+    dc->bExpireRedirects = ((child->bExpireRedirects==-1) ? parent->bExpireRedirects : child->bExpireRedirects);
     return dc;
 }
 
+class ShibTargetApache; // forward decl
+
 // per-request module structure
 struct shib_request_config
 {
-    SH_AP_TABLE *env;        // environment vars
+    SH_AP_TABLEenv;        // environment vars
 #ifdef SHIB_DEFERRED_HEADERS
-    SH_AP_TABLE *hdr_out;    // headers to browser
+    SH_AP_TABLE* hdr_out;    // headers to browser
+#endif
+#ifndef SHIB_APACHE_13
+    ShibTargetApache* sta;  // SP per-request structure wrapped around Apache's request
 #endif
 };
 
 // create a request record
-static shib_request_config *init_request_config(request_rec *r)
+static shib_request_configinit_request_config(request_rec *r)
 {
-    shib_request_config* rc=(shib_request_config*)ap_pcalloc(r->pool,sizeof(shib_request_config));
-    ap_set_module_config (r->request_config, &mod_shib, rc);
+    shib_request_config* rc = (shib_request_config*)ap_pcalloc(r->pool,sizeof(shib_request_config));
     memset(rc, 0, sizeof(shib_request_config));
-    ap_log_rerror(APLOG_MARK,APLOG_DEBUG|APLOG_NOERRNO,SH_AP_R(r), "shib_init_rc");
+    ap_set_module_config(r->request_config, &mod_shib, rc);
+    ap_log_rerror(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, SH_AP_R(r), "shib_init_rc");
     return rc;
 }
 
-// generic global slot handlers
-extern "C" const char* ap_set_global_string_slot(cmd_parms* parms, void*, const char* arg)
-{
-    *((char**)(parms->info))=ap_pstrdup(parms->pool,arg);
-    return nullptr;
-}
-
-extern "C" const char* shib_set_server_string_slot(cmd_parms* parms, void*, const char* arg)
-{
-    char* base=(char*)ap_get_module_config(parms->server->module_config,&mod_shib);
-    size_t offset=(size_t)parms->info;
-    *((char**)(base + offset))=ap_pstrdup(parms->pool,arg);
-    return nullptr;
-}
-
-extern "C" const char* shib_ap_set_file_slot(cmd_parms* parms,
-#ifdef SHIB_APACHE_13
-                                            char* arg1, char* arg2
-#else
-                                            void* arg1, const char* arg2
-#endif
-                                            )
-{
-  ap_set_file_slot(parms, arg1, arg2);
-  return DECLINE_CMD;
-}
-
-extern "C" const char* shib_table_set(cmd_parms* parms, shib_dir_config* dc, const char* arg1, const char* arg2)
-{
-    if (!dc->tSettings)
-        dc->tSettings = ap_make_table(parms->pool, 4);
-    ap_table_set(dc->tSettings, arg1, arg2);
-    return nullptr;
-}
-
-extern "C" const char* shib_set_acl_slot(cmd_parms* params, shib_dir_config* dc, char* arg)
-{
-    bool absolute;
-    switch (*arg) {
-        case 0:
-            absolute = false;
-            break;
-        case '/':
-        case '\\':
-            absolute = true;
-            break;
-        case '.':
-            absolute = (*(arg+1) == '.' || *(arg+1) == '/' || *(arg+1) == '\\');
-            break;
-        default:
-            absolute = *(arg+1) == ':';
-    }
-
-    if (absolute || !params->path)
-        dc->szAccessControl = ap_pstrdup(params->pool, arg);
-    else
-        dc->szAccessControl = ap_pstrcat(params->pool, params->path, arg);
-    return nullptr;
-}
-
 class ShibTargetApache : public AbstractSPRequest
 #if defined(SHIBSP_HAVE_GSSAPI) && !defined(SHIB_APACHE_13)
     , public GSSRequest
 #endif
 {
-  bool m_handler;
   mutable string m_body;
   mutable bool m_gotBody,m_firsttime;
   mutable vector<string> m_certs;
   set<string> m_allhttp;
 
 public:
+  bool m_handler;
   request_rec* m_req;
   shib_dir_config* m_dc;
   shib_server_config* m_sc;
   shib_request_config* m_rc;
 
-  ShibTargetApache(request_rec* req, bool handler, bool shib_check_user)
-      : AbstractSPRequest(SHIBSP_LOGCAT".Apache"), m_handler(handler), m_gotBody(false),m_firsttime(true) {
-    m_sc = (shib_server_config*)ap_get_module_config(req->server->module_config, &mod_shib);
-    m_dc = (shib_dir_config*)ap_get_module_config(req->per_dir_config, &mod_shib);
-    m_rc = (shib_request_config*)ap_get_module_config(req->request_config, &mod_shib);
-    m_req = req;
+  ShibTargetApache(request_rec* req) : AbstractSPRequest(SHIBSP_LOGCAT".Apache"),
+        m_gotBody(false),m_firsttime(true), m_handler(false), m_req(req), m_dc(nullptr), m_sc(nullptr), m_rc(nullptr) {
+  }
+  virtual ~ShibTargetApache() {}
+
+  bool isInitialized() const {
+      return (m_sc != nullptr);
+  }
+
+  bool init(bool handler, bool check_user) {
+    m_handler = handler;
+    if (m_sc)
+        return !check_user; // only initialize once
+    m_sc = (shib_server_config*)ap_get_module_config(m_req->server->module_config, &mod_shib);
+    m_dc = (shib_dir_config*)ap_get_module_config(m_req->per_dir_config, &mod_shib);
+    m_rc = (shib_request_config*)ap_get_module_config(m_req->request_config, &mod_shib);
 
     setRequestURI(m_req->unparsed_uri);
 
-    if (shib_check_user && m_dc->bUseHeaders == 1) {
+    if (check_user && m_dc->bUseHeaders == 1) {
         // Try and see if this request was already processed, to skip spoof checking.
         if (!ap_is_initial_req(m_req)) {
             m_firsttime = false;
@@ -377,14 +359,13 @@ public:
         else if (!g_spoofKey.empty()) {
             const char* hdr = ap_table_get(m_req->headers_in, "Shib-Spoof-Check");
             if (hdr && g_spoofKey == hdr)
-                m_firsttime=false;
+                m_firsttime = false;
         }
-
         if (!m_firsttime)
             log(SPDebug, "shib_check_user running more than once");
     }
+    return true;
   }
-  virtual ~ShibTargetApache() {}
 
   const char* getScheme() const {
     return m_sc->szScheme ? m_sc->szScheme : ap_http_method(m_req);
@@ -410,7 +391,13 @@ public:
   }
   string getRemoteAddr() const {
     string ret = AbstractSPRequest::getRemoteAddr();
-    return ret.empty() ? m_req->connection->remote_ip : ret;
+    if (!ret.empty())
+        return ret;
+#ifdef SHIB_APACHE_24
+    return m_req->useragent_ip;
+#else
+    return m_req->connection->remote_ip;
+#endif
   }
   void log(SPLogLevel level, const string& msg) const {
     AbstractSPRequest::log(level,msg);
@@ -606,7 +593,7 @@ public:
         in.read(buf,1024);
         ap_rwrite(buf,in.gcount(),m_req);
     }
-#if (defined(SHIB_APACHE_20) || defined(SHIB_APACHE_22))
+#if (defined(SHIB_APACHE_20) || defined(SHIB_APACHE_22) || defined(SHIB_APACHE_24))
     if (status != XMLTOOLING_HTTP_STATUS_OK && status != XMLTOOLING_HTTP_STATUS_ERROR)
         return status;
 #endif
@@ -647,134 +634,252 @@ public:
 };
 
 /********************************************************************************/
-// Apache handlers
+// Apache hooks
 
-extern "C" int shib_check_user(request_rec* r)
+#ifndef SHIB_APACHE_13
+extern "C" apr_status_t shib_request_cleanup(void* r)
 {
-  // Short-circuit entirely?
-  if (((shib_dir_config*)ap_get_module_config(r->per_dir_config, &mod_shib))->bOff==1)
+    if (r)
+        delete reinterpret_cast<ShibTargetApache*>(r);
+    return APR_SUCCESS;
+}
+#endif
+
+// Initial look at a request - create the per-request structure
+static int shib_post_read(request_rec *r)
+{
+    shib_request_config* rc = init_request_config(r);
+#ifdef SHIB_APACHE_24
+    rc->sta = new ShibTargetApache(r);
+    apr_pool_cleanup_register(r->pool, rc->sta, shib_request_cleanup, apr_pool_cleanup_null);
+#endif
     return DECLINED;
+}
 
-  ap_log_rerror(APLOG_MARK,APLOG_DEBUG|APLOG_NOERRNO,SH_AP_R(r), "shib_check_user(%d): ENTER", (int)getpid());
+// Performs authentication and enforce session requirements.
+// Also does header/env export from session, and will dispatch
+// SP handler requests if it detects a handler URL.
+extern "C" int shib_check_user(request_rec* r)
+{
+    // Short-circuit entirely?
+    if (((shib_dir_config*)ap_get_module_config(r->per_dir_config, &mod_shib))->bOff == 1)
+        return DECLINED;
 
-  string threadid("[");
-  threadid += lexical_cast<string>(getpid()) + "] shib_check_user";
-  xmltooling::NDC ndc(threadid.c_str());
+    ap_log_rerror(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, SH_AP_R(r), "shib_check_user(%d): ENTER", (int)getpid());
 
-  try {
-    ShibTargetApache sta(r,false,true);
+    string threadid("[");
+    threadid += lexical_cast<string>(getpid()) + "] shib_check_user";
+    xmltooling::NDC ndc(threadid.c_str());
 
-    // Check user authentication and export information, then set the handler bypass
-    pair<bool,long> res = sta.getServiceProvider().doAuthentication(sta,true);
-    apr_pool_userdata_setn((const void*)42,g_UserDataKey,nullptr,r->pool);
-    // If directed, install a spoof key to recognize when we've already cleared headers.
-    if (!g_spoofKey.empty() && (((shib_dir_config*)ap_get_module_config(r->per_dir_config, &mod_shib))->bUseHeaders==1))
-        ap_table_set(r->headers_in, "Shib-Spoof-Check", g_spoofKey.c_str());
-    if (res.first) return res.second;
+    try {
+#ifndef SHIB_APACHE_24
+        ShibTargetApache sta(r);
+        ShibTargetApache* psta = &sta;
+#else
+        shib_request_config* rc = (shib_request_config*)ap_get_module_config(r->request_config, &mod_shib);
+        if (!rc || !rc->sta) {
+            ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, SH_AP_R(r), "shib_check_user found no per-request structure");
+            return SERVER_ERROR;
+        }
+        ShibTargetApache* psta = rc->sta;
+#endif
+        if (!psta->init(false, true)) {
+            ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, SH_AP_R(r), "shib_check_user unable to initialize SP request object");
+            return SERVER_ERROR;
+        }
 
-    // user auth was okay -- export the assertions now
-    res = sta.getServiceProvider().doExport(sta);
-    if (res.first) return res.second;
+        // Check user authentication and export information, then set the handler bypass
+        pair<bool,long> res = psta->getServiceProvider().doAuthentication(*psta, true);
+        apr_pool_userdata_setn((const void*)42,g_UserDataKey,nullptr,r->pool);
+        // If directed, install a spoof key to recognize when we've already cleared headers.
+        if (!g_spoofKey.empty() && (((shib_dir_config*)ap_get_module_config(r->per_dir_config, &mod_shib))->bUseHeaders==1))
+            ap_table_set(r->headers_in, "Shib-Spoof-Check", g_spoofKey.c_str());
+        if (res.first) {
+#ifdef SHIB_APACHE_24
+            // This is insane, but Apache's internal request.c logic insists that an auth module
+            // returning OK MUST set r->user to avoid a failure. But they check for NULL and not
+            // for an empty string. If this turns out to cause trouble, there's no solution except
+            // to set a dummy ID any time it's not set.
+            if (res.second == OK && !r->user)
+                r->user = "";
+#endif
+            return res.second;
+        }
 
-    // export happened successfully..  this user is ok.
-    return OK;
-  }
-  catch (std::exception& e) {
-    ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, SH_AP_R(r), "shib_check_user threw an exception: %s", e.what());
-    return SERVER_ERROR;
-  }
-  catch (...) {
-    ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, SH_AP_R(r), "shib_check_user threw an unknown exception!");
-    if (g_catchAll)
-      return SERVER_ERROR;
-    throw;
-  }
+        // user auth was okay -- export the session data now
+        res = psta->getServiceProvider().doExport(*psta);
+        if (res.first) {
+#ifdef SHIB_APACHE_24
+            // See above for explanation of this hack.
+            if (res.second == OK && !r->user)
+                r->user = "";
+#endif
+            return res.second;
+        }
+
+#ifdef SHIB_APACHE_24
+        // See above for explanation of this hack.
+        if (!r->user)
+            r->user = "";
+#endif
+        return OK;
+    }
+    catch (std::exception& e) {
+        ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, SH_AP_R(r), "shib_check_user threw an exception: %s", e.what());
+        return SERVER_ERROR;
+    }
+    catch (...) {
+        ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, SH_AP_R(r), "shib_check_user threw an unknown exception!");
+        if (g_catchAll)
+            return SERVER_ERROR;
+        throw;
+    }
 }
 
+// Runs SP handler requests when invoked directly.
 extern "C" int shib_handler(request_rec* r)
 {
-  // Short-circuit entirely?
-  if (((shib_dir_config*)ap_get_module_config(r->per_dir_config, &mod_shib))->bOff==1)
-    return DECLINED;
+    // Short-circuit entirely?
+    if (((shib_dir_config*)ap_get_module_config(r->per_dir_config, &mod_shib))->bOff == 1)
+        return DECLINED;
 
-  string threadid("[");
-  threadid += lexical_cast<string>(getpid()) + "] shib_handler";
-  xmltooling::NDC ndc(threadid.c_str());
+    string threadid("[");
+    threadid += lexical_cast<string>(getpid()) + "] shib_handler";
+    xmltooling::NDC ndc(threadid.c_str());
 
 #ifndef SHIB_APACHE_13
-  // With 2.x, this handler always runs, though last.
-  // We check if shib_check_user ran, because it will detect a handler request
-  // and dispatch it directly.
-  void* data;
-  apr_pool_userdata_get(&data,g_UserDataKey,r->pool);
-  if (data==(const void*)42) {
-    ap_log_rerror(APLOG_MARK,APLOG_DEBUG|APLOG_NOERRNO,SH_AP_R(r),"shib_handler skipped since check_user ran");
-    return DECLINED;
-  }
+    // With 2.x, this handler always runs, though last.
+    // We check if shib_check_user ran, because it will detect a handler request
+    // and dispatch it directly.
+    void* data;
+    apr_pool_userdata_get(&data,g_UserDataKey,r->pool);
+    if (data==(const void*)42) {
+        ap_log_rerror(APLOG_MARK,APLOG_DEBUG|APLOG_NOERRNO,SH_AP_R(r),"shib_handler skipped since check_user ran");
+        return DECLINED;
+    }
 #endif
 
-  ap_log_rerror(APLOG_MARK,APLOG_DEBUG|APLOG_NOERRNO,SH_AP_R(r),"shib_handler(%d): ENTER: %s", (int)getpid(), r->handler);
+    ap_log_rerror(APLOG_MARK,APLOG_DEBUG|APLOG_NOERRNO,SH_AP_R(r),"shib_handler(%d): ENTER: %s", (int)getpid(), r->handler);
 
-  try {
-    ShibTargetApache sta(r,true,false);
+    try {
+#ifndef SHIB_APACHE_24
+        ShibTargetApache sta(r);
+        ShibTargetApache* psta = &sta;
+#else
+        shib_request_config* rc = (shib_request_config*)ap_get_module_config(r->request_config, &mod_shib);
+        if (!rc || !rc->sta) {
+            ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, SH_AP_R(r), "shib_handler found no per-request structure");
+            return SERVER_ERROR;
+        }
+        ShibTargetApache* psta = rc->sta;
+#endif
+        if (!psta->init(true, false)) {
+            ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, SH_AP_R(r), "shib_handler unable to initialize SP request object");
+            return SERVER_ERROR;
+        }
 
-    pair<bool,long> res = sta.getServiceProvider().doHandler(sta);
-    if (res.first) return res.second;
+        pair<bool,long> res = psta->getServiceProvider().doHandler(*psta);
+        if (res.first) return res.second;
 
-    ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, SH_AP_R(r), "doHandler() did not do anything.");
-    return SERVER_ERROR;
-  }
-  catch (std::exception& e) {
-    ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, SH_AP_R(r), "shib_handler threw an exception: %s", e.what());
-    return SERVER_ERROR;
-  }
-  catch (...) {
-    ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, SH_AP_R(r), "shib_handler threw an unknown exception!");
-    if (g_catchAll)
-      return SERVER_ERROR;
-    throw;
-  }
+        ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, SH_AP_R(r), "doHandler() did not do anything.");
+        return SERVER_ERROR;
+    }
+    catch (std::exception& e) {
+        ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, SH_AP_R(r), "shib_handler threw an exception: %s", e.what());
+        return SERVER_ERROR;
+    }
+    catch (...) {
+        ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, SH_AP_R(r), "shib_handler threw an unknown exception!");
+        if (g_catchAll)
+          return SERVER_ERROR;
+        throw;
+    }
 }
 
-/*
- * shib_auth_checker() -- a simple resource manager to
- * process the .htaccess settings
- */
+// This performs authorization functions to limit access.
+// On all versions, this runs any RequestMap-attached plugins.
+// For pre-2.4 versions, the RequestMap will always find an htAccess plugin
+// that runs code to parse and enforce Apache Require rules.
+// On 2.4, we have to short-circuit that and let Apache run callbacks
+// for each Require rule we handle.
 extern "C" int shib_auth_checker(request_rec* r)
 {
-  // Short-circuit entirely?
-  if (((shib_dir_config*)ap_get_module_config(r->per_dir_config, &mod_shib))->bOff==1)
-    return DECLINED;
+    // Short-circuit entirely?
+    shib_dir_config* dc = (shib_dir_config*)ap_get_module_config(r->per_dir_config, &mod_shib);
+    if (dc->bOff == 1
+#ifdef SHIB_APACHE_24
+        || dc->bRequestMapperAuthz == 0     // this allows for bypass of the full auth_checker hook if only htaccess is used
+#endif
+        ) {
+        return DECLINED;
+    }
 
-  ap_log_rerror(APLOG_MARK,APLOG_DEBUG|APLOG_NOERRNO,SH_AP_R(r), "shib_auth_checker(%d): ENTER", (int)getpid());
+    ap_log_rerror(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, SH_AP_R(r), "shib_auth_checker(%d): ENTER", (int)getpid());
 
-  string threadid("[");
-  threadid += lexical_cast<string>(getpid()) + "] shib_auth_checker";
-  xmltooling::NDC ndc(threadid.c_str());
+    string threadid("[");
+    threadid += lexical_cast<string>(getpid()) + "] shib_auth_checker";
+    xmltooling::NDC ndc(threadid.c_str());
+
+    try {
+#ifndef SHIB_APACHE_24
+        ShibTargetApache sta(r);
+        ShibTargetApache* psta = &sta;
+#else
+        shib_request_config* rc = (shib_request_config*)ap_get_module_config(r->request_config, &mod_shib);
+        if (!rc || !rc->sta) {
+            ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, SH_AP_R(r), "shib_auth_checker found no per-request structure");
+            return SERVER_ERROR;
+        }
+        ShibTargetApache* psta = rc->sta;
+#endif
+        if (!psta->init(false, false)) {
+            ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, SH_AP_R(r), "shib_auth_checker unable to initialize SP request object");
+            return SERVER_ERROR;
+        }
 
-  try {
-    ShibTargetApache sta(r,false,false);
+        pair<bool,long> res = psta->getServiceProvider().doAuthorization(*psta);
+        if (res.first) return res.second;
 
-    pair<bool,long> res = sta.getServiceProvider().doAuthorization(sta);
-    if (res.first) return res.second;
+        // The SP method should always return true, so if we get this far, something unusual happened.
+        // Just let Apache (or some other module) decide what to do.
+        return DECLINED;
+    }
+    catch (std::exception& e) {
+        ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, SH_AP_R(r), "shib_auth_checker threw an exception: %s", e.what());
+        return SERVER_ERROR;
+    }
+    catch (...) {
+        ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, SH_AP_R(r), "shib_auth_checker threw an unknown exception!");
+        if (g_catchAll)
+          return SERVER_ERROR;
+        throw;
+    }
+}
 
-    // The SP method should always return true, so if we get this far, something unusual happened.
-    // Just let Apache (or some other module) decide what to do.
+// Overlays environment variables on top of subprocess table.
+extern "C" int shib_fixups(request_rec* r)
+{
+  shib_dir_config *dc = (shib_dir_config*)ap_get_module_config(r->per_dir_config, &mod_shib);
+  if (dc->bOff==1 || dc->bUseEnvVars==0)
     return DECLINED;
-  }
-  catch (std::exception& e) {
-    ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, SH_AP_R(r), "shib_auth_checker threw an exception: %s", e.what());
-    return SERVER_ERROR;
-  }
-  catch (...) {
-    ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, SH_AP_R(r), "shib_auth_checker threw an unknown exception!");
-    if (g_catchAll)
-      return SERVER_ERROR;
-    throw;
-  }
+
+  ap_log_rerror(APLOG_MARK,APLOG_DEBUG|APLOG_NOERRNO,SH_AP_R(r), "shib_fixup(%d): ENTER", (int)getpid());
+
+  shib_request_config *rc = (shib_request_config*)ap_get_module_config(r->request_config, &mod_shib);
+  if (rc==nullptr || rc->env==nullptr || ap_is_empty_table(rc->env))
+        return DECLINED;
+
+  ap_log_rerror(APLOG_MARK,APLOG_DEBUG|APLOG_NOERRNO,SH_AP_R(r), "shib_fixup adding %d vars", ap_table_elts(rc->env)->nelts);
+  r->subprocess_env = ap_overlay_tables(r->pool, r->subprocess_env, rc->env);
+
+  return OK;
 }
 
-// Access control plugin that enforces htaccess rules
+
+// Access control plugin that enforces pre-2.4 htaccess rules.
+// Post-2.4, we have to register individual methods to respond
+// to each require rule we want to handle, and have those call
+// into these methods directly.
 class htAccessControl : virtual public AccessControl
 {
 public:
@@ -783,6 +888,15 @@ public:
     Lockable* lock() {return this;}
     void unlock() {}
     aclresult_t authorized(const SPRequest& request, const Session* session) const;
+
+    aclresult_t doAccessControl(const ShibTargetApache& sta, const Session* session, const char* plugin) const;
+    aclresult_t doUser(const ShibTargetApache& sta, const char* params) const;
+#ifndef SHIB_APACHE_24
+    aclresult_t doGroup(const ShibTargetApache& sta, const char* params) const;
+#endif
+    aclresult_t doAuthnContext(const ShibTargetApache& sta, const char* acRef, const char* params) const;
+    aclresult_t doShibAttr(const ShibTargetApache& sta, const Session* session, const char* rule, const char* params) const;
+
 private:
     bool checkAttribute(const SPRequest& request, const Attribute* attr, const char* toMatch, RegularExpression* re) const;
 };
@@ -792,83 +906,500 @@ AccessControl* htAccessFactory(const xercesc::DOMElement* const & e)
     return new htAccessControl();
 }
 
-class ApacheRequestMapper : public virtual RequestMapper, public virtual PropertySet
-{
-public:
-    ApacheRequestMapper(const xercesc::DOMElement* e);
-    ~ApacheRequestMapper() {}
-    Lockable* lock() { return m_mapper->lock(); }
-    void unlock() { m_staKey->setData(nullptr); m_propsKey->setData(nullptr); m_mapper->unlock(); }
-    Settings getSettings(const HTTPRequest& request) const;
-
-    const PropertySet* getParent() const { return nullptr; }
-    void setParent(const PropertySet*) {}
-    pair<bool,bool> getBool(const char* name, const char* ns=nullptr) const;
-    pair<bool,const char*> getString(const char* name, const char* ns=nullptr) const;
-    pair<bool,const XMLCh*> getXMLString(const char* name, const char* ns=nullptr) const;
-    pair<bool,unsigned int> getUnsignedInt(const char* name, const char* ns=nullptr) const;
-    pair<bool,int> getInt(const char* name, const char* ns=nullptr) const;
-    void getAll(map<string,const char*>& properties) const;
-    const PropertySet* getPropertySet(const char* name, const char* ns=shibspconstants::ASCII_SHIB2SPCONFIG_NS) const;
-    const xercesc::DOMElement* getElement() const;
-
-private:
-    scoped_ptr<RequestMapper> m_mapper;
-    scoped_ptr<ThreadKey> m_staKey,m_propsKey;
-    mutable htAccessControl m_htaccess;
-};
-
-RequestMapper* ApacheRequestMapFactory(const xercesc::DOMElement* const & e)
+AccessControl::aclresult_t htAccessControl::doAccessControl(const ShibTargetApache& sta, const Session* session, const char* plugin) const
 {
-    return new ApacheRequestMapper(e);
+       aclresult_t result = shib_acl_false;
+       try {
+        ifstream aclfile(plugin);
+        if (!aclfile)
+            throw ConfigurationException("Unable to open access control file ($1).", params(1, plugin));
+        xercesc::DOMDocument* acldoc = XMLToolingConfig::getConfig().getParser().parse(aclfile);
+               XercesJanitor<xercesc::DOMDocument> docjanitor(acldoc);
+               static XMLCh _type[] = UNICODE_LITERAL_4(t,y,p,e);
+        string t(XMLHelper::getAttrString(acldoc ? acldoc->getDocumentElement() : nullptr, nullptr, _type));
+        if (t.empty())
+            throw ConfigurationException("Missing type attribute in AccessControl plugin configuration.");
+        scoped_ptr<AccessControl> aclplugin(SPConfig::getConfig().AccessControlManager.newPlugin(t.c_str(), acldoc->getDocumentElement()));
+               Locker acllock(aclplugin.get());
+               result = aclplugin->authorized(sta, session);
+       }
+       catch (std::exception& ex) {
+               sta.log(SPRequest::SPError, ex.what());
+       }
+    return result;
 }
 
-ApacheRequestMapper::ApacheRequestMapper(const xercesc::DOMElement* e)
-    : m_mapper(SPConfig::getConfig().RequestMapperManager.newPlugin(XML_REQUEST_MAPPER,e)),
-        m_staKey(ThreadKey::create(nullptr)), m_propsKey(ThreadKey::create(nullptr))
+AccessControl::aclresult_t htAccessControl::doUser(const ShibTargetApache& sta, const char* params) const
 {
-}
+    bool regexp = false;
+    bool negated = false;
+    while (*params) {
+        const char* w = ap_getword_conf(sta.m_req->pool, &params);
+        if (*w == '~') {
+            regexp = true;
+            continue;
+        }
+        else if (*w == '!') {
+            // A negated rule presumes success unless a match is found.
+            negated = true;
+            if (*(w+1) == '~')
+                regexp = true;
+            continue;
+        }
 
-RequestMapper::Settings ApacheRequestMapper::getSettings(const HTTPRequest& request) const
-{
-    Settings s = m_mapper->getSettings(request);
-    m_staKey->setData((void*)dynamic_cast<const ShibTargetApache*>(&request));
-    m_propsKey->setData((void*)s.first);
-    return pair<const PropertySet*,AccessControl*>(this, s.second ? s.second : &m_htaccess);
-}
+        // Figure out if there's a match.
+        bool match = false;
+        if (regexp) {
+            try {
+                // To do regex matching, we have to convert from UTF-8.
+                auto_arrayptr<XMLCh> trans(fromUTF8(w));
+                RegularExpression re(trans.get());
+                auto_arrayptr<XMLCh> trans2(fromUTF8(sta.getRemoteUser().c_str()));
+                match = re.matches(trans2.get());
+            }
+            catch (XMLException& ex) {
+                auto_ptr_char tmp(ex.getMessage());
+                sta.log(SPRequest::SPError,
+                    string("htaccess plugin caught exception while parsing regular expression (") + w + "): " + tmp.get());
+            }
+        }
+        else if (sta.getRemoteUser() == w) {
+            match = true;
+        }
 
-pair<bool,bool> ApacheRequestMapper::getBool(const char* name, const char* ns) const
-{
-    const ShibTargetApache* sta=reinterpret_cast<const ShibTargetApache*>(m_staKey->getData());
-    const PropertySet* s=reinterpret_cast<const PropertySet*>(m_propsKey->getData());
-    if (sta && !ns) {
-        // Override Apache-settable boolean properties.
-        if (name && !strcmp(name,"requireSession") && sta->m_dc->bRequireSession != -1)
-            return make_pair(true, sta->m_dc->bRequireSession==1);
-        else if (name && !strcmp(name,"exportAssertion") && sta->m_dc->bExportAssertion != -1)
-            return make_pair(true, sta->m_dc->bExportAssertion==1);
-        else if (sta->m_dc->tSettings) {
-            const char* prop = ap_table_get(sta->m_dc->tSettings, name);
-            if (prop)
-                return make_pair(true, !strcmp(prop, "true") || !strcmp(prop, "1") || !strcmp(prop, "On"));
+        if (match) {
+            if (sta.isPriorityEnabled(SPRequest::SPDebug))
+                sta.log(SPRequest::SPDebug,
+                    string("htaccess: require user ") + (negated ? "rejecting (" : "accepting (") + sta.getRemoteUser() + ")");
+            return (negated ? shib_acl_false : shib_acl_true);
         }
     }
-    return s ? s->getBool(name,ns) : make_pair(false,false);
+    return (negated ? shib_acl_true : shib_acl_false);
 }
 
-pair<bool,const char*> ApacheRequestMapper::getString(const char* name, const char* ns) const
+#ifndef SHIB_APACHE_24
+static SH_AP_TABLE* groups_for_user(request_rec* r, const char* user, char* grpfile)
 {
-    const ShibTargetApache* sta=reinterpret_cast<const ShibTargetApache*>(m_staKey->getData());
-    const PropertySet* s=reinterpret_cast<const PropertySet*>(m_propsKey->getData());
-    if (sta && !ns) {
+    SH_AP_CONFIGFILE* f;
+    SH_AP_TABLE* grps=ap_make_table(r->pool,15);
+    char l[MAX_STRING_LEN];
+    const char *group_name, *ll, *w;
+
+#ifdef SHIB_APACHE_13
+    if (!(f=ap_pcfg_openfile(r->pool,grpfile))) {
+#else
+    if (ap_pcfg_openfile(&f,r->pool,grpfile) != APR_SUCCESS) {
+#endif
+        ap_log_rerror(APLOG_MARK,APLOG_DEBUG,SH_AP_R(r),"groups_for_user() could not open group file: %s\n",grpfile);
+        return nullptr;
+    }
+
+    SH_AP_POOL* sp;
+#ifdef SHIB_APACHE_13
+    sp=ap_make_sub_pool(r->pool);
+#else
+    if (apr_pool_create(&sp,r->pool) != APR_SUCCESS) {
+        ap_log_rerror(APLOG_MARK,APLOG_ERR,0,r,
+            "groups_for_user() could not create a subpool");
+        return nullptr;
+    }
+#endif
+
+    while (!(ap_cfg_getline(l,MAX_STRING_LEN,f))) {
+        if ((*l=='#') || (!*l))
+            continue;
+        ll = l;
+        ap_clear_pool(sp);
+        group_name = ap_getword(sp,&ll,':');
+        while (*ll) {
+            w=ap_getword_conf(sp,&ll);
+            if (!strcmp(w,user)) {
+                ap_table_setn(grps,ap_pstrdup(r->pool,group_name),"in");
+                break;
+            }
+        }
+    }
+    ap_cfg_closefile(f);
+    ap_destroy_pool(sp);
+    return grps;
+}
+
+AccessControl::aclresult_t htAccessControl::doGroup(const ShibTargetApache& sta, const char* params) const
+{
+    SH_AP_TABLE* grpstatus = nullptr;
+    if (sta.m_dc->szAuthGrpFile) {
+        if (sta.isPriorityEnabled(SPRequest::SPDebug))
+            sta.log(SPRequest::SPDebug, string("htaccess plugin using groups file: ") + sta.m_dc->szAuthGrpFile);
+        grpstatus = groups_for_user(sta.m_req, sta.getRemoteUser().c_str(), sta.m_dc->szAuthGrpFile);
+    }
+
+    bool negated = false;
+    while (*params) {
+        const char* w = ap_getword_conf(sta.m_req->pool, &params);
+        if (*w == '!') {
+            // A negated rule presumes success unless a match is found.
+            negated = true;
+            continue;
+        }
+
+        if (grpstatus && ap_table_get(grpstatus, w)) {
+            // If we matched, then we're done with this rule either way and we flip status to reflect the outcome.
+            sta.log(SPRequest::SPDebug, string("htaccess: require group ") + (negated ? "rejecting (" : "accepting (") + w + ")");
+            return (negated ? shib_acl_false : shib_acl_true);
+        }
+    }
+
+    return (negated ? shib_acl_true : shib_acl_false);
+}
+#endif
+
+AccessControl::aclresult_t htAccessControl::doAuthnContext(const ShibTargetApache& sta, const char* ref, const char* params) const
+{
+    if (ref && *ref) {
+        bool regexp = false;
+        bool negated = false;
+        while (ref && *params) {
+            const char* w = ap_getword_conf(sta.m_req->pool, &params);
+            if (*w == '~') {
+                regexp = true;
+                continue;
+            }
+            else if (*w == '!') {
+                // A negated rule presumes success unless a match is found.
+                negated = true;
+                if (*(w+1) == '~')
+                    regexp = true;
+                continue;
+            }
+
+            // Figure out if there's a match.
+            bool match = false;
+            if (regexp) {
+                try {
+                    RegularExpression re(w);
+                    match = re.matches(ref);
+                }
+                catch (XMLException& ex) {
+                    auto_ptr_char tmp(ex.getMessage());
+                    sta.log(SPRequest::SPError,
+                        string("htaccess plugin caught exception while parsing regular expression (") + w + "): " + tmp.get());
+                }
+            }
+            else if (!strcmp(w, ref)) {
+                match = true;
+            }
+
+            if (match) {
+                if (sta.isPriorityEnabled(SPRequest::SPDebug))
+                    sta.log(SPRequest::SPDebug,
+                        string("htaccess: require authnContext ") + (negated ? "rejecting (" : "accepting (") + ref + ")");
+                return (negated ? shib_acl_false : shib_acl_true);
+            }
+        }
+        return (negated ? shib_acl_true : shib_acl_false);
+    }
+
+    if (sta.isPriorityEnabled(SPRequest::SPDebug))
+        sta.log(SPRequest::SPDebug, "htaccess: require authnContext rejecting session with no context associated");
+    return shib_acl_false;
+}
+
+bool htAccessControl::checkAttribute(const SPRequest& request, const Attribute* attr, const char* toMatch, RegularExpression* re) const
+{
+    bool caseSensitive = attr->isCaseSensitive();
+    const vector<string>& vals = attr->getSerializedValues();
+    for (vector<string>::const_iterator v = vals.begin(); v != vals.end(); ++v) {
+        if (re) {
+            auto_arrayptr<XMLCh> trans(fromUTF8(v->c_str()));
+            if (re->matches(trans.get())) {
+                if (request.isPriorityEnabled(SPRequest::SPDebug))
+                    request.log(SPRequest::SPDebug, string("htaccess: expecting regexp ") + toMatch + ", got " + *v + ": acccepted");
+                return true;
+            }
+        }
+        else if ((caseSensitive && *v == toMatch) || (!caseSensitive && !strcasecmp(v->c_str(), toMatch))) {
+            if (request.isPriorityEnabled(SPRequest::SPDebug))
+                request.log(SPRequest::SPDebug, string("htaccess: expecting ") + toMatch + ", got " + *v + ": accepted");
+            return true;
+        }
+        else if (request.isPriorityEnabled(SPRequest::SPDebug)) {
+            request.log(SPRequest::SPDebug, string("htaccess: expecting ") + toMatch + ", got " + *v + ": rejected");
+        }
+    }
+    return false;
+}
+
+AccessControl::aclresult_t htAccessControl::doShibAttr(const ShibTargetApache& sta, const Session* session, const char* rule, const char* params) const
+{
+#ifndef SHIB_APACHE_24
+    // Look for the new shib-attr placeholder and move past it.
+    if (sta.m_dc->bCompatWith24 == 1 && rule && !strcmp(rule, "shib-attr")) {
+        if (*params)
+            rule = ap_getword_conf(sta.m_req->pool, &params);
+    }
+#endif
+
+    // Find the attribute(s) matching the require rule.
+    pair<multimap<string,const Attribute*>::const_iterator,multimap<string,const Attribute*>::const_iterator> attrs =
+        session->getIndexedAttributes().equal_range(rule ? rule : "");
+
+    bool regexp = false;
+    while (attrs.first != attrs.second && *params) {
+        const char* w = ap_getword_conf(sta.m_req->pool, &params);
+        if (*w == '~') {
+            regexp = true;
+            continue;
+        }
+
+        try {
+            scoped_ptr<RegularExpression> re;
+            if (regexp) {
+                auto_arrayptr<XMLCh> trans(fromUTF8(w));
+                re.reset(new xercesc::RegularExpression(trans.get()));
+            }
+                    
+            pair<multimap<string,const Attribute*>::const_iterator,multimap<string,const Attribute*>::const_iterator> attrs2(attrs);
+            for (; attrs2.first != attrs2.second; ++attrs2.first) {
+                if (checkAttribute(sta, attrs2.first->second, w, regexp ? re.get() : nullptr)) {
+                    return shib_acl_true;
+                }
+            }
+        }
+        catch (XMLException& ex) {
+            auto_ptr_char tmp(ex.getMessage());
+            sta.log(SPRequest::SPError, string("htaccess plugin caught exception while parsing regular expression (") + w + "): " + tmp.get());
+        }
+    }
+    return shib_acl_false;
+}
+
+AccessControl::aclresult_t htAccessControl::authorized(const SPRequest& request, const Session* session) const
+{
+#ifdef SHIB_APACHE_24
+    // We should never be invoked in 2.4 as an SP plugin.
+    throw ConfigurationException("Save my walrus!");
+#else
+    // Make sure the object is our type.
+    const ShibTargetApache* sta=dynamic_cast<const ShibTargetApache*>(&request);
+    if (!sta)
+        throw ConfigurationException("Request wrapper object was not of correct type.");
+
+    int m = sta->m_req->method_number;
+    bool method_restricted = false;
+    const char *t, *w;
+
+    const array_header* reqs_arr = ap_requires(sta->m_req);
+    if (!reqs_arr)
+        return shib_acl_indeterminate;  // should never happen
+
+       // Check for an "embedded" AccessControl plugin.
+       if (sta->m_dc->szAccessControl) {
+        aclresult_t result = doAccessControl(*sta, session, sta->m_dc->szAccessControl);
+        if (result == shib_acl_true && sta->m_dc->bRequireAll != 1) {
+            // If we're not insisting that all rules be met, then we're done.
+            request.log(SPRequest::SPDebug, "htaccess: embedded AccessControl plugin was successful, granting access");
+            return shib_acl_true;
+        }
+        else if (result != shib_acl_true && sta->m_dc->bRequireAll == 1) {
+            // If we're insisting that all rules be met, which is not something Apache really handles well,
+            // then we either return false or indeterminate based on the authoritative option, which defaults on.
+            if (sta->m_dc->bAuthoritative != 0) {
+                request.log(SPRequest::SPDebug, "htaccess: embedded AccessControl plugin was unsuccessful, denying access");
+                return shib_acl_false;
+            }
+
+            request.log(SPRequest::SPDebug, "htaccess: embedded AccessControl plugin was unsuccessful but not authoritative, leaving it up to Apache");
+            return shib_acl_indeterminate;
+        }
+    }
+
+    require_line* reqs = (require_line*)reqs_arr->elts;
+
+    for (int x = 0; x < reqs_arr->nelts; ++x) {
+        // This rule should be completely ignored, the method doesn't fit.
+        // The rule just doesn't exist for our purposes.
+        if (!(reqs[x].method_mask & (1 << m)))
+            continue;
+
+        method_restricted = true; // this lets us know at the end that at least one rule was potentially enforcable.
+
+        // Tracks status of this rule's evaluation.
+        bool status = false;
+
+        string remote_user = request.getRemoteUser();
+
+        t = reqs[x].requirement;
+        w = ap_getword_white(sta->m_req->pool, &t);
+
+        if (!strcasecmp(w,"shibboleth")) {
+            // This is a dummy rule needed because Apache conflates authn and authz.
+            // Without some require rule, AuthType is ignored and no check_user hooks run.
+
+            // We evaluate to false if ShibAccessControl is used and ShibRequireAll is off.
+            // This allows actual rules to dictate the result, since ShibAccessControl returned
+            // non-true, and if nothing else is used, access will be denied.
+            if (!sta->m_dc->szAccessControl || sta->m_dc->bRequireAll == 1) {
+                // We evaluate to true, because ShibRequireAll is enabled (so a true is just a no-op)
+                // or because there was no other AccessControl rule in place, so this may be the only
+                // rule in effect.
+                status = true;
+            }
+        }
+        else if (!strcmp(w,"valid-user") && session) {
+            request.log(SPRequest::SPDebug, "htaccess: accepting valid-user based on active session");
+            status = true;
+        }
+        else if (!strcmp(w,"user") && !remote_user.empty()) {
+            status = (doUser(*sta, t) == shib_acl_true);
+        }
+        else if (!strcmp(w,"group")  && !remote_user.empty()) {
+            status = (doGroup(*sta, t) == shib_acl_true);
+        }
+        else if (!strcmp(w,"authnContextClassRef") || !strcmp(w,"authnContextDeclRef")) {
+            const char* ref = !strcmp(w, "authnContextClassRef") ? session->getAuthnContextClassRef() : session->getAuthnContextDeclRef();
+            status = (doAuthnContext(*sta, ref, t) == shib_acl_true);
+        }
+        else if (!session) {
+            request.log(SPRequest::SPError, string("htaccess: require ") + w + " not given a valid session, are you using lazy sessions?");
+        }
+        else if (sta->m_dc->bCompatWith24 == 1 && !strcmp(w,"shib-plugin")) {
+            w = ap_getword_conf(sta->m_req->pool, &t);
+            if (w) {
+                status = (doAccessControl(*sta, session, w) == shib_acl_true);
+            }
+        }
+        else {
+            status = (doShibAttr(*sta, session, w, t) == shib_acl_true);
+        }
+
+        // If status is false, we found a rule we couldn't satisfy.
+        // Could be an unknown rule to us, or it just didn't match.
+
+        if (status && sta->m_dc->bRequireAll != 1) {
+            // If we're not insisting that all rules be met, then we're done.
+            request.log(SPRequest::SPDebug, "htaccess: a rule was successful, granting access");
+            return shib_acl_true;
+        }
+        else if (!status && sta->m_dc->bRequireAll == 1) {
+            // If we're insisting that all rules be met, which is not something Apache really handles well,
+            // then we either return false or indeterminate based on the authoritative option, which defaults on.
+            if (sta->m_dc->bAuthoritative != 0) {
+                request.log(SPRequest::SPDebug, "htaccess: a rule was unsuccessful, denying access");
+                return shib_acl_false;
+            }
+
+            request.log(SPRequest::SPDebug, "htaccess: a rule was unsuccessful but not authoritative, leaving it up to Apache");
+            return shib_acl_indeterminate;
+        }
+
+        // Otherwise, we keep going. If we're requring all, then we have to check every rule.
+        // If not we just didn't find a successful rule yet, so we keep going anyway.
+    }
+
+    // If we get here, we either "failed" or we're in require all mode (but not both).
+    // If no rules possibly apply or we insisted that all rules check out, then we're good.
+    if (!method_restricted) {
+        request.log(SPRequest::SPDebug, "htaccess: no rules applied to this request method, granting access");
+        return shib_acl_true;
+    }
+    else if (sta->m_dc->bRequireAll == 1) {
+        request.log(SPRequest::SPDebug, "htaccess: all rules successful, granting access");
+        return shib_acl_true;
+    }
+    else if (sta->m_dc->bAuthoritative != 0) {
+        request.log(SPRequest::SPDebug, "htaccess: no rules were successful, denying access");
+        return shib_acl_false;
+    }
+
+    request.log(SPRequest::SPDebug, "htaccess: no rules were successful but not authoritative, leaving it up to Apache");
+    return shib_acl_indeterminate;
+#endif
+}
+
+class ApacheRequestMapper : public virtual RequestMapper, public virtual PropertySet
+{
+public:
+    ApacheRequestMapper(const xercesc::DOMElement* e);
+    ~ApacheRequestMapper() {}
+    Lockable* lock() { return m_mapper->lock(); }
+    void unlock() { m_staKey->setData(nullptr); m_propsKey->setData(nullptr); m_mapper->unlock(); }
+    Settings getSettings(const HTTPRequest& request) const;
+
+    const PropertySet* getParent() const { return nullptr; }
+    void setParent(const PropertySet*) {}
+    pair<bool,bool> getBool(const char* name, const char* ns=nullptr) const;
+    pair<bool,const char*> getString(const char* name, const char* ns=nullptr) const;
+    pair<bool,const XMLCh*> getXMLString(const char* name, const char* ns=nullptr) const;
+    pair<bool,unsigned int> getUnsignedInt(const char* name, const char* ns=nullptr) const;
+    pair<bool,int> getInt(const char* name, const char* ns=nullptr) const;
+    void getAll(map<string,const char*>& properties) const;
+    const PropertySet* getPropertySet(const char* name, const char* ns=shibspconstants::ASCII_SHIB2SPCONFIG_NS) const;
+    const xercesc::DOMElement* getElement() const;
+
+    const htAccessControl& getHTAccessControl() const { return m_htaccess; }
+
+private:
+    scoped_ptr<RequestMapper> m_mapper;
+    scoped_ptr<ThreadKey> m_staKey,m_propsKey;
+    mutable htAccessControl m_htaccess;
+};
+
+RequestMapper* ApacheRequestMapFactory(const xercesc::DOMElement* const & e)
+{
+    return new ApacheRequestMapper(e);
+}
+
+ApacheRequestMapper::ApacheRequestMapper(const xercesc::DOMElement* e)
+    : m_mapper(SPConfig::getConfig().RequestMapperManager.newPlugin(XML_REQUEST_MAPPER,e)),
+        m_staKey(ThreadKey::create(nullptr)), m_propsKey(ThreadKey::create(nullptr))
+{
+}
+
+RequestMapper::Settings ApacheRequestMapper::getSettings(const HTTPRequest& request) const
+{
+    Settings s = m_mapper->getSettings(request);
+    m_staKey->setData((void*)dynamic_cast<const ShibTargetApache*>(&request));
+    m_propsKey->setData((void*)s.first);
+    // Only return the htAccess plugin for pre-2.4 servers.
+#ifdef SHIB_APACHE_24
+    return pair<const PropertySet*,AccessControl*>(this, s.second);
+#else
+    return pair<const PropertySet*,AccessControl*>(this, s.second ? s.second : &m_htaccess);
+#endif
+}
+
+pair<bool,bool> ApacheRequestMapper::getBool(const char* name, const char* ns) const
+{
+    const ShibTargetApache* sta=reinterpret_cast<const ShibTargetApache*>(m_staKey->getData());
+    const PropertySet* s=reinterpret_cast<const PropertySet*>(m_propsKey->getData());
+    if (sta && !ns) {
+        // Override Apache-settable boolean properties.
+        if (name && !strcmp(name,"requireSession") && sta->m_dc->bRequireSession != -1)
+            return make_pair(true, sta->m_dc->bRequireSession==1);
+        else if (name && !strcmp(name,"exportAssertion") && sta->m_dc->bExportAssertion != -1)
+            return make_pair(true, sta->m_dc->bExportAssertion==1);
+        else if (sta->m_dc->tSettings) {
+            const char* prop = ap_table_get(sta->m_dc->tSettings, name);
+            if (prop)
+                return make_pair(true, !strcmp(prop, "true") || !strcmp(prop, "1") || !strcmp(prop, "On"));
+        }
+    }
+    return s ? s->getBool(name,ns) : make_pair(false,false);
+}
+
+pair<bool,const char*> ApacheRequestMapper::getString(const char* name, const char* ns) const
+{
+    const ShibTargetApache* sta=reinterpret_cast<const ShibTargetApache*>(m_staKey->getData());
+    const PropertySet* s=reinterpret_cast<const PropertySet*>(m_propsKey->getData());
+    if (sta && !ns) {
         // Override Apache-settable string properties.
         if (name && !strcmp(name,"authType")) {
-            const char *auth_type=ap_auth_type(sta->m_req);
+            const char* auth_type = ap_auth_type(sta->m_req);
             if (auth_type) {
                 // Check for Basic Hijack
                 if (!strcasecmp(auth_type, "basic") && sta->m_dc->bBasicHijack == 1)
                     auth_type = "shibboleth";
-                return make_pair(true,auth_type);
+                return make_pair(true, auth_type);
             }
         }
         else if (name && !strcmp(name,"applicationId") && sta->m_dc->szApplicationId)
@@ -965,412 +1496,229 @@ void ApacheRequestMapper::getAll(map<string,const char*>& properties) const
         ap_table_do(_rm_get_all_table_walk, &properties, sta->m_dc->tSettings, NULL);
 }
 
-const PropertySet* ApacheRequestMapper::getPropertySet(const char* name, const char* ns) const
-{
-    const PropertySet* s=reinterpret_cast<const PropertySet*>(m_propsKey->getData());
-    return s ? s->getPropertySet(name,ns) : nullptr;
-}
-
-const xercesc::DOMElement* ApacheRequestMapper::getElement() const
-{
-    const PropertySet* s=reinterpret_cast<const PropertySet*>(m_propsKey->getData());
-    return s ? s->getElement() : nullptr;
-}
-
-static SH_AP_TABLE* groups_for_user(request_rec* r, const char* user, char* grpfile)
-{
-    SH_AP_CONFIGFILE* f;
-    SH_AP_TABLE* grps=ap_make_table(r->pool,15);
-    char l[MAX_STRING_LEN];
-    const char *group_name, *ll, *w;
-
-#ifdef SHIB_APACHE_13
-    if (!(f=ap_pcfg_openfile(r->pool,grpfile))) {
-#else
-    if (ap_pcfg_openfile(&f,r->pool,grpfile) != APR_SUCCESS) {
-#endif
-        ap_log_rerror(APLOG_MARK,APLOG_DEBUG,SH_AP_R(r),"groups_for_user() could not open group file: %s\n",grpfile);
-        return nullptr;
-    }
-
-    SH_AP_POOL* sp;
-#ifdef SHIB_APACHE_13
-    sp=ap_make_sub_pool(r->pool);
-#else
-    if (apr_pool_create(&sp,r->pool) != APR_SUCCESS) {
-        ap_log_rerror(APLOG_MARK,APLOG_ERR,0,r,
-            "groups_for_user() could not create a subpool");
-        return nullptr;
-    }
-#endif
-
-    while (!(ap_cfg_getline(l,MAX_STRING_LEN,f))) {
-        if ((*l=='#') || (!*l))
-            continue;
-        ll = l;
-        ap_clear_pool(sp);
-
-        group_name=ap_getword(sp,&ll,':');
-
-        while (*ll) {
-            w=ap_getword_conf(sp,&ll);
-            if (!strcmp(w,user)) {
-                ap_table_setn(grps,ap_pstrdup(r->pool,group_name),"in");
-                break;
-            }
-        }
-    }
-    ap_cfg_closefile(f);
-    ap_destroy_pool(sp);
-    return grps;
-}
-
-bool htAccessControl::checkAttribute(const SPRequest& request, const Attribute* attr, const char* toMatch, RegularExpression* re) const
-{
-    bool caseSensitive = attr->isCaseSensitive();
-    const vector<string>& vals = attr->getSerializedValues();
-    for (vector<string>::const_iterator v = vals.begin(); v != vals.end(); ++v) {
-        if (re) {
-            auto_arrayptr<XMLCh> trans(fromUTF8(v->c_str()));
-            if (re->matches(trans.get())) {
-                if (request.isPriorityEnabled(SPRequest::SPDebug))
-                    request.log(SPRequest::SPDebug, string("htaccess: expecting regexp ") + toMatch + ", got " + *v + ": acccepted");
-                return true;
-            }
-        }
-        else if ((caseSensitive && *v == toMatch) || (!caseSensitive && !strcasecmp(v->c_str(), toMatch))) {
-            if (request.isPriorityEnabled(SPRequest::SPDebug))
-                request.log(SPRequest::SPDebug, string("htaccess: expecting ") + toMatch + ", got " + *v + ": accepted");
-            return true;
-        }
-        else if (request.isPriorityEnabled(SPRequest::SPDebug)) {
-            request.log(SPRequest::SPDebug, string("htaccess: expecting ") + toMatch + ", got " + *v + ": rejected");
-        }
-    }
-    return false;
-}
-
-AccessControl::aclresult_t htAccessControl::authorized(const SPRequest& request, const Session* session) const
+const PropertySet* ApacheRequestMapper::getPropertySet(const char* name, const char* ns) const
 {
-    // Make sure the object is our type.
-    const ShibTargetApache* sta=dynamic_cast<const ShibTargetApache*>(&request);
-    if (!sta)
-        throw ConfigurationException("Request wrapper object was not of correct type.");
+    const PropertySet* s=reinterpret_cast<const PropertySet*>(m_propsKey->getData());
+    return s ? s->getPropertySet(name,ns) : nullptr;
+}
 
-    int m=sta->m_req->method_number;
-    bool method_restricted=false;
-    const char *t, *w;
+const xercesc::DOMElement* ApacheRequestMapper::getElement() const
+{
+    const PropertySet* s=reinterpret_cast<const PropertySet*>(m_propsKey->getData());
+    return s ? s->getElement() : nullptr;
+}
 
-    const array_header* reqs_arr=ap_requires(sta->m_req);
-    if (!reqs_arr)
-        return shib_acl_indeterminate;  // should never happen
+// Authz callbacks for Apache 2.4
+#ifdef SHIB_APACHE_24
+pair<ShibTargetApache*,authz_status> shib_base_check_authz(request_rec* r)
+{
+    shib_request_config* rc = (shib_request_config*)ap_get_module_config(r->request_config, &mod_shib);
+    if (!rc || !rc->sta) {
+        ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, SH_AP_R(r), "shib_base_check_authz found no per-request structure");
+        return make_pair(nullptr, AUTHZ_GENERAL_ERROR);
+    }
+    else if (!rc->sta->isInitialized()) {
+        return make_pair(nullptr, AUTHZ_DENIED_NO_USER);
+    }
+    return make_pair(rc->sta, AUTHZ_GRANTED);
+}
 
-       // Check for an "embedded" AccessControl plugin.
-       if (sta->m_dc->szAccessControl) {
-               aclresult_t result = shib_acl_false;
-               try {
-            ifstream aclfile(sta->m_dc->szAccessControl);
-            if (!aclfile)
-                throw ConfigurationException("Unable to open access control file ($1).", params(1, sta->m_dc->szAccessControl));
-            xercesc::DOMDocument* acldoc = XMLToolingConfig::getConfig().getParser().parse(aclfile);
-                   XercesJanitor<xercesc::DOMDocument> docjanitor(acldoc);
-                   static XMLCh _type[] = UNICODE_LITERAL_4(t,y,p,e);
-            string t(XMLHelper::getAttrString(acldoc ? acldoc->getDocumentElement() : nullptr, nullptr, _type));
-            if (t.empty())
-                throw ConfigurationException("Missing type attribute in AccessControl plugin configuration.");
-            scoped_ptr<AccessControl> aclplugin(SPConfig::getConfig().AccessControlManager.newPlugin(t.c_str(), acldoc->getDocumentElement()));
-                       Locker acllock(aclplugin.get());
-                       result = aclplugin->authorized(request, session);
-               }
-               catch (std::exception& ex) {
-                       request.log(SPRequest::SPError, ex.what());
-               }
+extern "C" static authz_status shib_shibboleth_check_authz(request_rec* r, const char* require_line, const void*)
+{
+    pair<ShibTargetApache*,authz_status> sta = shib_base_check_authz(r);
+    if (!sta.first)
+        return sta.second;
+    return AUTHZ_GRANTED;
+}
 
-        if (result == shib_acl_true && sta->m_dc->bRequireAll != 1) {
-            // If we're not insisting that all rules be met, then we're done.
-            request.log(SPRequest::SPDebug, "htaccess: embedded AccessControl plugin was successful, granting access");
-            return shib_acl_true;
-        }
-        else if (result != shib_acl_true && sta->m_dc->bRequireAll == 1) {
-            // If we're insisting that all rules be met, which is not something Apache really handles well,
-            // then we either return false or indeterminate based on the authoritative option, which defaults on.
-            if (sta->m_dc->bAuthoritative != 0) {
-                request.log(SPRequest::SPDebug, "htaccess: embedded AccessControl plugin was unsuccessful, denying access");
-                return shib_acl_false;
-            }
+extern "C" static authz_status shib_validuser_check_authz(request_rec* r, const char* require_line, const void*)
+{
+    pair<ShibTargetApache*,authz_status> sta = shib_base_check_authz(r);
+    if (!sta.first)
+        return sta.second;
 
-            request.log(SPRequest::SPDebug, "htaccess: embedded AccessControl plugin was unsuccessful but not authoritative, leaving it up to Apache");
-            return shib_acl_indeterminate;
+    try {
+        const Session* session = sta.first->getSession(false);
+        if (session) {
+            sta.first->log(SPRequest::SPDebug, "htaccess: accepting valid-user based on active session");
+            return AUTHZ_GRANTED;
         }
     }
+    catch (std::exception& e) {
+        sta.first->log(SPRequest::SPWarn, string("htaccess: unable to obtain session for access control check: ") +  e.what());
+    }
 
+    return AUTHZ_DENIED_NO_USER;
+}
 
-    require_line* reqs=(require_line*)reqs_arr->elts;
-
-    for (int x=0; x<reqs_arr->nelts; x++) {
-        // This rule should be completely ignored, the method doesn't fit.
-        // The rule just doesn't exist for our purposes.
-        if (!(reqs[x].method_mask & (1 << m)))
-            continue;
-
-        method_restricted=true; // this lets us know at the end that at least one rule was potentially enforcable.
+extern "C" static authz_status shib_user_check_authz(request_rec* r, const char* require_line, const void*)
+{
+    if (!r->user)
+        return AUTHZ_DENIED_NO_USER;
+    pair<ShibTargetApache*,authz_status> sta = shib_base_check_authz(r);
+    if (!sta.first)
+        return sta.second;
+
+    const htAccessControl& hta = dynamic_cast<const ApacheRequestMapper*>(sta.first->getRequestSettings().first)->getHTAccessControl();
+    if (hta.doUser(*sta.first, require_line) == AccessControl::shib_acl_true)
+        return AUTHZ_GRANTED;
+    return AUTHZ_DENIED;
+}
 
-        // Tracks status of this rule's evaluation.
-        bool status = false;
+extern "C" static authz_status shib_acclass_check_authz(request_rec* r, const char* require_line, const void*)
+{
+    pair<ShibTargetApache*,authz_status> sta = shib_base_check_authz(r);
+    if (!sta.first)
+        return sta.second;
 
-        string remote_user = request.getRemoteUser();
+    const htAccessControl& hta = dynamic_cast<const ApacheRequestMapper*>(sta.first->getRequestSettings().first)->getHTAccessControl();
 
-        t = reqs[x].requirement;
-        w = ap_getword_white(sta->m_req->pool, &t);
+    try {
+        const Session* session = sta.first->getSession(false);
+        if (session && hta.doAuthnContext(*sta.first, session->getAuthnContextClassRef(), require_line) == AccessControl::shib_acl_true)
+            return AUTHZ_GRANTED;
+        return AUTHZ_DENIED;
+    }
+    catch (std::exception& e) {
+        sta.first->log(SPRequest::SPWarn, string("htaccess: unable to obtain session for access control check: ") +  e.what());
+    }
 
-        if (!strcasecmp(w,"shibboleth")) {
-            // This is a dummy rule needed because Apache conflates authn and authz.
-            // Without some require rule, AuthType is ignored and no check_user hooks run.
+    return AUTHZ_GENERAL_ERROR;
+}
 
-            // We evaluate to false if ShibAccessControl is used and ShibRequireAll is off.
-            // This allows actual rules to dictate the result, since ShibAccessControl returned
-            // non-true, and if nothing else is used, access will be denied.
-            if (!sta->m_dc->szAccessControl || sta->m_dc->bRequireAll == 1) {
-                // We evaluate to true, because ShibRequireAll is enabled (so a true is just a no-op)
-                // or because there was no other AccessControl rule in place, so this may be the only
-                // rule in effect.
-                status = true;
-            }
-        }
-        else if (!strcmp(w,"valid-user") && session) {
-            request.log(SPRequest::SPDebug, "htaccess: accepting valid-user based on active session");
-            status = true;
-        }
-        else if (!strcmp(w,"user") && !remote_user.empty()) {
-            bool regexp = false;
-            while (*t) {
-                w = ap_getword_conf(sta->m_req->pool,&t);
-                if (*w == '~') {
-                    regexp = true;
-                    continue;
-                }
-                else if (*w == '!') {
-                    // A negated rule presumes success unless a match is found.
-                    status = true;
-                    if (*(w+1) == '~')
-                        regexp = true;
-                    continue;
-                }
+extern "C" static authz_status shib_acdecl_check_authz(request_rec* r, const char* require_line, const void*)
+{
+    pair<ShibTargetApache*,authz_status> sta = shib_base_check_authz(r);
+    if (!sta.first)
+        return sta.second;
 
-                // Figure out if there's a match.
-                bool match = false;
-                if (regexp) {
-                    try {
-                        // To do regex matching, we have to convert from UTF-8.
-                        auto_arrayptr<XMLCh> trans(fromUTF8(w));
-                        RegularExpression re(trans.get());
-                        auto_arrayptr<XMLCh> trans2(fromUTF8(remote_user.c_str()));
-                        match = re.matches(trans2.get());
-                    }
-                    catch (XMLException& ex) {
-                        auto_ptr_char tmp(ex.getMessage());
-                        request.log(SPRequest::SPError,
-                            string("htaccess plugin caught exception while parsing regular expression (") + w + "): " + tmp.get());
-                    }
-                }
-                else if (remote_user == w) {
-                    match = true;
-                }
+    const htAccessControl& hta = dynamic_cast<const ApacheRequestMapper*>(sta.first->getRequestSettings().first)->getHTAccessControl();
 
-                if (match) {
-                    // If we matched, then we're done with this rule either way and we flip status to reflect the outcome.
-                    status = !status;
-                    if (request.isPriorityEnabled(SPRequest::SPDebug))
-                        request.log(SPRequest::SPDebug,
-                            string("htaccess: require user ") + (!status ? "rejecting (" : "accepting (") + remote_user + ")");
-                    break;
-                }
-            }
-        }
-        else if (!strcmp(w,"group")  && !remote_user.empty()) {
-            SH_AP_TABLE* grpstatus = nullptr;
-            if (sta->m_dc->szAuthGrpFile) {
-                if (request.isPriorityEnabled(SPRequest::SPDebug))
-                    request.log(SPRequest::SPDebug,string("htaccess plugin using groups file: ") + sta->m_dc->szAuthGrpFile);
-                grpstatus = groups_for_user(sta->m_req,remote_user.c_str(),sta->m_dc->szAuthGrpFile);
-            }
+    try {
+        const Session* session = sta.first->getSession(false);
+        if (session && hta.doAuthnContext(*sta.first, session->getAuthnContextDeclRef(), require_line) == AccessControl::shib_acl_true)
+            return AUTHZ_GRANTED;
+        return AUTHZ_DENIED;
+    }
+    catch (std::exception& e) {
+        sta.first->log(SPRequest::SPWarn, string("htaccess: unable to obtain session for access control check: ") +  e.what());
+    }
 
-            while (*t) {
-                w = ap_getword_conf(sta->m_req->pool,&t);
-                if (*w == '!') {
-                    // A negated rule presumes success unless a match is found.
-                    status = true;
-                    continue;
-                }
+    return AUTHZ_GENERAL_ERROR;
+}
 
-                if (grpstatus && ap_table_get(grpstatus,w)) {
-                    // If we matched, then we're done with this rule either way and we flip status to reflect the outcome.
-                    status = !status;
-                    request.log(SPRequest::SPDebug, string("htaccess: require group ") + (!status ? "rejecting (" : "accepting (") + w + ")");
-                    break;
-                }
-            }
-        }
-        else if (!strcmp(w,"authnContextClassRef") || !strcmp(w,"authnContextDeclRef")) {
-            const char* ref = !strcmp(w,"authnContextClassRef") ? session->getAuthnContextClassRef() : session->getAuthnContextDeclRef();
-            if (ref && *ref) {
-                bool regexp = false;
-                while (ref && *t) {
-                    w = ap_getword_conf(sta->m_req->pool,&t);
-                    if (*w == '~') {
-                        regexp=true;
-                        continue;
-                    }
-                    else if (*w == '!') {
-                        // A negated rule presumes success unless a match is found.
-                        status = true;
-                        if (*(w+1)=='~')
-                            regexp = true;
-                        continue;
-                    }
+extern "C" static authz_status shib_attr_check_authz(request_rec* r, const char* require_line, const void*)
+{
+    pair<ShibTargetApache*,authz_status> sta = shib_base_check_authz(r);
+    if (!sta.first)
+        return sta.second;
 
-                    // Figure out if there's a match.
-                    bool match = false;
-                    if (regexp) {
-                        try {
-                            // To do regex matching, we have to convert from UTF-8.
-                            RegularExpression re(w);
-                            match = re.matches(ref);
-                        }
-                        catch (XMLException& ex) {
-                            auto_ptr_char tmp(ex.getMessage());
-                            request.log(SPRequest::SPError,
-                                string("htaccess plugin caught exception while parsing regular expression (") + w + "): " + tmp.get());
-                        }
-                    }
-                    else if (!strcmp(w,ref)) {
-                        match = true;
-                    }
+    const htAccessControl& hta = dynamic_cast<const ApacheRequestMapper*>(sta.first->getRequestSettings().first)->getHTAccessControl();
 
-                    if (match) {
-                        // If we matched, then we're done with this rule either way and we flip status to reflect the outcome.
-                        status = !status;
-                        if (request.isPriorityEnabled(SPRequest::SPDebug))
-                            request.log(SPRequest::SPDebug,
-                                string("htaccess: require authnContext ") + (!status ? "rejecting (" : "accepting (") + ref + ")");
-                        break;
-                    }
-                }
-            }
-            else if (request.isPriorityEnabled(SPRequest::SPDebug)) {
-                request.log(SPRequest::SPDebug, "htaccess: require authnContext rejecting session with no context associated");
-            }
-        }
-        else if (!session) {
-            request.log(SPRequest::SPError, string("htaccess: require ") + w + " not given a valid session, are you using lazy sessions?");
+    try {
+        const Session* session = sta.first->getSession(false);
+        if (session) {
+            const char* rule = ap_getword_conf(r->pool, &require_line);
+            if (rule && hta.doShibAttr(*sta.first, session, rule, require_line) == AccessControl::shib_acl_true)
+                return AUTHZ_GRANTED;
         }
-        else {
-            // Find the attribute(s) matching the require rule.
-            pair<multimap<string,const Attribute*>::const_iterator,multimap<string,const Attribute*>::const_iterator> attrs =
-                session->getIndexedAttributes().equal_range(w);
-
-            bool regexp=false;
-            while (!status && attrs.first!=attrs.second && *t) {
-                w=ap_getword_conf(sta->m_req->pool,&t);
-                if (*w=='~') {
-                    regexp=true;
-                    continue;
-                }
+        return AUTHZ_DENIED;
+    }
+    catch (std::exception& e) {
+        sta.first->log(SPRequest::SPWarn, string("htaccess: unable to obtain session for access control check: ") +  e.what());
+    }
 
-                try {
-                    scoped_ptr<RegularExpression> re;
-                    if (regexp) {
-                        auto_arrayptr<XMLCh> trans(fromUTF8(w));
-                        re.reset(new xercesc::RegularExpression(trans.get()));
-                    }
-                    
-                    pair<multimap<string,const Attribute*>::const_iterator,multimap<string,const Attribute*>::const_iterator> attrs2(attrs);
-                    for (; !status && attrs2.first!=attrs2.second; ++attrs2.first) {
-                        if (checkAttribute(request, attrs2.first->second, w, regexp ? re.get() : nullptr)) {
-                            status = true;
-                        }
-                    }
-                }
-                catch (XMLException& ex) {
-                    auto_ptr_char tmp(ex.getMessage());
-                    request.log(SPRequest::SPError,
-                        string("htaccess plugin caught exception while parsing regular expression (") + w + "): " + tmp.get()
-                        );
-                }
-            }
-        }
+    return AUTHZ_GENERAL_ERROR;
+}
 
-        // If status is false, we found a rule we couldn't satisfy.
-        // Could be an unknown rule to us, or it just didn't match.
+extern "C" static authz_status shib_plugin_check_authz(request_rec* r, const char* require_line, const void*)
+{
+    pair<ShibTargetApache*,authz_status> sta = shib_base_check_authz(r);
+    if (!sta.first)
+        return sta.second;
 
-        if (status && sta->m_dc->bRequireAll != 1) {
-            // If we're not insisting that all rules be met, then we're done.
-            request.log(SPRequest::SPDebug, "htaccess: a rule was successful, granting access");
-            return shib_acl_true;
-        }
-        else if (!status && sta->m_dc->bRequireAll == 1) {
-            // If we're insisting that all rules be met, which is not something Apache really handles well,
-            // then we either return false or indeterminate based on the authoritative option, which defaults on.
-            if (sta->m_dc->bAuthoritative != 0) {
-                request.log(SPRequest::SPDebug, "htaccess: a rule was unsuccessful, denying access");
-                return shib_acl_false;
-            }
+    const htAccessControl& hta = dynamic_cast<const ApacheRequestMapper*>(sta.first->getRequestSettings().first)->getHTAccessControl();
 
-            request.log(SPRequest::SPDebug, "htaccess: a rule was unsuccessful but not authoritative, leaving it up to Apache");
-            return shib_acl_indeterminate;
+    try {
+        const Session* session = sta.first->getSession(false);
+        if (session) {
+            const char* config = ap_getword_conf(r->pool, &require_line);
+            if (config && hta.doAccessControl(*sta.first, session, config) == AccessControl::shib_acl_true)
+                return AUTHZ_GRANTED;
         }
-
-        // Otherwise, we keep going. If we're requring all, then we have to check every rule.
-        // If not we just didn't find a successful rule yet, so we keep going anyway.
-    }
-
-    // If we get here, we either "failed" or we're in require all mode (but not both).
-    // If no rules possibly apply or we insisted that all rules check out, then we're good.
-    if (!method_restricted) {
-        request.log(SPRequest::SPDebug, "htaccess: no rules applied to this request method, granting access");
-        return shib_acl_true;
+        return AUTHZ_DENIED;
     }
-    else if (sta->m_dc->bRequireAll == 1) {
-        request.log(SPRequest::SPDebug, "htaccess: all rules successful, granting access");
-        return shib_acl_true;
-    }
-    else if (sta->m_dc->bAuthoritative != 0) {
-        request.log(SPRequest::SPDebug, "htaccess: no rules were successful, denying access");
-        return shib_acl_false;
+    catch (std::exception& e) {
+        sta.first->log(SPRequest::SPWarn, string("htaccess: unable to obtain session for access control check: ") +  e.what());
     }
 
-    request.log(SPRequest::SPDebug, "htaccess: no rules were successful but not authoritative, leaving it up to Apache");
-    return shib_acl_indeterminate;
+    return AUTHZ_GENERAL_ERROR;
 }
+#endif
 
+// Command manipulation functions
 
-// Initial look at a request - create the per-request structure
-static int shib_post_read(request_rec *r)
+extern "C" const char* ap_set_global_string_slot(cmd_parms* parms, void*, const char* arg)
 {
-    init_request_config(r);
-    //ap_log_rerror(APLOG_MARK,APLOG_DEBUG|APLOG_NOERRNO,SH_AP_R(r), "shib_post_read");
-    return DECLINED;
+    *((char**)(parms->info))=ap_pstrdup(parms->pool,arg);
+    return nullptr;
 }
 
-// fixups: set environment vars
-
-extern "C" int shib_fixups(request_rec* r)
+extern "C" const char* shib_set_server_string_slot(cmd_parms* parms, void*, const char* arg)
 {
-  shib_request_config *rc = (shib_request_config*)ap_get_module_config(r->request_config, &mod_shib);
-  shib_dir_config *dc = (shib_dir_config*)ap_get_module_config(r->per_dir_config, &mod_shib);
-  if (dc->bOff==1 || dc->bUseEnvVars==0)
-    return DECLINED;
+    char* base=(char*)ap_get_module_config(parms->server->module_config,&mod_shib);
+    size_t offset=(size_t)parms->info;
+    *((char**)(base + offset))=ap_pstrdup(parms->pool,arg);
+    return nullptr;
+}
 
-  ap_log_rerror(APLOG_MARK,APLOG_DEBUG|APLOG_NOERRNO,SH_AP_R(r), "shib_fixup(%d): ENTER", (int)getpid());
+extern "C" const char* shib_ap_set_file_slot(cmd_parms* parms,
+#ifdef SHIB_APACHE_13
+                                            char* arg1, char* arg2
+#else
+                                            void* arg1, const char* arg2
+#endif
+                                            )
+{
+  ap_set_file_slot(parms, arg1, arg2);
+  return DECLINE_CMD;
+}
 
-  if (rc==nullptr || rc->env==nullptr || ap_is_empty_table(rc->env))
-        return DECLINED;
+extern "C" const char* shib_table_set(cmd_parms* parms, shib_dir_config* dc, const char* arg1, const char* arg2)
+{
+    if (!dc->tSettings)
+        dc->tSettings = ap_make_table(parms->pool, 4);
+    ap_table_set(dc->tSettings, arg1, arg2);
+    return nullptr;
+}
 
-  ap_log_rerror(APLOG_MARK,APLOG_DEBUG|APLOG_NOERRNO,SH_AP_R(r), "shib_fixup adding %d vars", ap_table_elts(rc->env)->nelts);
-  r->subprocess_env = ap_overlay_tables(r->pool, r->subprocess_env, rc->env);
+#ifndef SHIB_APACHE_24
+extern "C" const char* shib_set_acl_slot(cmd_parms* params, shib_dir_config* dc, char* arg)
+{
+    bool absolute;
+    switch (*arg) {
+        case 0:
+            absolute = false;
+            break;
+        case '/':
+        case '\\':
+            absolute = true;
+            break;
+        case '.':
+            absolute = (*(arg+1) == '.' || *(arg+1) == '/' || *(arg+1) == '\\');
+            break;
+        default:
+            absolute = *(arg+1) == ':';
+    }
 
-  return OK;
+    if (absolute || !params->path)
+        dc->szAccessControl = ap_pstrdup(params->pool, arg);
+    else
+        dc->szAccessControl = ap_pstrcat(params->pool, params->path, arg);
+    return nullptr;
 }
+#endif
+
 
 #ifdef SHIB_APACHE_13
 /*
@@ -1435,8 +1783,10 @@ extern "C" void shib_child_init(apr_pool_t* p, server_rec* s)
         ap_log_error(APLOG_MARK,APLOG_CRIT|APLOG_NOERRNO,SH_AP_R(s),"shib_child_init() failed to initialize libraries");
         exit(1);
     }
-    g_Config->AccessControlManager.registerFactory(HT_ACCESS_CONTROL,&htAccessFactory);
-    g_Config->RequestMapperManager.registerFactory(NATIVE_REQUEST_MAPPER,&ApacheRequestMapFactory);
+#ifndef SHIB_APACHE_24
+    g_Config->AccessControlManager.registerFactory(HT_ACCESS_CONTROL, &htAccessFactory);
+#endif
+    g_Config->RequestMapperManager.registerFactory(NATIVE_REQUEST_MAPPER, &ApacheRequestMapFactory);
 
     try {
         if (!g_Config->instantiate(g_szSHIBConfig, true))
@@ -1448,11 +1798,11 @@ extern "C" void shib_child_init(apr_pool_t* p, server_rec* s)
         exit(1);
     }
 
-    ServiceProvider* sp=g_Config->getServiceProvider();
+    ServiceProvider* sp = g_Config->getServiceProvider();
     xmltooling::Locker locker(sp);
-    const PropertySet* props=sp->getPropertySet("InProcess");
+    const PropertySet* props = sp->getPropertySet("InProcess");
     if (props) {
-        pair<bool,const char*> unsetValue=props->getString("unsetHeaderValue");
+        pair<bool,const char*> unsetValue = props->getString("unsetHeaderValue");
         if (unsetValue.first)
             g_unsetHeaderValue = unsetValue.second;
         pair<bool,bool> flag=props->getBool("checkSpoofing");
@@ -1469,7 +1819,7 @@ extern "C" void shib_child_init(apr_pool_t* p, server_rec* s)
     // Set the cleanup handler
     apr_pool_cleanup_register(p, nullptr, &shib_exit, apr_pool_cleanup_null);
 
-    ap_log_error(APLOG_MARK,APLOG_DEBUG|APLOG_NOERRNO,SH_AP_R(s),"shib_child_init() done");
+    ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, SH_AP_R(s), "shib_child_init() done");
 }
 
 // Output filters
@@ -1583,6 +1933,9 @@ static command_rec shire_cmds[] = {
   {"AuthzShibAuthoritative", (config_fn_t)ap_set_flag_slot,
    (void *) XtOffsetOf (shib_dir_config, bAuthoritative),
    OR_AUTHCFG, FLAG, "Allow failed mod_shib htaccess authorization to fall through to other modules"},
+  {"ShibCompatWith24", (config_fn_t)ap_set_flag_slot,
+   (void *) XtOffsetOf (shib_dir_config, bCompatWith24),
+   OR_AUTHCFG, FLAG, "Support Apache 2.4-style require rules"},
   {"ShibUseEnvironment", (config_fn_t)ap_set_flag_slot,
    (void *) XtOffsetOf (shib_dir_config, bUseEnvVars),
    OR_AUTHCFG, FLAG, "Export attributes using environment variables (default)"},
@@ -1624,31 +1977,60 @@ module MODULE_VAR_EXPORT mod_shib = {
     shib_post_read             /* post read-request */
 };
 
-#elif defined(SHIB_APACHE_20) || defined(SHIB_APACHE_22)
+#else
 
-//static const char * const authnPre[] = { "mod_gss.c", nullptr };
+#ifdef SHIB_APACHE_24
+extern "C" static const authz_provider shib_authz_shibboleth_provider = { &shib_shibboleth_check_authz, nullptr };
+extern "C" static const authz_provider shib_authz_validuser_provider = { &shib_validuser_check_authz, nullptr };
+extern "C" static const authz_provider shib_authz_user_provider = { &shib_user_check_authz, nullptr };
+extern "C" static const authz_provider shib_authz_acclass_provider = { &shib_acclass_check_authz, nullptr };
+extern "C" static const authz_provider shib_authz_acdecl_provider = { &shib_acdecl_check_authz, nullptr };
+extern "C" static const authz_provider shib_authz_attr_provider = { &shib_attr_check_authz, nullptr };
+extern "C" static const authz_provider shib_authz_plugin_provider = { &shib_plugin_check_authz, nullptr };
+#endif
 
 extern "C" void shib_register_hooks (apr_pool_t *p)
 {
 #ifdef SHIB_DEFERRED_HEADERS
-  ap_register_output_filter("SHIB_HEADERS_OUT", do_output_filter, nullptr, AP_FTYPE_CONTENT_SET);
-  ap_hook_insert_filter(set_output_filter, nullptr, nullptr, APR_HOOK_LAST);
-  ap_register_output_filter("SHIB_HEADERS_ERR", do_error_filter, nullptr, AP_FTYPE_CONTENT_SET);
-  ap_hook_insert_error_filter(set_error_filter, nullptr, nullptr, APR_HOOK_LAST);
-  ap_hook_post_read_request(shib_post_read, nullptr, nullptr, APR_HOOK_MIDDLE);
+    ap_register_output_filter("SHIB_HEADERS_OUT", do_output_filter, nullptr, AP_FTYPE_CONTENT_SET);
+    ap_hook_insert_filter(set_output_filter, nullptr, nullptr, APR_HOOK_LAST);
+    ap_register_output_filter("SHIB_HEADERS_ERR", do_error_filter, nullptr, AP_FTYPE_CONTENT_SET);
+    ap_hook_insert_error_filter(set_error_filter, nullptr, nullptr, APR_HOOK_LAST);
+    ap_hook_post_read_request(shib_post_read, nullptr, nullptr, APR_HOOK_MIDDLE);
+#endif
+    ap_hook_child_init(shib_child_init, nullptr, nullptr, APR_HOOK_MIDDLE);
+    const char* prereq = getenv("SHIBSP_APACHE_PREREQ");
+#ifdef SHIB_APACHE_24
+    if (prereq && *prereq) {
+        const char* const authnPre[] = { prereq, nullptr };
+        ap_hook_check_authn(shib_check_user, authnPre, nullptr, APR_HOOK_MIDDLE, AP_AUTH_INTERNAL_PER_URI);
+    }
+    else {
+        ap_hook_check_authn(shib_check_user, nullptr, nullptr, APR_HOOK_MIDDLE, AP_AUTH_INTERNAL_PER_URI);
+    }
+    ap_hook_check_authz(shib_auth_checker, nullptr, nullptr, APR_HOOK_FIRST, AP_AUTH_INTERNAL_PER_URI);
+#else
+    if (prereq && *prereq) {
+        const char* const authnPre[] = { prereq, nullptr };
+        ap_hook_check_user_id(shib_check_user, authnPre, nullptr, APR_HOOK_MIDDLE);
+    }
+    else {
+        ap_hook_check_user_id(shib_check_user, nullptr, nullptr, APR_HOOK_MIDDLE);
+    }
+    ap_hook_auth_checker(shib_auth_checker, nullptr, nullptr, APR_HOOK_FIRST);
+#endif
+    ap_hook_handler(shib_handler, nullptr, nullptr, APR_HOOK_LAST);
+    ap_hook_fixups(shib_fixups, nullptr, nullptr, APR_HOOK_MIDDLE);
+
+#ifdef SHIB_APACHE_24
+    ap_register_auth_provider(p, AUTHZ_PROVIDER_GROUP, "shibboleth", AUTHZ_PROVIDER_VERSION, &shib_authz_shibboleth_provider, AP_AUTH_INTERNAL_PER_CONF);
+    ap_register_auth_provider(p, AUTHZ_PROVIDER_GROUP, "valid-user", AUTHZ_PROVIDER_VERSION, &shib_authz_validuser_provider, AP_AUTH_INTERNAL_PER_CONF);
+    ap_register_auth_provider(p, AUTHZ_PROVIDER_GROUP, "user", AUTHZ_PROVIDER_VERSION, &shib_authz_user_provider, AP_AUTH_INTERNAL_PER_CONF);
+    ap_register_auth_provider(p, AUTHZ_PROVIDER_GROUP, "authnContextClassRef", AUTHZ_PROVIDER_VERSION, &shib_authz_acclass_provider, AP_AUTH_INTERNAL_PER_CONF);
+    ap_register_auth_provider(p, AUTHZ_PROVIDER_GROUP, "authnContextDeclRef", AUTHZ_PROVIDER_VERSION, &shib_authz_acdecl_provider, AP_AUTH_INTERNAL_PER_CONF);
+    ap_register_auth_provider(p, AUTHZ_PROVIDER_GROUP, "shib-attr", AUTHZ_PROVIDER_VERSION, &shib_authz_attr_provider, AP_AUTH_INTERNAL_PER_CONF);
+    ap_register_auth_provider(p, AUTHZ_PROVIDER_GROUP, "shib-plugin", AUTHZ_PROVIDER_VERSION, &shib_authz_plugin_provider, AP_AUTH_INTERNAL_PER_CONF);
 #endif
-  ap_hook_child_init(shib_child_init, nullptr, nullptr, APR_HOOK_MIDDLE);
-  const char* prereq = getenv("SHIBSP_APACHE_PREREQ");
-  if (prereq && *prereq) {
-    const char* const authnPre[] = { prereq, nullptr };
-    ap_hook_check_user_id(shib_check_user, authnPre, nullptr, APR_HOOK_MIDDLE);
-  }
-  else {
-    ap_hook_check_user_id(shib_check_user, nullptr, nullptr, APR_HOOK_MIDDLE);
-  }
-  ap_hook_auth_checker(shib_auth_checker, nullptr, nullptr, APR_HOOK_FIRST);
-  ap_hook_handler(shib_handler, nullptr, nullptr, APR_HOOK_LAST);
-  ap_hook_fixups(shib_fixups, nullptr, nullptr, APR_HOOK_MIDDLE);
 }
 
 // SHIB Module commands
@@ -1671,9 +2053,6 @@ static command_rec shib_cmds[] = {
     AP_INIT_TAKE2("ShibRequestSetting", (config_fn_t)shib_table_set, nullptr,
         OR_AUTHCFG, "Set arbitrary Shibboleth request property for content"),
 
-    AP_INIT_TAKE1("ShibAccessControl", (config_fn_t)shib_set_acl_slot, nullptr,
-        OR_AUTHCFG, "Set arbitrary Shibboleth access control plugin for content"),
-
     AP_INIT_FLAG("ShibDisable", (config_fn_t)ap_set_flag_slot,
         (void *) offsetof (shib_dir_config, bOff),
         OR_AUTHCFG, "Disable all Shib module activity here to save processing effort"),
@@ -1695,15 +2074,26 @@ static command_rec shib_cmds[] = {
     AP_INIT_TAKE1("ShibRedirectToSSL", (config_fn_t)ap_set_string_slot,
         (void *) offsetof (shib_dir_config, szRedirectToSSL),
         OR_AUTHCFG, "Redirect non-SSL requests to designated port"),
+#ifdef SHIB_APACHE_24
+    AP_INIT_FLAG("ShibRequestMapperAuthz", (config_fn_t)ap_set_flag_slot,
+        (void *) offsetof (shib_dir_config, bRequestMapperAuthz),
+        OR_AUTHCFG, "Support access control via shibboleth2.xml / RequestMapper"),
+#else
     AP_INIT_TAKE1("AuthGroupFile", (config_fn_t)shib_ap_set_file_slot,
         (void *) offsetof (shib_dir_config, szAuthGrpFile),
         OR_AUTHCFG, "Text file containing group names and member user IDs"),
+    AP_INIT_TAKE1("ShibAccessControl", (config_fn_t)shib_set_acl_slot, nullptr,
+        OR_AUTHCFG, "Set arbitrary Shibboleth access control plugin for content"),
     AP_INIT_FLAG("ShibRequireAll", (config_fn_t)ap_set_flag_slot,
         (void *) offsetof (shib_dir_config, bRequireAll),
         OR_AUTHCFG, "All require directives must match"),
     AP_INIT_FLAG("AuthzShibAuthoritative", (config_fn_t)ap_set_flag_slot,
         (void *) offsetof (shib_dir_config, bAuthoritative),
         OR_AUTHCFG, "Allow failed mod_shib htaccess authorization to fall through to other modules"),
+    AP_INIT_FLAG("ShibCompatWith24", (config_fn_t)ap_set_flag_slot,
+        (void *) offsetof (shib_dir_config, bCompatWith24),
+        OR_AUTHCFG, "Support Apache 2.4-style require rules"),
+#endif
     AP_INIT_FLAG("ShibUseEnvironment", (config_fn_t)ap_set_flag_slot,
         (void *) offsetof (shib_dir_config, bUseEnvVars),
         OR_AUTHCFG, "Export attributes using environment variables (default)"),
@@ -1727,8 +2117,6 @@ module AP_MODULE_DECLARE_DATA mod_shib = {
     shib_register_hooks         /* register hooks */
 };
 
-#else
-#error "unsupported Apache version"
 #endif
 
 }
diff --git a/apache/mod_shib24.vcxproj b/apache/mod_shib24.vcxproj
new file mode 100644 (file)
index 0000000..d8bfb7a
--- /dev/null
@@ -0,0 +1,224 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup Label="ProjectConfigurations">
+    <ProjectConfiguration Include="Debug|Win32">
+      <Configuration>Debug</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Debug|x64">
+      <Configuration>Debug</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|Win32">
+      <Configuration>Release</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|x64">
+      <Configuration>Release</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+  </ItemGroup>
+  <PropertyGroup Label="Globals">
+    <ProjectGuid>{B44C0852-83B8-4FB2-A86E-097C9C8256D1}</ProjectGuid>
+    <ProjectName>mod_shib_24</ProjectName>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <CharacterSet>MultiByte</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <CharacterSet>MultiByte</CharacterSet>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <CharacterSet>MultiByte</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <CharacterSet>MultiByte</CharacterSet>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+  <ImportGroup Label="ExtensionSettings">
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+    <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props" />
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+    <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props" />
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+    <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props" />
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+    <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props" />
+  </ImportGroup>
+  <PropertyGroup Label="UserMacros" />
+  <PropertyGroup>
+    <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+    <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectName)-$(Configuration)\</IntDir>
+    <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
+    <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
+    <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Platform)\$(ProjectName)-$(Configuration)\</IntDir>
+    <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
+    <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectName)-$(Configuration)\</IntDir>
+    <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
+    <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
+    <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Platform)\$(ProjectName)-$(Configuration)\</IntDir>
+    <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
+    <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
+    <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
+    <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
+    <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
+    <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
+    <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
+    <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
+    <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
+    <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
+    <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
+    <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
+    <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
+    <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.so</TargetExt>
+    <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.so</TargetExt>
+    <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.so</TargetExt>
+    <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.so</TargetExt>
+  </PropertyGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <ClCompile>
+      <Optimization>MaxSpeed</Optimization>
+      <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+      <AdditionalIncludeDirectories>..;\Apache24\include;..\..\cpp-xmltooling;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <PreprocessorDefinitions>NDEBUG;WIN32;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <StringPooling>true</StringPooling>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <RuntimeTypeInfo>true</RuntimeTypeInfo>
+      <WarningLevel>Level3</WarningLevel>
+    </ClCompile>
+    <ResourceCompile>
+      <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <Culture>0x0409</Culture>
+    </ResourceCompile>
+    <Link>
+      <AdditionalDependencies>xerces-c_3.lib;xmltooling-lite1.lib;libapr-1.lib;libaprutil-1.lib;libhttpd.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalLibraryDirectories>..\..\cpp-xmltooling\$(Configuration);\Apache24\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+      <DataExecutionPrevention>
+      </DataExecutionPrevention>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+    </Link>
+    <Bscmake>
+      <SuppressStartupBanner>true</SuppressStartupBanner>
+    </Bscmake>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <ClCompile>
+      <Optimization>MaxSpeed</Optimization>
+      <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+      <AdditionalIncludeDirectories>..;\httpd-2.2-x64\include;..\..\cpp-xmltooling;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <PreprocessorDefinitions>NDEBUG;WIN32;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <StringPooling>true</StringPooling>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <RuntimeTypeInfo>true</RuntimeTypeInfo>
+      <WarningLevel>Level3</WarningLevel>
+    </ClCompile>
+    <ResourceCompile>
+      <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <Culture>0x0409</Culture>
+    </ResourceCompile>
+    <Link>
+      <AdditionalDependencies>xerces-c_3.lib;xmltooling-lite1.lib;libapr-1.lib;libaprutil-1.lib;libhttpd.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalLibraryDirectories>..\..\cpp-xmltooling\$(Platform)\$(Configuration);C:\httpd-2.2-x64\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+      <DataExecutionPrevention>
+      </DataExecutionPrevention>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+    </Link>
+    <Bscmake>
+      <SuppressStartupBanner>true</SuppressStartupBanner>
+    </Bscmake>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <ClCompile>
+      <Optimization>Disabled</Optimization>
+      <AdditionalIncludeDirectories>..;\Apache24\include;..\..\cpp-xmltooling;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <PreprocessorDefinitions>_DEBUG;WIN32;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+      <RuntimeTypeInfo>true</RuntimeTypeInfo>
+      <BrowseInformation>true</BrowseInformation>
+      <WarningLevel>Level3</WarningLevel>
+      <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
+    </ClCompile>
+    <ResourceCompile>
+      <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <Culture>0x0409</Culture>
+    </ResourceCompile>
+    <Link>
+      <AdditionalDependencies>xerces-c_3D.lib;xmltooling-lite1D.lib;libapr-1.lib;libaprutil-1.lib;libhttpd.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalLibraryDirectories>..\..\cpp-xmltooling\$(Configuration);\Apache24\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <DataExecutionPrevention>
+      </DataExecutionPrevention>
+    </Link>
+    <Bscmake>
+      <SuppressStartupBanner>true</SuppressStartupBanner>
+    </Bscmake>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <ClCompile>
+      <Optimization>Disabled</Optimization>
+      <AdditionalIncludeDirectories>..;\httpd-2.2-x64\include;..\..\cpp-xmltooling;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <PreprocessorDefinitions>_DEBUG;WIN32;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+      <RuntimeTypeInfo>true</RuntimeTypeInfo>
+      <BrowseInformation>true</BrowseInformation>
+      <WarningLevel>Level3</WarningLevel>
+      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+    </ClCompile>
+    <ResourceCompile>
+      <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <Culture>0x0409</Culture>
+    </ResourceCompile>
+    <Link>
+      <AdditionalDependencies>xerces-c_3D.lib;xmltooling-lite1D.lib;libapr-1.lib;libaprutil-1.lib;libhttpd.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalLibraryDirectories>..\..\cpp-xmltooling\$(Platform)\$(Configuration);C:\httpd-2.2-x64\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <DataExecutionPrevention>
+      </DataExecutionPrevention>
+    </Link>
+    <Bscmake>
+      <SuppressStartupBanner>true</SuppressStartupBanner>
+    </Bscmake>
+  </ItemDefinitionGroup>
+  <ItemGroup>
+    <None Include="Makefile.am" />
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="mod_apache.cpp">
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
+    </ClCompile>
+    <ClCompile Include="mod_shib_24.cpp" />
+  </ItemGroup>
+  <ItemGroup>
+    <ResourceCompile Include="mod_shib_24.rc" />
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="resource.h" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\shibsp\shibsp-lite.vcxproj">
+      <Project>{81f0f7a6-dc36-46ef-957f-f9e81d4403f7}</Project>
+      <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+    </ProjectReference>
+  </ItemGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+  <ImportGroup Label="ExtensionTargets">
+  </ImportGroup>
+</Project>
\ No newline at end of file
diff --git a/apache/mod_shib_24.cpp b/apache/mod_shib_24.cpp
new file mode 100644 (file)
index 0000000..afd219d
--- /dev/null
@@ -0,0 +1,70 @@
+/**
+ * Licensed to the University Corporation for Advanced Internet
+ * Development, Inc. (UCAID) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for
+ * additional information regarding copyright ownership.
+ *
+ * UCAID licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the
+ * License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the License.
+ */
+
+/* mod_shib_24.cpp -- a wrapper around the apache module code to
+ *                   build for Apache 2.4
+ *
+ * Created by:  Scott Cantor
+ *
+ */
+
+#define SHIB_APACHE_24 1
+
+#define MODULE_VAR_EXPORT AP_MODULE_DECLARE_DATA
+#define SH_AP_POOL apr_pool_t
+#define SH_AP_TABLE apr_table_t
+#define SH_AP_CONFIGFILE ap_configfile_t
+#define array_header apr_array_header_t
+
+#define SH_AP_R(r) 0,r
+#define SH_AP_USER(r) r->user
+#define SH_AP_AUTH_TYPE(r) r->ap_auth_type
+
+#define SERVER_ERROR HTTP_INTERNAL_SERVER_ERROR
+#define REDIRECT HTTP_MOVED_TEMPORARILY
+#define ap_pcalloc apr_pcalloc
+#define ap_pstrdup apr_pstrdup
+#define ap_pstrcat apr_pstrcat
+#define ap_psprintf apr_psprintf
+#define ap_table_get apr_table_get
+#define ap_table_add apr_table_add
+#define ap_table_addn apr_table_addn
+#define ap_table_setn apr_table_setn
+#define ap_table_unset apr_table_unset
+#define ap_table_set apr_table_set
+#define ap_table_do apr_table_do
+#define ap_copy_table apr_table_copy
+#define ap_overlay_tables apr_table_overlay
+#define ap_overlap_tables apr_table_overlap
+#define ap_table_elts apr_table_elts
+#define ap_is_empty_table apr_is_empty_table
+#define ap_clear_pool apr_pool_clear
+#define ap_destroy_pool apr_pool_destroy
+#define ap_make_table apr_table_make
+#define AP_OVERLAP_TABLES_SET APR_OVERLAP_TABLES_SET
+
+#define ap_send_http_header(r)
+#define ap_hard_timeout(str,r)
+#define ap_reset_timeout(r)
+#define ap_kill_timeout(r)
+
+#define ap_http_method ap_http_scheme
+
+#include "mod_apache.cpp"
diff --git a/apache/mod_shib_24.rc b/apache/mod_shib_24.rc
new file mode 100644 (file)
index 0000000..c673701
--- /dev/null
@@ -0,0 +1,109 @@
+//Microsoft Developer Studio generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "afxres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+#ifndef _MAC
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION 2,5,0,0
+ PRODUCTVERSION 2,5,0,0
+ FILEFLAGSMASK 0x3fL
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x40004L
+ FILETYPE 0x2L
+ FILESUBTYPE 0x0L
+BEGIN
+    BLOCK "StringFileInfo"
+    BEGIN
+        BLOCK "040904b0"
+        BEGIN
+            VALUE "Comments", "\0"
+            VALUE "CompanyName", "Internet2\0"
+            VALUE "FileDescription", "Shibboleth Apache 2.4 Module\0"
+            VALUE "FileVersion", "2, 5, 0, 0\0"
+            VALUE "InternalName", "mod_shib_22\0"
+            VALUE "LegalCopyright", "Copyright © 2012 UCAID\0"
+            VALUE "LegalTrademarks", "\0"
+            VALUE "OriginalFilename", "mod_shib_22.so\0"
+            VALUE "PrivateBuild", "\0"
+            VALUE "ProductName", "Shibboleth 2.5\0"
+            VALUE "ProductVersion", "2, 5, 0, 0\0"
+            VALUE "SpecialBuild", "\0"
+        END
+    END
+    BLOCK "VarFileInfo"
+    BEGIN
+        VALUE "Translation", 0x409, 1200
+    END
+END
+
+#endif    // !_MAC
+
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE DISCARDABLE 
+BEGIN
+    "resource.h\0"
+END
+
+2 TEXTINCLUDE DISCARDABLE 
+BEGIN
+    "#include ""afxres.h""\r\n"
+    "\0"
+END
+
+3 TEXTINCLUDE DISCARDABLE 
+BEGIN
+    "\r\n"
+    "\0"
+END
+
+#endif    // APSTUDIO_INVOKED
+
+#endif    // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif    // not APSTUDIO_INVOKED
+
index cacbe1d..89de840 100644 (file)
@@ -80,6 +80,9 @@ apache2.config: ${srcdir}/apache2.config.in Makefile ${top_builddir}/config.stat
 apache22.config: ${srcdir}/apache22.config.in Makefile ${top_builddir}/config.status
        $(MAKE) do-build-file FILE=$@
 
+apache24.config: ${srcdir}/apache24.config.in Makefile ${top_builddir}/config.status
+       $(MAKE) do-build-file FILE=$@
+
 shibd-redhat: ${srcdir}/shibd-redhat.in Makefile ${top_builddir}/config.status
        $(MAKE) do-build-file FILE=$@
 
@@ -132,6 +135,7 @@ CLEANFILES = \
        apache.config \
        apache2.config \
        apache22.config \
+       apache24.config \
        shibd-redhat \
        shibd-suse \
        shibd-debian \
@@ -145,6 +149,7 @@ EXTRA_DIST = \
        apache.config.in \
        apache2.config.in \
        apache22.config.in \
+       apache24.config.in \
        shibd-redhat.in \
        shibd-suse.in \
        shibd-debian.in \
diff --git a/configs/apache24.config.in b/configs/apache24.config.in
new file mode 100644 (file)
index 0000000..5475ed7
--- /dev/null
@@ -0,0 +1,38 @@
+# https://wiki.shibboleth.net/confluence/display/SHIB2/NativeSPApacheConfig
+
+# RPM installations on platforms with a conf.d directory will
+# result in this file being copied into that directory for you
+# and preserved across upgrades.
+
+# For non-RPM installs, you should copy the relevant contents of
+# this file to a configuration location you control.
+
+#
+# Load the Shibboleth module.
+#
+LoadModule mod_shib @-PKGLIBDIR-@/mod_shib_24.so
+
+#
+# Used for example logo and style sheet in error templates.
+#
+<IfModule mod_alias.c>
+  <Location /shibboleth-sp>
+    Allow from all
+  </Location>
+  Alias /shibboleth-sp/main.css @-PKGWEBDIR-@/main.css
+  Alias /shibboleth-sp/logo.jpg @-PKGWEBDIR-@/logo.jpg
+</IfModule>
+
+#
+# Configure the module for content.
+#
+# You MUST enable AuthType shibboleth for the module to process
+# any requests, and there MUST be a require command as well. To
+# enable Shibboleth but not specify any session/access requirements
+# use "require shibboleth".
+#
+<Location /secure>
+  AuthType shibboleth
+  ShibRequestSetting requireSession 1
+  require valid-user
+</Location>
index be7693c..04487cc 100644 (file)
@@ -669,7 +669,7 @@ if test "$WANT_APACHE_20" = "yes" ; then
     AC_ARG_WITH(apxs2, 
         AS_HELP_STRING([--with-apxs2=FILE],[Specifies where to find the Apache 2.0 apxs script.]),
         [
-        AC_MSG_CHECKING(for user-specified Apache2 apxs name/location)
+        AC_MSG_CHECKING(for user-specified Apache 2.0 apxs name/location)
         if test "$withval" != "no" ; then
           if test "$withval" != "yes"; then
             APXS2=$withval
@@ -698,10 +698,10 @@ if test "$WANT_APACHE_20" = "yes" ; then
         fi
         ])
 
-    AC_MSG_CHECKING([to see if Apache2 apxs was located])
+    AC_MSG_CHECKING([to see if Apache 2.0 apxs was located])
     if test ! -f "$APXS2" ; then
         AC_MSG_RESULT(no)
-        AC_MSG_ERROR([Unable to locate Apache2 apxs script. An Apache development package may be missing from your server, or you may need to use the --with-apxs2 option.])
+        AC_MSG_ERROR([Unable to locate Apache 2.0 apxs script. An Apache development package may be missing from your server, or you may need to use the --with-apxs2 option.])
     fi
     AC_MSG_RESULT($APXS2)
     AC_SUBST(APXS2)
@@ -782,7 +782,7 @@ if test "$WANT_APACHE_22" = "yes" ; then
     AC_ARG_WITH(apxs22, 
         AS_HELP_STRING([--with-apxs22=FILE],[Specifies where to find the Apache 2.2 apxs script.]),
         [
-        AC_MSG_CHECKING(for user-specified Apache2.2 apxs name/location)
+        AC_MSG_CHECKING(for user-specified Apache 2.2 apxs name/location)
         if test "$withval" != "no" ; then
           if test "$withval" != "yes"; then
             APXS22=$withval
@@ -811,10 +811,10 @@ if test "$WANT_APACHE_22" = "yes" ; then
         fi
         ])
 
-    AC_MSG_CHECKING([to see if Apache2.2 apxs was located])
+    AC_MSG_CHECKING([to see if Apache 2.2 apxs was located])
     if test ! -f "$APXS22" ; then
         AC_MSG_RESULT(no)
-        AC_MSG_ERROR([Unable to locate Apache2.2 apxs script. An Apache development package may be missing from your server, or you may need to use the --with-apxs22 option.])
+        AC_MSG_ERROR([Unable to locate Apache 2.2 apxs script. An Apache development package may be missing from your server, or you may need to use the --with-apxs22 option.])
     fi
     AC_MSG_RESULT($APXS22)
     AC_SUBST(APXS22)
@@ -870,14 +870,85 @@ fi
 AC_SUBST(APXS22_CFLAGS)
 AC_SUBST(APXS22_INCLUDE)
 
+# Apache 2.4 (mod_shib_24)
+#   --enable-apache-24
+#   --with-apxs24     (DSO build, the normal way, uses apxs to derive build flags)
+#      --with-apr1       (DSO build, APR development package installed separately)
+#   --with-apu1       (DSO build, APR-UTIL development package installed separately)
+
+AC_ARG_ENABLE(apache-24,
+       AS_HELP_STRING([--enable-apache-24],[enable the Apache 2.4 module]),
+       [if test "x$enableval" = "x" ; then
+         WANT_APACHE_24=yes
+        else
+            WANT_APACHE_24="$enableval"
+        fi
+       ],[ WANT_APACHE_24=no ])
+AC_MSG_CHECKING(whether to build Apache 2.4 module)
+if test "$WANT_APACHE_24" != yes && test "$WANT_APACHE_24" != no ; then
+    WANT_APACHE_24=yes
+fi
+AC_MSG_RESULT($WANT_APACHE_24)
+
+if test "$WANT_APACHE_24" = "yes" ; then
+    AC_ARG_WITH(apxs24, 
+        AS_HELP_STRING([--with-apxs24=FILE],[Specifies where to find the Apache 2.4 apxs script.]),
+        [
+        AC_MSG_CHECKING(for user-specified Apache 2.4 apxs name/location)
+        if test "$withval" != "no" ; then
+          if test "$withval" != "yes"; then
+            APXS24=$withval
+            AC_MSG_RESULT("$withval")
+          fi
+        fi
+        ],
+        [
+        AC_PATH_PROG(APXS24, apxs2, no)
+        if test "$APXS24" = "no" ; then
+            AC_PATH_PROG(APXS24, apxs, no)
+        fi
+        if test "$APXS24" = "no" ; then
+          for i in /usr/sbin /usr/local/apache2/bin /usr/local/apache/bin ; do
+            if test "$APXS24" = "no" && test -f "$i/apxs2" ; then
+              APXS24="$i/apxs2"
+            fi
+          done
+          if test "$APXS24" = "no" ; then
+            for i in /usr/sbin /usr/local/apache2/bin /usr/local/apache/bin ; do
+              if test "$APXS24" = "no" && test -f "$i/apxs" ; then
+                APXS24="$i/apxs"
+              fi
+            done
+          fi
+        fi
+        ])
+
+    AC_MSG_CHECKING([to see if Apache 2.4 apxs was located])
+    if test ! -f "$APXS24" ; then
+        AC_MSG_RESULT(no)
+        AC_MSG_ERROR([Unable to locate Apache 2.4 apxs script. An Apache development package may be missing from your server, or you may need to use the --with-apxs24 option.])
+    fi
+    AC_MSG_RESULT($APXS24)
+    AC_SUBST(APXS24)
+
+    # extract settings we need from APXS24 -q
+    APXS24_CC="`$APXS24 -q CC`"
+    APXS24_CFLAGS="`$APXS24 -q CPPFLAGS` `$APXS24 -q CFLAGS` $APR1_CFLAGS $APU1_CFLAGS"
+    APXS24_INCLUDE="`$APXS24 -q INCLUDEDIR`"
+fi
+
+AC_SUBST(APXS24_CFLAGS)
+AC_SUBST(APXS24_INCLUDE)
+
 # always output the Makefile, even if you don't use it
 AC_CONFIG_FILES([apache/Makefile])
 AM_CONDITIONAL(BUILD_AP13,test "$WANT_APACHE_13" = "yes")
 AM_CONDITIONAL(BUILD_AP20,test "$WANT_APACHE_20" = "yes")
 AM_CONDITIONAL(BUILD_AP22,test "$WANT_APACHE_22" = "yes")
+AM_CONDITIONAL(BUILD_AP24,test "$WANT_APACHE_24" = "yes")
 
 # add the apache module to the list of wanted subdirs..
-if test "$WANT_APACHE_13" = "yes" || test "$WANT_APACHE_20" = "yes" || test "$WANT_APACHE_22" = "yes" ; then
+if test "$WANT_APACHE_13" = "yes" || test "$WANT_APACHE_20" = "yes" || test "$WANT_APACHE_22" = "yes" || test "$WANT_APACHE_24" = "yes" ; then
     WANT_SUBDIRS="$WANT_SUBDIRS apache"
 fi
 
@@ -1185,6 +1256,18 @@ if test -n "$APXS22_CC" && test "$APXS22_CC" != "$CC" ; then
   echo "=================================================================="
 fi
 
+if test -n "$APXS24_CC" && test "$APXS24_CC" != "$CC" ; then
+  echo "=================================================================="
+  echo "WARNING: You have chosen to compile Apache-2.4 modules with a different"
+  echo "         compiler than the one used to compile Apache."
+  echo ""
+  echo "    Current compiler:      $CC"
+  echo "   Apache's compiler:      $APXS24_CC"
+  echo ""
+  echo "This could cause problems."
+  echo "=================================================================="
+fi
+
 LIBTOOL="$LIBTOOL --silent"
 
 AC_OUTPUT
index d513892..1e793ac 100644 (file)
@@ -113,6 +113,9 @@ fi
 if [ -f $RPM_BUILD_ROOT%{_libdir}/%{name}/mod_shib_22.so ] ; then
        APACHE_CONFIG="apache22.config"
 fi
+if [ -f $RPM_BUILD_ROOT%{_libdir}/%{name}/mod_shib_24.so ] ; then
+       APACHE_CONFIG="apache24.config"
+fi
 %{?_without_builtinapache:APACHE_CONFIG="no"}
 if [ "$APACHE_CONFIG" != "no" ] ; then
        APACHE_CONFD="no"
@@ -342,6 +345,7 @@ fi
 - Add boost-devel dependency
 - Build memcache plugin on RH6
 - Add cachedir to install
+- Add Apache 2.4 to install
 
 * Sun Jun 26 2011  Scott Cantor  <cantor.2@osu.edu>  - 2.4.3-1
 - Log files shouldn't be world readable.