@@ -79,7 +79,7 @@ public async Task InvokeAsync(HttpContext context)
7979 {
8080 context . Response . StatusCode = authorizationResult . StatusCode ;
8181
82- string installedServicePath = _registryEditor . ReadString ( _registryUri ) ;
82+ string installedServicePath = Path . GetFullPath ( _registryEditor . ReadString ( _registryUri ) ) ;
8383
8484 string clientProcessVersionString = GetVersionFromFilePath ( authorizationResult . ClientProcessFileName ) ;
8585 string serviceProcessVersionString = GetVersionFromFilePath ( authorizationResult . ServerProcessFileName ) ;
@@ -91,17 +91,17 @@ public async Task InvokeAsync(HttpContext context)
9191 Version . TryParse ( installedServiceVersionString , out Version installedServiceVersion ) &&
9292 installedServiceVersion > serviceProcessVersion )
9393 {
94- string serviceStopDescription = $ "Client Process Path: '{ authorizationResult . ClientProcessFileName } ' Version '{ clientProcessVersionString } ') , " +
95- $ "Service Process Path: '{ authorizationResult . ServerProcessFileName } ' Version '{ serviceProcessVersionString } ') , " +
96- $ "Installed Service Path: '{ installedServicePath } ' Version '{ installedServiceVersionString } ') ";
94+ string serviceStopDescription = $ "Client Process Path: '{ authorizationResult . ClientProcessFileName } ' Version '{ clientProcessVersionString } ', " +
95+ $ "Service Process Path: '{ authorizationResult . ServerProcessFileName } ' Version '{ serviceProcessVersionString } ', " +
96+ $ "Installed Service Path: '{ installedServicePath } ' Version '{ installedServiceVersionString } '";
9797 await StopServiceAsync ( serviceStopDescription ) ;
9898 context . Response . StatusCode = StatusCodes . Status409Conflict ;
9999 }
100100
101101 _logger . Error < ProcessCommunicationErrorLog > ( $ "Sending HTTP status code { context . Response . StatusCode } to gRPC client. " +
102- $ "Client Process Path: '{ authorizationResult . ClientProcessFileName } ' Version '{ clientProcessVersionString } ') , " +
103- $ "Service Process Path: '{ authorizationResult . ServerProcessFileName } ' Version '{ serviceProcessVersionString } ') , " +
104- $ "Installed Service Path: '{ installedServicePath } ' Version '{ installedServiceVersionString } ') ") ;
102+ $ "Client Process Path: '{ authorizationResult . ClientProcessFileName } ' Version '{ clientProcessVersionString } ', " +
103+ $ "Service Process Path: '{ authorizationResult . ServerProcessFileName } ' Version '{ serviceProcessVersionString } ', " +
104+ $ "Installed Service Path: '{ installedServicePath } ' Version '{ installedServiceVersionString } '") ;
105105
106106 context . Response . Headers [ HttpConfiguration . CLIENT_PROCESS_PATH ] = authorizationResult . ClientProcessFileName ;
107107 context . Response . Headers [ HttpConfiguration . SERVICE_PROCESS_PATH ] = authorizationResult . ServerProcessFileName ;
@@ -160,23 +160,25 @@ private async Task<AuthorizationResult> AuthorizeAsync(HttpContext context)
160160 {
161161 NamedPipeServerStream namedPipe = GetNamedPipe ( context ) ;
162162
163- string clientProcessFileName = _pipeStreamProcessIdentifier . GetClientProcessFileName ( namedPipe ) ?? string . Empty ;
164- string serverProcessFileName = _pipeStreamProcessIdentifier . GetServerProcessFileName ( namedPipe ) ?? string . Empty ;
163+ string clientProcessPath = _pipeStreamProcessIdentifier . GetClientProcessFullFilePath ( namedPipe ) ?? string . Empty ;
164+ string serverProcessPath = _pipeStreamProcessIdentifier . GetServerProcessFullFilePath ( namedPipe ) ?? string . Empty ;
165165
166- if ( ! _config . ServiceExePath . Equals ( serverProcessFileName , StringComparison . InvariantCultureIgnoreCase ) )
166+ string expectedServiceProcessPath = Path . GetFullPath ( _config . ServiceExePath ) ;
167+ if ( ! expectedServiceProcessPath . Equals ( serverProcessPath , StringComparison . InvariantCultureIgnoreCase ) )
167168 {
168169 _logger . Warn < ProcessCommunicationErrorLog > ( $ "The owner of the Named Pipe is not this Service. Dispose and recreate.") ;
169170 await _recreateAndStartAsyncFunc ( ) ;
170- return AuthorizationResult . Error ( StatusCodes . Status409Conflict , clientProcessFileName , serverProcessFileName ) ;
171+ return AuthorizationResult . Error ( StatusCodes . Status409Conflict , clientProcessPath , serverProcessPath ) ;
171172 }
172173
173- if ( _config . AppExePath . Equals ( clientProcessFileName , StringComparison . InvariantCultureIgnoreCase ) )
174+ string expectedClientProcessPath = Path . GetFullPath ( _config . AppExePath ) ;
175+ if ( expectedClientProcessPath . Equals ( clientProcessPath , StringComparison . InvariantCultureIgnoreCase ) )
174176 {
175177 return AuthorizationResult . Ok ( ) ;
176178 }
177179
178- _logger . Warn < ProcessCommunicationErrorLog > ( $ "The connected client is unauthorized. Client path: '{ clientProcessFileName } '. Expected: '{ _config . AppExePath } '.") ;
179- return AuthorizationResult . Error ( StatusCodes . Status401Unauthorized , clientProcessFileName , serverProcessFileName ) ;
180+ _logger . Warn < ProcessCommunicationErrorLog > ( $ "The connected client is unauthorized. Client path: '{ clientProcessPath } '. Expected: '{ expectedClientProcessPath } '.") ;
181+ return AuthorizationResult . Error ( StatusCodes . Status401Unauthorized , clientProcessPath , serverProcessPath ) ;
180182 }
181183 catch ( Exception ex )
182184 {
0 commit comments