mrtentje
mrtentje

Reputation: 1422

Asp.net mvc4 authentication through WCF

I have a requirement for project to build a ASP.NET MVC4 (razor engine) "Front-end" and a WCF service as "backend" (with a sql server 2012 database).

A requirement is to login, register etc. I want to put this logic in the backend, but in the front-end I would like to make use of the [AllowAnonymous] and the logic to authenticate a user with roles (for example use of formauthentication, webmatrix.WebSecurity, Membership provider?).

Is it possible to realize? Do I have to create a login and register (and roles etc.) features by myself? Or can I use a built-in features/libraries of the ASP.NET MVC or WCF? Or both?

Could you give some examples/suggestions/tutorials to realize this?

Thanks in advance

Upvotes: 1

Views: 3143

Answers (1)

aKzenT
aKzenT

Reputation: 7915

I think this should work for you:

http://msdn.microsoft.com/en-us/library/bb386582.aspx

Edit: To elaborate you can use custom logic for WCF authentication including calling the ASP.NET membership providers which should work fine with MVC and the security attributes you mentioned.

Or is the WCF service on another server and you want to call from your ASP.NET controller to your WCF service for authentication? This is a bit more complex, but you should be able to do it by implementing your own Membership provider.

Depending on the scenario you can reuse some or all of the login and register views that come with MVC.

Edit: In the second scenario here are some pointers that might help:

http://singlesignon.codeplex.com/ - Seems to be what you need, but I didn't check out the code.

Custom membership that uses web service for authentication - No code, but it confirms that it should work.

Upvotes: 1

Related Questions