<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic User/Pass Authentication using RESTful WCF &amp;amp; Windows Forms in cybersource APIs</title>
    <link>https://community.developer.cybersource.com/t5/cybersource-APIs/User-Pass-Authentication-using-RESTful-WCF-amp-Windows-Forms/m-p/84472#M470</link>
    <description>&lt;P&gt;What is the best approach to implementing authorisation/authentication for a Windows Forms app talking to an IIS-hosted RESTful WCF Service?&lt;/P&gt;&lt;P&gt;The reason I ask is I am very confused, after sifting through different articles and posts expressing a different method and eventually hitting a ~650 page document on WCF Security Best Practices" (&lt;A href="http://www.codeplex.com/WCFSecurityGuide" target="_blank" rel="nofollow noopener noreferrer"&gt;http://www.codeplex.com/WCFSecurityGuide&lt;/A&gt;) I am just uncertain which approach is the BEST to take and how to get started on implementation, given my scenario.&lt;/P&gt;&lt;P&gt;I started with this article "A Guide to Designing and Building RESTful Web Services with WCF 3.5" (&lt;A href="http://msdn.microsoft.com/en-us/library/dd203052.aspx" target="_blank" rel="nofollow noopener noreferrer"&gt;http://msdn.microsoft.com/en-us/library/dd203052.aspx&lt;/A&gt;&amp;nbsp;&lt;A href="https://shagle.download" target="_blank" rel="noopener"&gt;shagle&lt;/A&gt; &lt;A href="https://voojio.com/chatroom/omegle" target="_blank" rel="noopener"&gt;voojio&lt;/A&gt;) and a PDC video on RESTful WCF services, which was great and helped me implement my first REST-friendly WCF service,&lt;/P&gt;&lt;P&gt;After I had the service working, I returned to implement security, see. "Security Considerations" (quarter down the page) and attempted to implement a HTTP Authorization header as per the instructions, however I found the code to be incomplete (see how 'UserKeys' variable was never declared). This is the point at which I tried to research more on how to do this (using a HMAC hash with the "Authorization" HTTP header, but could not find much on google?) it led me to other articles regarding message-level security, forms auth and custom validators and frankly I am not sure which is the best and most appropriate approach to take now.&lt;/P&gt;&lt;P&gt;So with all that said (and thanks for listening up till now!), I guess my main questions are,&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;- Which security implementation should I use?&lt;BR /&gt;&lt;BR /&gt;- Is there any way to avoid sending the username/password with every WCF call? I would prefer not to send these extra bytes if a connection has been established at the beginning, which it will be before subsequent calls are allowed to be made after login.&lt;BR /&gt;&lt;BR /&gt;- Should I even really be concerned about anything other than plain text if I am using SSL?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;As said, .NET 3.5 win forms app, IIS-hosted WCF service, however what is important is I wish any and all WCF services to require this authorization procedure (however it should be, session, http header or otherwise) as I do not want anybody to be able to hit these services from the web.&lt;/P&gt;&lt;P&gt;I know the above post is large but I had to express the route I have already been down and what I need to accomplish, any and all help is greatly appreciated.&lt;/P&gt;&lt;P&gt;PS: I am also aware of this post&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://stackoverflow.com/questions/141484/how-to-configure-secure-restful-services-with-wcf-using-usernamepassword-ssl" target="_blank" rel="noopener"&gt;How to configure secure RESTful services with WCF using username/password + SSL&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;A href="https://omegle.ws" target="_blank" rel="noopener"&gt;/ome&lt;/A&gt;&lt;A href="https://omegle.club" target="_blank" rel="noopener"&gt;gle&lt;/A&gt;&amp;nbsp;&lt;/SPAN&gt;and if the community suggests I move away from REST for WCF services, I can do this, however I started with this to keep consistency for any public APIs to come.&lt;/P&gt;&lt;P&gt;I think it's important I state how I am accessing my WCF Service (contacting the service is working, but what is the best way to validate credentials - and then return the Member object?):&lt;/P&gt;&lt;PRE&gt;WebChannelFactory&amp;lt;IMemberService&amp;gt; cf = &lt;SPAN class=""&gt;new&lt;/SPAN&gt; &lt;SPAN class=""&gt;WebChannelFactory&lt;/SPAN&gt;&amp;lt;IMemberService&amp;gt;(
                &lt;SPAN class=""&gt;new&lt;/SPAN&gt; &lt;SPAN class=""&gt;Uri&lt;/SPAN&gt;(Properties.Settings.Default.MemberServiceEndpoint));
            &lt;SPAN class=""&gt;IMemberService&lt;/SPAN&gt; &lt;SPAN class=""&gt;channel&lt;/SPAN&gt; &lt;SPAN class=""&gt;=&lt;/SPAN&gt; cf.CreateChannel();
            &lt;SPAN class=""&gt;Member&lt;/SPAN&gt; &lt;SPAN class=""&gt;m&lt;/SPAN&gt; &lt;SPAN class=""&gt;=&lt;/SPAN&gt; channel.GetMember(&lt;SPAN class=""&gt;"user"&lt;/SPAN&gt;, &lt;SPAN class=""&gt;"pass"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;P&gt;Code that was half implemented from MS article (and some of my own for testing):&lt;/P&gt;&lt;PRE&gt; &lt;SPAN class=""&gt;&lt;SPAN class=""&gt;public&lt;/SPAN&gt; Member &lt;SPAN class=""&gt;GetMember&lt;/SPAN&gt;(&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;string&lt;/SPAN&gt; username, &lt;SPAN class=""&gt;string&lt;/SPAN&gt; password&lt;/SPAN&gt;)&lt;/SPAN&gt;
    {
        &lt;SPAN class=""&gt;if&lt;/SPAN&gt; (&lt;SPAN class=""&gt;string&lt;/SPAN&gt;.IsNullOrEmpty(username))
            &lt;SPAN class=""&gt;throw&lt;/SPAN&gt; &lt;SPAN class=""&gt;new&lt;/SPAN&gt; WebProtocolException(HttpStatusCode.BadRequest, &lt;SPAN class=""&gt;"Username must be provided."&lt;/SPAN&gt;, &lt;SPAN class=""&gt;null&lt;/SPAN&gt;);
        &lt;SPAN class=""&gt;if&lt;/SPAN&gt; (&lt;SPAN class=""&gt;string&lt;/SPAN&gt;.IsNullOrEmpty(password))
            &lt;SPAN class=""&gt;throw&lt;/SPAN&gt; &lt;SPAN class=""&gt;new&lt;/SPAN&gt; WebProtocolException(HttpStatusCode.BadRequest, &lt;SPAN class=""&gt;"Password must be provided."&lt;/SPAN&gt;, &lt;SPAN class=""&gt;null&lt;/SPAN&gt;);

        &lt;SPAN class=""&gt;if&lt;/SPAN&gt; (!AuthenticateMember(username))
        {
            WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.Unauthorized;
            &lt;SPAN class=""&gt;return&lt;/SPAN&gt; &lt;SPAN class=""&gt;null&lt;/SPAN&gt;;
        }

        &lt;SPAN class=""&gt;return&lt;/SPAN&gt; &lt;SPAN class=""&gt;new&lt;/SPAN&gt; Member() { Username = &lt;SPAN class=""&gt;"goneale"&lt;/SPAN&gt; };
    }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 10 Oct 2022 12:31:52 GMT</pubDate>
    <dc:creator>NaquinSonarikh</dc:creator>
    <dc:date>2022-10-10T12:31:52Z</dc:date>
    <item>
      <title>User/Pass Authentication using RESTful WCF &amp; Windows Forms</title>
      <link>https://community.developer.cybersource.com/t5/cybersource-APIs/User-Pass-Authentication-using-RESTful-WCF-amp-Windows-Forms/m-p/84472#M470</link>
      <description>&lt;P&gt;What is the best approach to implementing authorisation/authentication for a Windows Forms app talking to an IIS-hosted RESTful WCF Service?&lt;/P&gt;&lt;P&gt;The reason I ask is I am very confused, after sifting through different articles and posts expressing a different method and eventually hitting a ~650 page document on WCF Security Best Practices" (&lt;A href="http://www.codeplex.com/WCFSecurityGuide" target="_blank" rel="nofollow noopener noreferrer"&gt;http://www.codeplex.com/WCFSecurityGuide&lt;/A&gt;) I am just uncertain which approach is the BEST to take and how to get started on implementation, given my scenario.&lt;/P&gt;&lt;P&gt;I started with this article "A Guide to Designing and Building RESTful Web Services with WCF 3.5" (&lt;A href="http://msdn.microsoft.com/en-us/library/dd203052.aspx" target="_blank" rel="nofollow noopener noreferrer"&gt;http://msdn.microsoft.com/en-us/library/dd203052.aspx&lt;/A&gt;&amp;nbsp;&lt;A href="https://shagle.download" target="_blank" rel="noopener"&gt;shagle&lt;/A&gt; &lt;A href="https://voojio.com/chatroom/omegle" target="_blank" rel="noopener"&gt;voojio&lt;/A&gt;) and a PDC video on RESTful WCF services, which was great and helped me implement my first REST-friendly WCF service,&lt;/P&gt;&lt;P&gt;After I had the service working, I returned to implement security, see. "Security Considerations" (quarter down the page) and attempted to implement a HTTP Authorization header as per the instructions, however I found the code to be incomplete (see how 'UserKeys' variable was never declared). This is the point at which I tried to research more on how to do this (using a HMAC hash with the "Authorization" HTTP header, but could not find much on google?) it led me to other articles regarding message-level security, forms auth and custom validators and frankly I am not sure which is the best and most appropriate approach to take now.&lt;/P&gt;&lt;P&gt;So with all that said (and thanks for listening up till now!), I guess my main questions are,&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;- Which security implementation should I use?&lt;BR /&gt;&lt;BR /&gt;- Is there any way to avoid sending the username/password with every WCF call? I would prefer not to send these extra bytes if a connection has been established at the beginning, which it will be before subsequent calls are allowed to be made after login.&lt;BR /&gt;&lt;BR /&gt;- Should I even really be concerned about anything other than plain text if I am using SSL?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;As said, .NET 3.5 win forms app, IIS-hosted WCF service, however what is important is I wish any and all WCF services to require this authorization procedure (however it should be, session, http header or otherwise) as I do not want anybody to be able to hit these services from the web.&lt;/P&gt;&lt;P&gt;I know the above post is large but I had to express the route I have already been down and what I need to accomplish, any and all help is greatly appreciated.&lt;/P&gt;&lt;P&gt;PS: I am also aware of this post&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://stackoverflow.com/questions/141484/how-to-configure-secure-restful-services-with-wcf-using-usernamepassword-ssl" target="_blank" rel="noopener"&gt;How to configure secure RESTful services with WCF using username/password + SSL&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;A href="https://omegle.ws" target="_blank" rel="noopener"&gt;/ome&lt;/A&gt;&lt;A href="https://omegle.club" target="_blank" rel="noopener"&gt;gle&lt;/A&gt;&amp;nbsp;&lt;/SPAN&gt;and if the community suggests I move away from REST for WCF services, I can do this, however I started with this to keep consistency for any public APIs to come.&lt;/P&gt;&lt;P&gt;I think it's important I state how I am accessing my WCF Service (contacting the service is working, but what is the best way to validate credentials - and then return the Member object?):&lt;/P&gt;&lt;PRE&gt;WebChannelFactory&amp;lt;IMemberService&amp;gt; cf = &lt;SPAN class=""&gt;new&lt;/SPAN&gt; &lt;SPAN class=""&gt;WebChannelFactory&lt;/SPAN&gt;&amp;lt;IMemberService&amp;gt;(
                &lt;SPAN class=""&gt;new&lt;/SPAN&gt; &lt;SPAN class=""&gt;Uri&lt;/SPAN&gt;(Properties.Settings.Default.MemberServiceEndpoint));
            &lt;SPAN class=""&gt;IMemberService&lt;/SPAN&gt; &lt;SPAN class=""&gt;channel&lt;/SPAN&gt; &lt;SPAN class=""&gt;=&lt;/SPAN&gt; cf.CreateChannel();
            &lt;SPAN class=""&gt;Member&lt;/SPAN&gt; &lt;SPAN class=""&gt;m&lt;/SPAN&gt; &lt;SPAN class=""&gt;=&lt;/SPAN&gt; channel.GetMember(&lt;SPAN class=""&gt;"user"&lt;/SPAN&gt;, &lt;SPAN class=""&gt;"pass"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;P&gt;Code that was half implemented from MS article (and some of my own for testing):&lt;/P&gt;&lt;PRE&gt; &lt;SPAN class=""&gt;&lt;SPAN class=""&gt;public&lt;/SPAN&gt; Member &lt;SPAN class=""&gt;GetMember&lt;/SPAN&gt;(&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;string&lt;/SPAN&gt; username, &lt;SPAN class=""&gt;string&lt;/SPAN&gt; password&lt;/SPAN&gt;)&lt;/SPAN&gt;
    {
        &lt;SPAN class=""&gt;if&lt;/SPAN&gt; (&lt;SPAN class=""&gt;string&lt;/SPAN&gt;.IsNullOrEmpty(username))
            &lt;SPAN class=""&gt;throw&lt;/SPAN&gt; &lt;SPAN class=""&gt;new&lt;/SPAN&gt; WebProtocolException(HttpStatusCode.BadRequest, &lt;SPAN class=""&gt;"Username must be provided."&lt;/SPAN&gt;, &lt;SPAN class=""&gt;null&lt;/SPAN&gt;);
        &lt;SPAN class=""&gt;if&lt;/SPAN&gt; (&lt;SPAN class=""&gt;string&lt;/SPAN&gt;.IsNullOrEmpty(password))
            &lt;SPAN class=""&gt;throw&lt;/SPAN&gt; &lt;SPAN class=""&gt;new&lt;/SPAN&gt; WebProtocolException(HttpStatusCode.BadRequest, &lt;SPAN class=""&gt;"Password must be provided."&lt;/SPAN&gt;, &lt;SPAN class=""&gt;null&lt;/SPAN&gt;);

        &lt;SPAN class=""&gt;if&lt;/SPAN&gt; (!AuthenticateMember(username))
        {
            WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.Unauthorized;
            &lt;SPAN class=""&gt;return&lt;/SPAN&gt; &lt;SPAN class=""&gt;null&lt;/SPAN&gt;;
        }

        &lt;SPAN class=""&gt;return&lt;/SPAN&gt; &lt;SPAN class=""&gt;new&lt;/SPAN&gt; Member() { Username = &lt;SPAN class=""&gt;"goneale"&lt;/SPAN&gt; };
    }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Oct 2022 12:31:52 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/cybersource-APIs/User-Pass-Authentication-using-RESTful-WCF-amp-Windows-Forms/m-p/84472#M470</guid>
      <dc:creator>NaquinSonarikh</dc:creator>
      <dc:date>2022-10-10T12:31:52Z</dc:date>
    </item>
  </channel>
</rss>

