https://issues.shibboleth.net/jira/browse/SSPCPP-193
authorScott Cantor <cantor.2@osu.edu>
Wed, 20 May 2009 19:37:19 +0000 (19:37 +0000)
committerScott Cantor <cantor.2@osu.edu>
Wed, 20 May 2009 19:37:19 +0000 (19:37 +0000)
apache/mod_apache.cpp
apache/mod_shib_13.cpp
apache/mod_shib_20.cpp
apache/mod_shib_22.cpp
fastcgi/shibauthorizer.cpp
nsapi_shib/nsapi_shib.cpp
shibsp/SPRequest.h
shibsp/ServiceProvider.cpp

index a82c9d0..0e65d60 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright 2001-2007 Internet2
+ *  Copyright 2001-2009 Internet2
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -513,6 +513,14 @@ public:
   string getRemoteUser() const {
     return string(SH_AP_USER(m_req) ? SH_AP_USER(m_req) : "");
   }
+  void setAuthType(const char* authtype) {
+      if (authtype && m_dc->bBasicHijack == 1)
+          authtype = "Basic";
+      SH_AP_AUTH_TYPE(m_req) = authtype ? ap_pstrdup(m_req->pool, authtype) : NULL;
+  }
+  string getAuthType() const {
+    return string(SH_AP_AUTH_TYPE(m_req) ? SH_AP_AUTH_TYPE(m_req) : "");
+  }
   void setContentType(const char* type) {
       m_req->content_type = ap_psprintf(m_req->pool, type);
   }
index d3c7a00..0497568 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright 2001-2007 Internet2
+ *  Copyright 2001-2009 Internet2
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -28,6 +28,7 @@
 #define SH_AP_CONFIGFILE configfile_t
 #define SH_AP_R(r) r
 #define SH_AP_USER(r) r->connection->user
+#define SH_AP_AUTH_TYPE(r) r->connection->ap_auth_type
 
 #ifdef WIN32
 # define _USE_32BIT_TIME_T
index 065b24e..c4260c1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright 2001-2007 Internet2
+ *  Copyright 2001-2009 Internet2
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -31,6 +31,7 @@
 
 #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
index 5cab9e4..fbaf17d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright 2001-2007 Internet2
+ *  Copyright 2001-2009 Internet2
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -31,6 +31,7 @@
 
 #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
index 6a8051a..59f4417 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- *  Copyright 2001-2007 Internet2\r
+ *  Copyright 2001-2009 Internet2\r
  *\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
@@ -175,6 +175,23 @@ public:
         }\r
         return "";\r
     }\r
+    void setAuthType(const char* authtype) {\r
+        if (authtype)\r
+            m_request_headers["AUTH_TYPE"] = authtype;\r
+        else\r
+            m_request_headers.erase("AUTH_TYPE");\r
+    }\r
+    string getAuthType() const {\r
+        map<string,string>::const_iterator i = m_request_headers.find("AUTH_TYPE");\r
+        if (i != m_request_headers.end())\r
+            return i->second;\r
+        else {\r
+            char* auth_type = FCGX_GetParam("AUTH_TYPE", m_req->envp);\r
+            if (auth_type)\r
+                return auth_type;\r
+        }\r
+        return "";\r
+    }\r
     void setResponseHeader(const char* name, const char* value) {\r
         // Set for later.\r
         if (value)\r
index 59f1a24..6cc2710 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright 2001-2007 Internet2
+ *  Copyright 2001-2009 Internet2
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -373,6 +373,15 @@ public:
     const char* ru = pblock_findval("auth-user", m_rq->vars);
     return ru ? ru : "";
   }
