Merge branch 'moonshot-negotiate' of file:///srv/git/mod_auth_kerb
authorSam Hartman <hartmans@painless-security.com>
Mon, 3 Feb 2014 10:08:56 +0000 (05:08 -0500)
committerSam Hartman <hartmans@painless-security.com>
Mon, 3 Feb 2014 10:08:56 +0000 (05:08 -0500)
LICENSE
apxs.sh
client/Makefile
client/http_client.c
config.h.in
gss.c
mod_auth_gssapi.c
mod_auth_gssapi.h

diff --git a/LICENSE b/LICENSE
index 8c3ba52..1b8bb7e 100644 (file)
--- a/LICENSE
+++ b/LICENSE
@@ -1,11 +1,40 @@
 mod_auth_gssapi license
----------------------
-XXXX
+-----------------------
+/*
+ * Copyright (c) 2010 CESNET
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of CESNET nor the names of its contributors may
+ *    be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
 
 
-This package also contains parts (see the spnego subdirectory) based on the
-Heimdal source code (http://www.pdc.kth.se/heimdal/) released under
-following license statement:
+This package also contains parts (see the spnego and client subdirectories)
+based on the Heimdal source code (http://www.pdc.kth.se/heimdal/) released
+under the following license: 
 
 /*
  * Copyright (c) 1997-2001 Kungliga Tekniska Högskolan
diff --git a/apxs.sh b/apxs.sh
index db8c74b..f4723f6 100755 (executable)
--- a/apxs.sh
+++ b/apxs.sh
@@ -1,7 +1,34 @@
 #!/bin/sh
 #
-# XXX cleanup desperately needed
-#
+# Copyright (c) 2010 CESNET
+#  All rights reserved.
+# 
+#  Redistribution and use in source and binary forms, with or without
+#  modification, are permitted provided that the following conditions are met:
+# 
+#  1. Redistributions of source code must retain the above copyright notice,
+#     this list of conditions and the following disclaimer.
+# 
+#  2. Redistributions in binary form must reproduce the above copyright
+#     notice, this list of conditions and the following disclaimer in the
+#     documentation and/or other materials provided with the distribution.
+# 
+#  3. Neither the name of CESNET nor the names of its contributors may
+#     be used to endorse or promote products derived from this software
+#     without specific prior written permission.
+# 
+#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+#  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+#  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+#  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+#  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+#  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+#  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+#  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+#  POSSIBILITY OF SUCH DAMAGE.
+
 cppflags=`[ -n "$1" ] && echo $1 | sed -e 's/\([^ ]\+\)/-Wc,\1/g'`
 ldflags=`[ -n "$2"  ] && echo $2 | sed -e 's/\([^ ]\+\)/-Wl,\1/g'`
 ret=eval $4 $cppflags $ldflags $3
index 0fe6f2a..2aecc5d 100644 (file)
@@ -1,7 +1,7 @@
 DEFS = -DHAVE_SYS_TYPES_H -DHAVE_UNISTD_H -DHAVE_SYS_SOCKET_H -DHAVE_NETINET_IN_H -DHAVE_NETDB_H -DHAVE_SYS_PARAM_H \
        -D_GNU_SOURCE
 CPPFLAGS = $(DEFS) -Wall -O0 -g
-LDFLAGS = -lgssapi_krb5
+LDFLAGS = -L/usr/local/lib -lgssapi_krb5
 
 HTTP_OBJS = http_client.o gss_common.o base64.o net_write.o net_read.o
 
index 0ace960..3045b12 100644 (file)
@@ -335,7 +335,7 @@ do_http(const char *host, const char *page, gss_OID mech_oid, gss_cred_id_t cred
            if (h == NULL)
                errx(1, "Got %s but missed `WWW-Authenticate'", req.response);
 
-           if (strncasecmp(h, "GSSAPI", 6) == 0) {
+           if (strncasecmp(h, "Negotiate", 9) == 0) {
                OM_uint32 maj_stat, min_stat;
                gss_buffer_desc input_token, output_token;
 
@@ -361,8 +361,7 @@ do_http(const char *host, const char *page, gss_OID mech_oid, gss_cred_id_t cred
                }
 #endif
 
-//             i = 9;
-               i = 6;
+               i = 9;
                while(h[i] && isspace((unsigned char)h[i]))
                    i++;
                if (h[i] != '\0') {
@@ -457,7 +456,7 @@ do_http(const char *host, const char *page, gss_OID mech_oid, gss_cred_id_t cred
                                  output_token.length,
                                  &neg_token);
                    
-                   asprintf(&headers[0], "Authorization: GSSAPI %s",
+                   asprintf(&headers[0], "Authorization: Negotiate %s",
                             neg_token);
                    num_headers = 1;
                    free(neg_token);
@@ -563,6 +562,18 @@ main(int argc, char *argv[])
                        &cred, NULL, NULL);
        if (GSS_ERROR(maj_stat))
            gss_err(1, maj_stat, min_stat, "Failed to load initial credentials");
+    } else {
+       gss_OID_set_desc mechs, *mechsp = GSS_C_NO_OID_SET;
+
+       mechs.elements = mech_oid;
+       mechs.count = 1;
+       mechsp = &mechs;
+       maj_stat = gss_acquire_cred(&min_stat,
+                       gss_username, 0,
+                       mechsp, GSS_C_INITIATE,
+                       &cred, NULL, NULL);
+       if (GSS_ERROR(maj_stat))
+           gss_err(1, maj_stat, min_stat, "Failed to load initial credentials");
     }
 
     ret = do_http(host, page, mech_oid, cred);
index def453e..336664e 100644 (file)
@@ -1,15 +1,73 @@
-/* Define to the version of this package. */
-/* Conflicts with defintions from Apache */
-/* #undef PACKAGE_VERSION */
-
-/* Define to `unsigned' if <sys/types.h> does not define. */
-#undef size_t
+/* config.h.in.  Generated from configure.in by autoheader.  */
 
