-
Notifications
You must be signed in to change notification settings - Fork 10.3k
http.sys: Allow configuring HTTP_AUTH_EX_FLAGs as options #51833
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thanks for your PR, @evgenykotkov. Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
This comment was marked as resolved.
This comment was marked as resolved.
FYI https://github.com/dotnet/aspnetcore/pull/50685/files#diff-9ef7d6eddeed6c08a6095b72475b87bc6b8b84b2b657ad07d407f9feb44f232c removes the need for pre-defined interop structs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cached in the comments is vague.
Cached for how long?
Thank you for your API proposal. I'm removing the |
I think this is the same intent as
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please have a look at the merge conflicts.
/// or Negotiate authentication. Kerberos or Negotiate authentication must be enabled. | ||
/// The default is false. | ||
/// </summary> | ||
public bool CaptureCredential { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know we're mirroring an underlying API, but it seems like this should be "CaptureCredentials".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CaptureProcessCredentials
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In 39edd84, I went with the CaptureCredentials
name for this option. Please let me know if it works for you.
internal bool ReceiveContextHandle; | ||
internal bool DisableNTLMCredentialCaching; | ||
internal ulong ExFlags; | ||
internal byte ReceiveMutualAuth; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to retain at least a comment indicating that it's boolean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to retain at least a comment indicating that it's boolean.
With 7f18f8f, this change seems to be no longer necessary for main
.
However, since c50346d seems to fix a rather significant issue with an invalid structure layout/size, is it something that should be backported to stable branches?
Please let me know if that is the case, and whether you'd want me to handle that with a separate PR or in any other convenient way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you demonstrate any negative effects from the old structure? We've not had any complaints here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you demonstrate any negative effects from the old structure? We've not had any complaints here.
In my x64 environment, the native size of the structure is:
sizeof(HTTP_SERVER_AUTHENTICATION_INFO) == 64
In the same environment, the size of the interop structure before the fix is:
Marshal.SizeOf<HttpApiTypes.HTTP_SERVER_AUTHENTICATION_INFO> == 80
In turn, this means that:
- The field layout is wrong after the
AuthSchemes
field - An invalid (larger) size is passed during the call to
HttpSetUrlGroupProperty()
Maybe 1. hasn't been causing any practical issues because the current version of the code didn't change any structure fields after the AuthSchemes
. But I would still say that 2. is quite significant just by itself: the behavior when passing an invalid size to the HttpSetUrlGroupProperty()
function seems to be unspecified, and could have easily resulted in an error or even a crash.
In my environment the call seems to succeed, so from that perspective this remains a theoretical issue, but, to be precise, there is a chance that this behavior may change in the future or may differ depending on the OS version — I haven't checked that in detail.
For reference, here is the native definition of the related typedefs and the structure itself:
typedef BYTE BOOLEAN;
typedef unsigned char UCHAR;
typedef struct _HTTP_SERVER_AUTHENTICATION_INFO
{
HTTP_PROPERTY_FLAGS Flags;
ULONG AuthSchemes;
BOOLEAN ReceiveMutualAuth;
BOOLEAN ReceiveContextHandle;
BOOLEAN DisableNTLMCredentialCaching;
UCHAR ExFlags;
HTTP_SERVER_AUTHENTICATION_DIGEST_PARAMS DigestParams;
HTTP_SERVER_AUTHENTICATION_BASIC_PARAMS BasicParams;
} HTTP_SERVER_AUTHENTICATION_INFO, *PHTTP_SERVER_AUTHENTICATION_INFO;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, we won't consider backporting it without a repro of a functional issue. For now it's enough that the issue is gone in main.
The native HTTP.sys API offers two extended authentication flags: - `HTTP_AUTH_EX_FLAG_ENABLE_KERBEROS_CREDENTIAL_CACHING` and - `HTTP_AUTH_EX_FLAG_CAPTURE_CREDENTIAL` that can be used by users to fine-tune their Windows authentication setups. For instance, the `HTTP_AUTH_EX_FLAG_ENABLE_KERBEROS_CREDENTIAL_CACHING` flag can be used to avoid having to authenticate every request and make the authentication session-based, thus reducing the overall number of requests and improving the high-latency scenarios. Enabling it can be used to achieve the same behavior as with the `authPersistNonNTLM` option in IIS. (See dotnet#13634) This commit exposes both flags as options in the authentication manager. Because setting the extended flags requires a different property type (`HttpServerExtendedAuthenticationProperty`), we take additional precaution to only use that property type if we actually have the extended flags to set, and use the original `HttpServerAuthenticationProperty` otherwise.
aeb2178
to
bf884dc
Compare
Looks like this PR hasn't been active for some time and the codebase could have been changed in the meantime. |
I think we're just waiting for an API review. |
API review asked for a rename. Otherwise, we should be good to go. |
Based on the discussion in #51990, I kept the original names and made a couple of tweaks to the docstrings. |
* http.sys: Allow configuring HTTP_AUTH_EX_FLAGs as options The native HTTP.sys API offers two extended authentication flags: - `HTTP_AUTH_EX_FLAG_ENABLE_KERBEROS_CREDENTIAL_CACHING` and - `HTTP_AUTH_EX_FLAG_CAPTURE_CREDENTIAL` that can be used by users to fine-tune their Windows authentication setups. For instance, the `HTTP_AUTH_EX_FLAG_ENABLE_KERBEROS_CREDENTIAL_CACHING` flag can be used to avoid having to authenticate every request and make the authentication session-based, thus reducing the overall number of requests and improving the high-latency scenarios. Enabling it can be used to achieve the same behavior as with the `authPersistNonNTLM` option in IIS. (See dotnet#13634) This commit exposes both flags as options in the authentication manager. Because setting the extended flags requires a different property type (`HttpServerExtendedAuthenticationProperty`), we take additional precaution to only use that property type if we actually have the extended flags to set, and use the original `HttpServerAuthenticationProperty` otherwise. * http.sys: Rename: CaptureCredential → CaptureCredentials * http.sys: Clarify description for `EnableKerberosCredentialCaching` * http.sys: Further clarify description for `EnableKerberosCredentialCaching` * http.sys: Further clarify documentation for new options Based on the discussion in dotnet#51990 * http.sys: Tweak documentation for `CaptureCredentials`
http.sys: Allow configuring HTTP_AUTH_EX_FLAGs as options
Description
The native HTTP.sys API offers two extended authentication flags:
HTTP_AUTH_EX_FLAG_ENABLE_KERBEROS_CREDENTIAL_CACHING
andHTTP_AUTH_EX_FLAG_CAPTURE_CREDENTIAL
that can be used by users to fine-tune their Windows authentication setups.
For instance, the
HTTP_AUTH_EX_FLAG_ENABLE_KERBEROS_CREDENTIAL_CACHING
flag can be used to avoid having to authenticate every request and make the authentication session-based, thus reducing the overall number of requests and improving the high-latency scenarios. Enabling it can be used to achieve the same behavior as with theauthPersistNonNTLM
option in IIS.Change details:
The groundwork change c50346d fixes an existing issue in the definition/layout of the
HTTP_SERVER_AUTHENTICATION_INFO
interop structure.The core change 7489786 exposes both flags as options in the authentication manager. Because setting the extended flags requires a different property type (
HttpServerExtendedAuthenticationProperty
), we take additional precaution to only use that property type if we actually have the extended flags to set, and use the originalHttpServerAuthenticationProperty
otherwise.Fixes #13634
API proposal: #51990