Properly authenticating against WCF service in a Claims environment - c#

SharePoint web applications in Claims authentication mode supports NTLM, but only through the following steps:
HTTP 302 redirect to a second location.
HTTP 401 challenge for NTLM auth
HTTP 401 verification
HTTP 302 redirect back to original location (service)
Can I write a custom behavior, channel factory or binding to handle this? Is there a better way to go about this?

What you have listed is the standard NTLM hand shake.
One way to avoid it is to use Kerberos instead of NTLM. See: http://technet.microsoft.com/en-us/library/gg502594.aspx

Related

WebApi authentication with owin and LinkedIn auth provider under Asp.Net

We have a webApi running under Asp.Net with Owin (.Net Framework 4.6).
Several native frontend clients (iOs, android etc.) are using that api.
That API currently uses Microsoft Login with bearer token and cookie authentication. This works, and the access token is returned directly to the webView in the client with the redirected requests and we are able to access our API with the Bearer token and another authentication cookie.
We have now the task to implement authentication with a LinkedIn auth provider in that API. For clearification: we need an OWIN implementation (no AspNet.Core).
We are able to get the access token from LinkedIn within the webAPI using this LinkedIn auth provider. So we see the token in our User.Identity.Claims. We are also able to return it to the client again. Yes, this is maybe no good idea, but it seems to be not possible to get the token directly in the browser/webView because the response_type=code is mandatory for linkedIn authentication. With response_type=token this works for the microsoft authentication.
Anyway at the end the webview is redirected to following url though we already have retrieved the access_token:
http://10.0.2.2:8108/signin-linkedin?error=unsupported_response_type
Please just ignore that we do not use https for now. The host is only for testing, but the important part is the appended error.
Why do we get this error? Who calls this request and why do we have that error though we have the token already?
Another information is, that the access token we have now in the client cannot be used for authentication against the webAPI. So we get back a 401 Unauthorized.
Maybe I should mention explicitly that we use also cookie authentication in the api, which seems to work as we receive the cookie in the webView and we are able to call methods that are protected with cookie authentication only in the correct user context.
Any help is highly appreciated!
The unsupported_response_type error is gone after using HTTPS.

Programmatically authenticate with Azure AD for Application Proxy

I have an on-premise hosted WCF service with REST endpoint which is configured for Anonymous authentication only in IIS. I installed and configured Azure App proxy connector on the server. I am able to contact the service fine with Pass-through authentication, but struggling to authenticate from a console app when Azure AD is chosen as security mechanism. I know I could have pass-through in Azure and turn on for example windows authentication in IIS, but this is unfortunately not an option in this case.
Using a browser, I am able to access the application fine, don't even need to enter credentials, our on-premise AD is connected and synchronized with Azure AD.
I followed this walk-through despite it is not regarding application proxy, and reusing parts of code I am able to get the Access Token for my application, but when I run the http request with Authorization header I don't get the result of service operation.
Using Fiddler I can note the following:
I get http 302 (Found). I can see my Authorization header in request, and in response I get a cookie AzureAppProxyAnalyticCookie
That is followed with http 200 to login.microsoftonline.com
Example I provided link for above works fine so it is clear that I am doing something wrong. Why is Authorization header not accepted and why am I being redirected to logon page?
Thanks in advance
This is working for another service, have no idea what was wrong with the first one, but suspecting something with DNS on local server. Won't be spending more time on this, point is that I shouldn't have experienced the redirect at all, although browser handled it and managed to get me authenticated.

Wep API 2 calls with authorization header gives 403 error

I have a web api application that works good on the local network ( intranet), and it works on the internet also as long as the calls with no authorization header.
All calls with Authorization header gives the following error:
403 Forbidden ( The server denied the specified Uniform Resource
Locator (URL). Contact the server administrator.
What I tried so far
I added the package
Install-Package Microsoft,.AspNet.WebApi.Cors
When I add Authorization : Bearer The Token , the method returns 403
How to solve this
Based on the details you provides, It is clear that you have a firewall preventing this type of requests.
For example the Forefront TMG method to the published web server:
No delegation, and the client cannot authenticate directly
No delegation, but client may authenticate directly
You should use the second option and you will be Good
Hope this will help you

ASP.NET Always include Kerberos authentication in client response

Is there a way to configure IIS or mark up my code so that the client (any major modern browser) will always include Kerberos information in the response without having to make any modifications to the client itself?
In this specific server method, I'm using ASP.NET impersonation with delegation enabled in AD and it would seem that from firefox and a few other clients, Kerberos data is not being passed from the client to the server.
My application only has Windows Authentication enabled, but how can I force the requests to pass Kerberos information along?
If it helps, I'm using jquery's ajax to GET or POST my requests to the server.
As long as your server is returning "WWW-Authenticate" headers that indicate it accepts Kerberos authentication ("Negotiate"), the client should automatically supply the necessary credentials. Make sure that Negotiate is listed as a possible provider for Windows Authentication in the Authentication configuration of your application. You'll probably want to disable NTLM in that list.
You can tell if the client is sending Kerberos tickets if you look at the HTTP headers. It should have something like "Authorization: Negotiate YIIN..."; the first few base64 characters of the payload let you distinguish between Kerberos and NTLM.

Get NTLM Credentials Fiddler

I am not sure if this is possible, but I am running into an issue where a Web Service call is giving me back a 401 Unauthorized. I have looked at the Fiddler logs and confirmed this, but I am passing in the correct credentials through my app. Is there anyway to get credentials that are being passed to the service by looking at the Fiddler Headers or Auth tabs?
If you click the AUTH tab in Fiddler, it will show you the information about the authentication challenge response.
Note, however, that NTLM and Negotiate don't send the raw password over the network.
Is the target site HTTPS? If so, is Extended Protection enabled?

Categories

Resources