-/* Define if your GSSAPI library supports handling SPNEGO tokens */
+/* GSS-API implementation has its own SPNEGO */
 #undef GSSAPI_SUPPORTS_SPNEGO
 
-/* Define to 1 if you have the <unistd.h> header file. */
-#undef HAVE_UNISTD_H
+/* Define to 1 if you have the <gssapi/gssapi.h> header file. */
+#undef HAVE_GSSAPI_GSSAPI_H
+
+/* Define to 1 if you have the <gssapi.h> header file. */
+#undef HAVE_GSSAPI_H
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#undef HAVE_INTTYPES_H
+
+/* Define to 1 if you have the <limits.h> header file. */
+#undef HAVE_LIMITS_H
+
+/* Define to 1 if you have the <memory.h> header file. */
+#undef HAVE_MEMORY_H
+
+/* Define to 1 if you have the <netdb.h> header file. */
+#undef HAVE_NETDB_H
+
+/* Define to 1 if you have the <stddef.h> header file. */
+#undef HAVE_STDDEF_H
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#undef HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#undef HAVE_STDLIB_H
+
+/* Define to 1 if you have the <strings.h> header file. */
+#undef HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#undef HAVE_STRING_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#undef HAVE_SYS_STAT_H
 
 /* Define to 1 if you have the <sys/types.h> header file. */
 #undef HAVE_SYS_TYPES_H
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the home page for this package. */
+#undef PACKAGE_URL
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
+/* Define to 1 if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
+/* Define to 1 if your <sys/time.h> declares `struct tm'. */
+#undef TM_IN_SYS_TIME
+
+/* Define to `unsigned int' if <sys/types.h> does not define. */
+#undef size_t
diff --git a/gss.c b/gss.c
index 836df6f..07d485d 100644 (file)
--- a/gss.c
+++ b/gss.c
@@ -1,3 +1,34 @@
+/*
+ * Copyright (c) 2010 CESNET
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of CESNET nor the names of its contributors may
+ *    be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
 #include "mod_auth_gssapi.h"
 
 static const char *
index fb14416..32c0f01 100644 (file)
@@ -1,3 +1,34 @@
+/*
+ * Copyright (c) 2010 CESNET
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of CESNET nor the names of its contributors may
+ *    be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
 #include "mod_auth_gssapi.h"
 
 module AP_MODULE_DECLARE_DATA auth_gssapi_module;
@@ -51,8 +82,8 @@ set_http_headers(request_rec *r, const gss_auth_config *conf,
     if (negotiate_ret_value == NULL)
        return;
 
-    negoauth_param = (*negotiate_ret_value == '\0') ? "GSSAPI" :
-        apr_pstrcat(r->pool, "GSSAPI ", negotiate_ret_value, NULL);
+    negoauth_param = (*negotiate_ret_value == '\0') ? "Negotiate" :
+        apr_pstrcat(r->pool, "Negotiate ", negotiate_ret_value, NULL);
     apr_table_add(r->err_headers_out, header_name, negoauth_param);
 }
 
@@ -106,7 +137,7 @@ gss_authenticate_user(request_rec *r)
    
     /* get the type specified in Apache configuration */
     type = ap_auth_type(r);
-    if (type == NULL || strcmp(type, "GSSAPI") != 0) {
+    if (type == NULL || strcmp(type, "Negotiate") != 0) {
         gss_log(APLOG_MARK, APLOG_DEBUG, 0, r,
                "AuthType '%s' is not for us, bailing out",
                (type) ? type : "(NULL)");
@@ -126,7 +157,7 @@ gss_authenticate_user(request_rec *r)
     }
 
     auth_type = ap_getword_white(r->pool, &auth_line);
-    if (strcasecmp(auth_type, "GSSAPI") != 0) {
+    if (strcasecmp(auth_type, "Negotiate") != 0) {
         gss_log(APLOG_MARK, APLOG_DEBUG, 0, r,
                "Unsupported authentication type (%s) requested by client",
                (auth_type) ? auth_type : "(NULL)");
@@ -144,14 +175,14 @@ gss_authenticate_user(request_rec *r)
     /* optimizing hack */
     if (conn_ctx->state == GSS_CTX_ESTABLISHED && auth_line == NULL) {
        r->user = apr_pstrdup(r->pool, conn_ctx->user);
-       r->ap_auth_type = "GSSAPI";
+       r->ap_auth_type = "Negotiate";
        return OK;
     }
 
     /* XXXX subrequests ignored, only successful accesses taken into account! */
     if (!ap_is_initial_req(r) && conn_ctx->state == GSS_CTX_ESTABLISHED) {
        r->user = apr_pstrdup(r->pool, conn_ctx->user);
-       r->ap_auth_type = "GSSAPI";
+       r->ap_auth_type = "Negotiate";
        return OK;
     }
 
@@ -164,7 +195,7 @@ gss_authenticate_user(request_rec *r)
 
     if (ret == OK) {
        r->user = apr_pstrdup(r->pool, conn_ctx->user);
-       r->ap_auth_type = "GSSAPI";
+       r->ap_auth_type = "Negotiate";
     }
 
     /* debug LOG ??? */
index a8f8a8d..462afba 100644 (file)
@@ -1,3 +1,34 @@
+/*
+ * Copyright (c) 2010 CESNET
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of CESNET nor the names of its contributors may
+ *    be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
 #ifndef __MOD_AUTH_GSSAPI_H__
 #define __MOD_AUTH_GSSAPI_H__