mirror of
https://github.com/curl/curl.git
synced 2026-08-25 10:53:37 +03:00
spnego_sspi: honor CURLOPT_GSSAPI_DELEGATION for Windows SSPI
Make CURLOPT_GSSAPI_DELEGATION effective on Windows builds that use SSPI (instead of a native GSS-API implementation), so Kerberos delegation can be requested during SPNEGO/Negotiate authentication. Closes #21528
This commit is contained in:
parent
2256162fa7
commit
cc6777d939
7 changed files with 128 additions and 15 deletions
89
tests/unit/unit3302.c
Normal file
89
tests/unit/unit3302.c
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "unitcheck.h"
|
||||
#include "urldata.h"
|
||||
|
||||
static CURLcode test_unit3302(const char *arg)
|
||||
{
|
||||
UNITTEST_BEGIN_SIMPLE
|
||||
|
||||
#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
|
||||
struct Curl_easy *easy;
|
||||
CURLcode result;
|
||||
|
||||
curl_global_init(CURL_GLOBAL_ALL);
|
||||
easy = curl_easy_init();
|
||||
if(!easy) {
|
||||
curl_global_cleanup();
|
||||
goto unit_test_abort; /* OOM during setup, not a test failure */
|
||||
}
|
||||
|
||||
/* CURLGSSAPI_DELEGATION_FLAG must be stored */
|
||||
result = curl_easy_setopt(easy, CURLOPT_GSSAPI_DELEGATION,
|
||||
CURLGSSAPI_DELEGATION_FLAG);
|
||||
fail_unless(result == CURLE_OK,
|
||||
"setopt DELEGATION_FLAG returned error");
|
||||
fail_unless(easy->set.gssapi_delegation == CURLGSSAPI_DELEGATION_FLAG,
|
||||
"DELEGATION_FLAG not stored in data->set");
|
||||
|
||||
/* CURLGSSAPI_DELEGATION_POLICY_FLAG must be stored */
|
||||
result = curl_easy_setopt(easy, CURLOPT_GSSAPI_DELEGATION,
|
||||
CURLGSSAPI_DELEGATION_POLICY_FLAG);
|
||||
fail_unless(result == CURLE_OK,
|
||||
"setopt DELEGATION_POLICY_FLAG returned error");
|
||||
fail_unless(easy->set.gssapi_delegation == CURLGSSAPI_DELEGATION_POLICY_FLAG,
|
||||
"DELEGATION_POLICY_FLAG not stored in data->set");
|
||||
|
||||
/* both flags together */
|
||||
result = curl_easy_setopt(easy, CURLOPT_GSSAPI_DELEGATION,
|
||||
CURLGSSAPI_DELEGATION_FLAG |
|
||||
CURLGSSAPI_DELEGATION_POLICY_FLAG);
|
||||
fail_unless(result == CURLE_OK,
|
||||
"setopt both flags returned error");
|
||||
fail_unless(easy->set.gssapi_delegation ==
|
||||
(CURLGSSAPI_DELEGATION_FLAG | CURLGSSAPI_DELEGATION_POLICY_FLAG),
|
||||
"both delegation flags not stored in data->set");
|
||||
|
||||
/* CURLGSSAPI_DELEGATION_NONE must clear the field */
|
||||
result = curl_easy_setopt(easy, CURLOPT_GSSAPI_DELEGATION,
|
||||
CURLGSSAPI_DELEGATION_NONE);
|
||||
fail_unless(result == CURLE_OK,
|
||||
"setopt DELEGATION_NONE returned error");
|
||||
fail_unless(easy->set.gssapi_delegation == 0,
|
||||
"gssapi_delegation not cleared by DELEGATION_NONE");
|
||||
|
||||
/* unknown bits must be masked off */
|
||||
result = curl_easy_setopt(easy, CURLOPT_GSSAPI_DELEGATION, 0xFFL);
|
||||
fail_unless(result == CURLE_OK,
|
||||
"setopt 0xFF returned error");
|
||||
fail_unless(easy->set.gssapi_delegation ==
|
||||
(CURLGSSAPI_DELEGATION_FLAG | CURLGSSAPI_DELEGATION_POLICY_FLAG),
|
||||
"unknown bits not masked off");
|
||||
|
||||
curl_easy_cleanup(easy);
|
||||
curl_global_cleanup();
|
||||
#endif /* HAVE_GSSAPI || USE_WINDOWS_SSPI */
|
||||
|
||||
UNITTEST_END_SIMPLE
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue