Best way to restrict WCF service to specific user accounts

I will host the underlying WCF HTTP service using the Windows Service / Service Host. I would like to limit the service to two specific users of the active directory of the window, and these accounts will be different between the PRD and DEV environments, so they will be installed in the configuration file.

I was wondering if this is the best way to do this, I know that if I accepted this service using IIS, then I could restrict it to Web.config: http://www.rickgaribay.net/archive/2007/ 04/04 / recipe-wcf-basichttpbinding-with-windows-authentication.aspx However, since I am hosting using ServiceHost, I do not think this is an option.

From what I read, it is possible to do this using the PrincipalPermission Declarative attribute at the service class level: http://msdn.microsoft.com/en-us/library/vstudio/ms731200(v=vs.100).aspx However, I I don’t quite understand if this will go through the windowed window service account or the account that made the HTTP request. I need to pass an HTTP request account. Also, with declartive attributes, is it possible to use a configuration file attribute rather than hard-coded?

Any suggestions if you need more information let me know.

+4
source share
2 answers

I found the following article suitable for what I needed, basically it concerned authorization using behavior: http://allen-conway-dotnet.blogspot.co.uk/2010/01/how-to-create-aspnet- windows.html

+2
source

Source: https://habr.com/ru/post/1445260/


All Articles