+  void setAuthType(const char* authtype) {
+    param_free(pblock_remove("auth-type", m_rq->vars));
+    if (authtype)
+        pblock_nvinsert("auth-type", authtype, m_rq->vars);
+  }
+  string getAuthType() const {
+    const char* at = pblock_findval("auth-type", m_rq->vars);
+    return at ? at : "";
+  }
   void setContentType(const char* type) {
       // iPlanet seems to have a case folding problem.
       param_free(pblock_remove("content-type", m_rq->srvhdrs));
@@ -451,10 +460,6 @@ extern "C" NSAPI_PUBLIC int nsapi_shib(pblock* pb, ::Session* sn, Request* rq)
     // user authN was okay -- export the assertions now
     param_free(pblock_remove("auth-user",rq->vars));
 
-    // This seems to be required in order to eventually set
-    // the auth-user var.
-    pblock_nvinsert("auth-type","shibboleth",rq->vars);
-
     res = stn.getServiceProvider().doExport(stn);
     if (res.first) return (int)res.second;
 
index cf2b7ed..255e8b5 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Copyright 2001-2007 Internet2
- * 
+ *
  * Licensed 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
@@ -16,8 +16,8 @@
 
 /**
  * @file shibsp/SPRequest.h
- * 
- * Interface to server request being processed  
+ *
+ * Interface to server request being processed
  */
 
 #ifndef __shibsp_req_h__
 #include <xmltooling/io/HTTPResponse.h>
 
 namespace shibsp {
-    
+
     class SHIBSP_API Application;
     class SHIBSP_API ServiceProvider;
     class SHIBSP_API Session;
-    
+
     /**
      * Interface to server request being processed
-     * 
+     *
      * <p>To supply information from the surrounding web server environment,
      * a shim must be supplied in the form of this interface to adapt the
      * library to different proprietary server APIs.
-     * 
+     *
      * <p>This interface need not be threadsafe.
      */
     class SHIBSP_API SPRequest : public virtual xmltooling::HTTPRequest, public virtual xmltooling::HTTPResponse
@@ -48,10 +48,10 @@ namespace shibsp {
         SPRequest() {}
     public:
         virtual ~SPRequest() {}
-        
+
         /**
          * Returns the locked ServiceProvider processing the request.
-         * 
+         *
          * @return reference to ServiceProvider
          */
         virtual const ServiceProvider& getServiceProvider() const=0;
@@ -59,14 +59,14 @@ namespace shibsp {
         /**
          * Returns RequestMapper Settings associated with the request, guaranteed
          * to be valid for the request's duration.
-         * 
+         *
          * @return copy of settings
          */
         virtual RequestMapper::Settings getRequestSettings() const=0;
-        
+
         /**
          * Returns the Application governing the request.
-         * 
+         *
          * @return reference to Application
          */
         virtual const Application& getApplication() const=0;
@@ -84,7 +84,7 @@ namespace shibsp {
         /**
          * Returns the effective base Handler URL for a resource,
          * or the current request URL.
-         * 
+         *
          * @param resource  resource URL to compute handler for
          * @return  base location of handler
          */
@@ -94,7 +94,7 @@ namespace shibsp {
          * Returns a non-spoofable request header value, if possible.
          * Platforms that support environment export can redirect header
          * lookups by overriding this method.
-         * 
+         *
          * @param name  the name of the secure header to return
          * @return the header's value, or an empty string
          */
@@ -104,7 +104,7 @@ namespace shibsp {
 
         /**
          * Ensures no value exists for a request header.
-         * 
+         *
          * @param rawname  raw name of header to clear
          * @param cginame  CGI-equivalent name of header
          */
@@ -112,7 +112,7 @@ namespace shibsp {
 
         /**
          * Sets a value for a request header.
-         * 
+         *
          * @param name  name of header to set
          * @param value value to set
          */
@@ -120,11 +120,19 @@ namespace shibsp {
 
         /**
          * Establish REMOTE_USER identity in request.
-         * 
+         *
          * @param user  REMOTE_USER value to set or NULL to clear
          */
         virtual void setRemoteUser(const char* user)=0;
-        
+
+        /**
+         * Establish AUTH_TYPE for request.
+         *
+         * @param authtype  AUTH_TYPE value to set or NULL to clear
+         */
+        virtual void setAuthType(const char* authtype) {
+        }
+
         /** Portable logging levels. */
         enum SPLogLevel {
           SPDebug,
@@ -136,7 +144,7 @@ namespace shibsp {
 
         /**
          * Log to native server environment.
-         * 
+         *
          * @param level logging level
          * @param msg   message to log
          */
@@ -144,7 +152,7 @@ namespace shibsp {
 
         /**
          * Test logging level.
-         * 
+         *
          * @param level logging level
          * @return true iff logging level is enabled
          */
@@ -152,16 +160,16 @@ namespace shibsp {
 
         /**
          * Indicates that processing was declined, meaning no action is required during this phase of processing.
-         * 
+         *
          * @return  a status code to pass back to the server-specific layer
-         */        
+         */
         virtual long returnDecline()=0;
 
         /**
          * Indicates that processing was completed.
-         * 
+         *
          * @return  a status code to pass back to the server-specific layer
-         */        
+         */
         virtual long returnOK()=0;
     };
 };
index e723808..69afa28 100644 (file)
@@ -245,6 +245,8 @@ pair<bool,long> ServiceProvider::doAuthentication(SPRequest& request, bool handl
             return initiator->run(request,false);
         }
 
+        request.setAuthType("shibboleth");
+
         // We're done.  Everything is okay.  Nothing to report.  Nothing to do..
         // Let the caller decide how to proceed.
         log.debug("doAuthentication succeeded");