How to stop anonymous access to hosted WCF service

We can stop other users access than our desired list of customers by applying some sort of techniques as there is no direct On and Off service for this is available in WCF. We can restrict anonymous access in following ways-

1.    By putting Authentication on Services

2.    By not publishing/ exposing your Service Metadata (distributing manually to clients  and Metadata exchange is disabled)

3.    By firewall setup or allowing hard-coded IPs to access server where we have hosted our WCF service

In this blog, I am not going to cover the implementation of above mentioned approaches but giving simple, short and basic idea about them. 

The easiest one is last one i.e. restricting access to server where our WCF service is hosted except our valid IPs. In this IPs are punched to access server and thus our WCF service is accessible to them. 

Second one is making Metadata exchange disable and thus anonymous can't see the details about service. An expert may try to guess without metadata information thous chances are very low.

Third one is the best approach than these duos. As it is putting security to hosted WCF service and more secured and extensible, maintainable approach. 

For more WCF security details, refer Shiv sir post here - If you have some time, I would recommend you to read Shiv sir post on WCF Security here:  http://www.c-sharpcorner.com/UploadFile/shivprasadk/wcf-faq-part-3-10-security-related-faq/


Next Recommended Reading WCF And WCF Service Components