Send SWT token to a generated wcf proxy and validate it - c#

I've got an WP7 application who does authentication with Azure Access Control Service and stores it's SimpleWebToken in an the IsolatedStorage. I want to use this SWT-token to secure my (locally deployed not in AZURE)WCF Service. (The WCF service is finished, except the ACS token validation part) So I've added an Service Reference in my WP7 application and now I want to send the SWT-token to WCF Service via the generated WCF proxy client, but how? Or is this not the way to do it?

Because custom binding & wsHttpBinding isn't supported on WP7(Not sure if mango fixes this) and I don't want to use a WCFDataService. I've come with an nasty solution, I will add a string(the simplewebtoken) to my operationcontract and send it with every client call. I validate this token in the serviceimplentation with the configured securityTokenHandler. This currently works for me!

Related

Lock down binding to WCF service

I have a WCF service that is used as a data proxy for a Windows Forms client. I would like to secure the Windows Forms / WCF Service binding in such a way that ONLY the Windows Forms client can bind to the service. I don't want the windows users to be able to bind to the service in other ways such as powershell, C#, etc.
The WCF client instance used by the Forms app is using https to bind to WCF which is hosted on IIS. The Forms app also uses default Windows credentials to bind to the WCF service. I'm using basichttpbinding. Everything there works great.
I was thinking of using a certificate with a private key where the client would need the matching private key of the certificate embedded in the service. At what level would you implement that, or is there a better way of doing this?

WCF service Single proxy instance with multiple endpoints

I developed a WCF Service hosted in a Windows Service which would send a request to the thirdparty webservice and expects a response.So all i would be given is the url/wsdl information of the thirdparty service where its hosted.
I want to implement say a test service which would give response to my request and Create a single proxy of that service by adding service reference in the visual studio to the actual service.So there can be any number of third party applications which would provide their urls in the future for communication.
My question about the WCF is can i create a single proxy client once and just send the request to a webservice based on the url on the fly ? Is it possible to use the same proxy client for both HTTP and HTTPS by just passing the binding and address parameters dyanmically ?
Once you have create the proxy you cannot change its address. You could have several open proxies, one per 3rd party. In addition a single proxy cannot be reused for http and https since they use different bindings (in addition to the reason above).
One reason for this behavior (which may or may not be relevant in your case) id that proxy can keep state with the server, for example an open security session.

Need to secure WCF data, but just for one section

I have a WCF Service setup using BasicHttpBinding, now I need to make a section where I will allow users to upload a file. This needs to be secure, so we are thinking of using SSL for transfer from website to WCF. Does anyone know if I need to create another WCF Service just for the SSL piece or can it all be in one WCF Service, part of it being BasicHTTPBinding and the other part being the SSL piece, as we don't want to use SSL for all calls, just a few related to the file upload.
Otherwise is there anothe way to approach this? Like possibly encrypt the file via some encryption method on the website side and then send it over we could try that if that's recommended, so no SSL just sending the encrypted file to WCF to store on the server.
Thank you.
Yes you need 2 WCF services with seperate contracts, but they can be hosted onn the same site.
Configure the one that you want to use SSL with a binding that has "Transport Security".

How to setup WCF proxy relay service

I am writing an ASP.net Dashboard application in C#. The application will collect alarm statistics and display them on the dashboard via Ajax(jQuery).
The application could collect the alarm stats cross domain so we chose to set it up as follows:
A standalone Windows Service runs with a constant connection to the Broker(a program that collects stats). Inside the Windows Service we've hosted a WCF service. The windows service will load pass the string of stats into the WCFExternalService.
We then setup an WCF Service hosted in IIS and referenced inside the Client app( this service will act as a relay/proxy service).
Can someone please point me to an article or explain how to setup the bindings/endpoints to connect the proxy service to the external WCF service?
Thanks in advance for any help on this!
Larry
Looks like you have already got most of the structure going. My inputs below:
The WCF proxy (in UI layer) could implement the same service contract as its WCF service counterpart (in Windows service). However, the WCF proxy would be a 'client' of the real WCF service (you need to configure this in Web.config).
Now, enable the WCF proxy to be consumed by jQuery / JavaScript using WebInvoke attribute. [WebInvoke("GET", WebMessageBodyStyle.WrappedRequest, ResponseFormat:=WebMessageFormat.Json)]
Use jQuery $.ajax syntax to consume your WCF proxy. The url should be an equivalent of 'http://myHost/myVirtual/MyProxy.svc/MyMethod' and the data should be a JSON string equivalent of your WCF proxy parameters.
Further explanation on the first point:
This MSDN article explains how to set up a WCF client (to be consumed by your proxy WCF).
Next, you can create a proxy WCF service to consume the WCF client.
The Web.config of your website (which contains the proxy) needs sections for WCF client and WCF proxy.
Hosting does not matter in WCF, so your 'real' service could support any binding (Http, Tcp) based on your requirements and environment

How can I read the Clientcertificate within a WCF service?

I do host a WCF service on a server which requires the clients to authenticate using a x509 certificate. I need to read this certificate inside the service as the data contained is part of the business logic.
The binding I use for the WCF service is webHttpBinding with security set to "Transport" and clientCredentialType="certificate".
In ASP.net I can use the HttpContext.Current, which however is not available in WCF. What can I do to still get the certificate from the user?
Kind regards,
Alois
The article on http://blogs.msdn.com/b/wenlong/archive/2006/01/23/516041.aspx provided me with the solution to this problem. WCF allows to run in "ASP.net compatibility mode" which brings back the full HttpContext object.
I use this in my WCF service, with ASP.net compatibility disabled:
var x509ClaimSet = OperationContext.Current.ServiceSecurityContext.AuthorizationContext.ClaimSets.FirstOrDefault() as X509CertificateClaimSet;

Categories

Resources