const char *user_ccache = NULL;
const char *orig_ccache = NULL;
#endif
+ uint32_t init_flags = 0;
type = ap_auth_type(req);
if ((type == NULL) || (strcasecmp(type, "GSSAPI") != 0)) {
"failed", maj, min));
goto done;
}
+
+ if (cfg->deleg_ccache_dir) {
+ /* delegate ourselves credentials so we store them as requested */
+ init_flags |= GSS_C_DELEG_FLAG;
+ }
+
/* output and input are inverted here, this is intentional */
maj = gss_init_sec_context(&min, user_cred, &user_ctx, server,
- GSS_C_NO_OID, 0, 300,
+ GSS_C_NO_OID, init_flags, 300,
GSS_C_NO_CHANNEL_BINDINGS, &output,
NULL, &input, NULL, NULL);
if (GSS_ERROR(maj)) {
gss_release_buffer(&min, &input);
/* output and input are inverted here, this is intentional */
maj = gss_init_sec_context(&min, user_cred, &user_ctx, server,
- GSS_C_NO_OID, 0, 300,
+ GSS_C_NO_OID, init_flags, 300,
GSS_C_NO_CHANNEL_BINDINGS, &output,
NULL, &input, NULL, NULL);
if (GSS_ERROR(maj)) {
ret = OK;
done:
- if (ret == HTTP_UNAUTHORIZED) {
- if (output.length != 0) {
- replen = apr_base64_encode_len(output.length) + 1;
- reply = apr_pcalloc(req->pool, 10 + replen);
- if (reply) {
- memcpy(reply, "Negotiate ", 10);
- apr_base64_encode(&reply[10], output.value, output.length);
- apr_table_add(req->err_headers_out,
- "WWW-Authenticate", reply);
- }
- } else {
+ if ((!is_basic) && (output.length != 0)) {
+ replen = apr_base64_encode_len(output.length) + 1;
+ reply = apr_pcalloc(req->pool, 10 + replen);
+ if (reply) {
+ memcpy(reply, "Negotiate ", 10);
+ apr_base64_encode(&reply[10], output.value, output.length);
apr_table_add(req->err_headers_out,
- "WWW-Authenticate", "Negotiate");
- if (cfg->use_basic_auth) {
- apr_table_add(req->err_headers_out,
- "WWW-Authenticate",
- apr_psprintf(req->pool, "Basic realm=\"%s\"",
- ap_auth_name(req)));
- }
+ "WWW-Authenticate", reply);
+ }
+ } else if (ret == HTTP_UNAUTHORIZED) {
+ apr_table_add(req->err_headers_out,
+ "WWW-Authenticate", "Negotiate");
+ if (cfg->use_basic_auth) {
+ apr_table_add(req->err_headers_out,
+ "WWW-Authenticate",
+ apr_psprintf(req->pool, "Basic realm=\"%s\"",
+ ap_auth_name(req)));
}
}
#ifdef HAVE_GSS_KRB5_CCACHE_NAME