I am new to authentication and authorization concepts. I wrote an authenticate method in my wcf servcice. Methods in wcf service will get called only by authenticated users with specific roles. How does the security context automatically get loaded before each request to wcf service?
Asked
Active
Viewed 315 times
0
-
Just curious why you wrote your own method - you can leverage Windows Principals and use Attribute based permission demands on service operations - http://msdn.microsoft.com/en-us/library/ms731200.aspx – Ta01 Jan 11 '12 at 19:12
-
I was trying to use already existing autjentication code from the previous vesrion of the same project, atleats for first phase. MY concern is I wasnt sure How this security context gets loaded automatically, so that I can use "!HttpContext.Current.User.Identity.IsAuthenticated" in each of my service methods to verify if the currect user is valid and check user.haspermission("rolename") method to do authorization checks. I am making sense? – user1086046 Jan 11 '12 at 19:23
-
I did not really understand what you are trying to do. Do you want to know how you can implement secure services? Or are you wondering how you can reach the authenticated identity after you've successfully authenticated your user? – Kassem Jan 11 '12 at 19:50
-
I am trying to reach authenticated identity, after user is authenticated. – user1086046 Jan 11 '12 at 19:53
-
How can I load SecurityContext automatically before any requests are made to my wcf service? – user1086046 Jan 11 '12 at 19:57
1 Answers
1
Since you are looking to reach the authenticated identity, then the following link should be helpful:
http://msdn.microsoft.com/en-us/library/aa347790.aspx
EDIT: If you want to automate this, you should write a wrapper for your service host (i.e: a class that inherits from ServiceHost) to encapsulate that inside your service host rather than having to write it over and over again.

Kassem
- 8,116
- 17
- 75
- 116
-
-
how does OperationContext.Current.ServiceSecurityContext gets loaded? Do we do this manually or does it get loaded automatically? – user1086046 Jan 12 '12 at 14:51