#317 Dispose WindowsIdentity

This commit is contained in:
Chris R 2017-03-22 14:08:50 -07:00
parent c328e22699
commit 32bc9a57c9
2 changed files with 9 additions and 2 deletions

View File

@ -224,8 +224,14 @@ namespace Microsoft.AspNetCore.Server.HttpSys
&& info->InfoType == HttpApi.HTTP_REQUEST_INFO_TYPE.HttpRequestInfoTypeAuth && info->InfoType == HttpApi.HTTP_REQUEST_INFO_TYPE.HttpRequestInfoTypeAuth
&& info->pInfo->AuthStatus == HttpApi.HTTP_AUTH_STATUS.HttpAuthStatusSuccess) && info->pInfo->AuthStatus == HttpApi.HTTP_AUTH_STATUS.HttpAuthStatusSuccess)
{ {
return new WindowsPrincipal(new WindowsIdentity(info->pInfo->AccessToken, // Duplicates AccessToken
GetAuthTypeFromRequest(info->pInfo->AuthType).ToString())); var identity = new WindowsIdentity(info->pInfo->AccessToken,
GetAuthTypeFromRequest(info->pInfo->AuthType).ToString());
// Close the original
UnsafeNclNativeMethods.SafeNetHandles.CloseHandle(info->pInfo->AccessToken);
return new WindowsPrincipal(identity);
} }
} }

View File

@ -302,6 +302,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
// TODO: Verbose log // TODO: Verbose log
_isDisposed = true; _isDisposed = true;
_nativeRequestContext.Dispose(); _nativeRequestContext.Dispose();
(User?.Identity as WindowsIdentity)?.Dispose();
if (_nativeStream != null) if (_nativeStream != null)
{ {
_nativeStream.Dispose(); _nativeStream.Dispose();