<p>What's the best way to implement authentication over WCF?</p>

<p>I'd prefer to not use WS-* as it needs to be transport independent.</p>

<p>Should I "roll my own"? Is there any guidance for doing that (articles/blog posts)?<br>
Or is there some way to <em>(and should I)</em> use the built in ASP.NET Membership and Profile providers on the server side?
­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­</p>

[{'answer_id': 17548, 'author': 'samjudson', 'author_id': 1908, 'author_profile': 'https://Stackoverflow.com/users/1908', 'pm_score': 0, 'selected': False, 'text': '<p>Why should WS-* be transport dependant?</p>\n\n<p>The whole point of the WS-* specifications is that they are part of the message, and hence transport independent.</p>\n'}, {'answer_id': 17614, 'author': 'DavidWhitney', 'author_id': 1297, 'author_profile': 'https://Stackoverflow.com/users/1297', 'pm_score': 0, 'selected': False, 'text': "<p>WS-* is transport independant.  That's the entire point.</p>\n\n<p>Authentication really depends on who the desired consumers of your service are.  Don't weigh down internal services with security that isn't required, and likewise it's useful to add extra layers of security if you need to know specific things about third party users.</p>\n\n<p>For external APIs we've gone with WS-* authentication using certificates and then a simple authentication mechanism (username and password is supplied, GUID authentication token is returned, token is supplied with all requests after the fact).</p>\n"}, {'answer_id': 17908, 'author': 'tgmdbm', 'author_id': 1851, 'author_profile': 'https://Stackoverflow.com/users/1851', 'pm_score': 0, 'selected': False, 'text': "<p>Thanks for your answers.</p>\n\n<p>I did not mean transport dependant, my mistake. I meant that I'd like the consumer to be able to choose which endpoint to bind to. And since basicHttpBinding and netTcpBinding, amongst others, don't suppport WS-* I need to use something at the at the service level.</p>\n\n<p>Davids simple authentication is what I've been trying to avoid. Ideally I'd like a way to accomplish the same thing without having to add a token argument to all my operation contracts.</p>\n"}, {'answer_id': 53437, 'author': 'nedruod', 'author_id': 5504, 'author_profile': 'https://Stackoverflow.com/users/5504', 'pm_score': 2, 'selected': False, 'text': "<p>Message based authentication, which is WS-Security based, is what you're looking for and is definitely supported by basicHttpBinding and netTcpBinding.  I think you are making the mistaken assumption that only WsHttpBinding will support WS-Security, which is inaccurate.  </p>\n\n<p>The WS bindings are for WS-* elements other than WS-Security, such as WS-ReliableMessaging.  Setting up transport independent message security is still going to be tricky, if you want it to stay secure.  For the transports that aren't duplex you'll need to have at least one certificate exchanged in advance.  </p>\n\n<p>That might be the other reason you believe message security isn't supported by basicHttpBinding.  basicHttpBinding will not allow you to use UserName authentication without transport security (for good reason too I'll add).  And since transport security is inherently transport dependent I'm guessing you're trying to avoid it.</p>\n\n<p>So anyhow, if you want to be fully transport independent the first thing you need to tackle is getting the certificates in order and figuring out how you're going to distribute the first (root) certificate(s), or securely exchange certificates.  If you have the luxury of an application where you can distribute a master certificate, then take that route.  If you're in a more complex scenario than that, you need to step back and think about how hard this problem really is.</p>\n"}, {'answer_id': 1222874, 'author': 'Scott P', 'author_id': 33848, 'author_profile': 'https://Stackoverflow.com/users/33848', 'pm_score': 0, 'selected': False, 'text': '<p>If you are exposing an external service that requires user level authentication / authorization, I would recommend using the ASP.NET provider.</p>\n\n<p>There\'s a useful utility <a href="http://www.idesign.net/idesign/DesktopDefault.aspx?tabindex=5&amp;tabid=11#WCFSecurity" rel="nofollow noreferrer">here</a> that allows remote administration of the ASP.NET provider.  The ASP.NET solution does require SQL...</p>\n'}]
['https://Stackoverflow.com/questions/17098', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1851/']