This repository was archived by the owner on Mar 19, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed
src/Microsoft.Net.Http.Server/RequestProcessing Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -224,8 +224,14 @@ internal ClaimsPrincipal GetUser()
224224 && info ->InfoType == HttpApi . HTTP_REQUEST_INFO_TYPE . HttpRequestInfoTypeAuth
225225 && info ->pInfo ->AuthStatus == HttpApi . HTTP_AUTH_STATUS . HttpAuthStatusSuccess )
226226 {
227- return new WindowsPrincipal ( new WindowsIdentity ( info ->pInfo ->AccessToken ,
228- GetAuthTypeFromRequest ( info ->pInfo ->AuthType ) . ToString ( ) ) ) ;
227+ // Duplicates AccessToken
228+ var identity = new WindowsIdentity ( info ->pInfo ->AccessToken ,
229+ GetAuthTypeFromRequest ( info ->pInfo ->AuthType ) . ToString ( ) ) ;
230+
231+ // Close the original
232+ UnsafeNclNativeMethods . SafeNetHandles . CloseHandle ( info ->pInfo ->AccessToken ) ;
233+
234+ return new WindowsPrincipal ( identity ) ;
229235 }
230236 }
231237 return new ClaimsPrincipal ( new ClaimsIdentity ( ) ) ; // Anonymous / !IsAuthenticated
Original file line number Diff line number Diff line change 77using System . Net ;
88using System . Security . Claims ;
99using System . Security . Cryptography . X509Certificates ;
10+ using System . Security . Principal ;
1011using System . Threading ;
1112using System . Threading . Tasks ;
1213
@@ -303,6 +304,7 @@ internal void Dispose()
303304 // TODO: Verbose log
304305 _isDisposed = true ;
305306 _nativeRequestContext . Dispose ( ) ;
307+ ( User ? . Identity as WindowsIdentity ) ? . Dispose ( ) ;
306308 if ( _nativeStream != null )
307309 {
308310 _nativeStream . Dispose ( ) ;
You can’t perform that action at this time.
0 commit comments