Is OWIN/Self-Hosting required for Web API v2 authorization/authentication - owin

I have been trying to learn how to implement authentication and authorization within an ASP.NET Web API v2 project. Does the Web API need to be self-hosted via OWIN before authorization can be implemented or can it still be accomplished when hosting through IIS?

You can host Owin/Web Api in IIS as well.
Remember to install Microsoft.Owin.Host.SystemWeb.
Your config file must be called web.config.

Related

Bypass IIS modules for localhost call

I have 2 websites hosted on IIS. On one website's root config, I have Siteminder module configured. This website has other apps under which it hosts one .Net core WebAPI per app (using inprocess hosting). There are 10 such APIs. Individual api's webconfig does not have any siteminder module and relies on the root site's siteminder verification.
On the 2nd website, we dont plan to use siteminder. But have a requirement to support OAuth2 on the same 10 web APIs as that hosted on the site 1. I was thinking that we could potentially have a simple .Net Core API using YARP reverse proxy package, perform the OAuth2 based token authentication and then reroute the traffic locally to the APIs hosted on site 1. But I dont want to again go through siteminder authentication on site 1 for the rerouted traffic.
Is there a way to support this, without needing to do a dual deployment/hosting of the individual APIs?
Thanks!

How to wrap an asp.net WebApi project with azure API management?

I am having a Web API project in asp.net and this project is hosted on Azure web app services .Azure endpoint of the api works . How can i wrap this api under azure api management ?
Current setup
Asp.net web Api project > Hosted in azure web app services
I tried to add the api in API management via blank and open api specification.
I would expect the Azure API Management could connect to my web app service where my asp.net web api project is hosted.
Deploy your Web API to Azure App Service API App instead of App Service Web App. You will be able to import the API's directly from the UI. Here is the doc.
Alternative to Ketan's approach is to configure API manually using "Blank API" option. where you'll need to specify your App's base URL. You will be required later on to create all operations manually.

Sharepoint Provider Hosted app with Odata Web API

We have a requirement to build a SharePoint Provider hosted app, which needs to call to a ASP.NET Web API built with Odata. I could't find a exact solution for this. Any help to perform this would be highly approciated
It should be like any other web application as the provider hosted App is totally independent from SharePoint.
IF you are building the app using asp.net, then you can just add a reference to the odata endpoint, ex: http://yourservice/odata/$metadata
Visual Studio will generate a proxy to all entities in the odata service.
If you are building the app using other technology, then deal with the service as a normal REST service and call it using any HTTP client, from browser or a backend.

Azure - Making an API App available to a Logic App

I've created a web application API with a swagger interface that I've deployed as an API App to Azure.
When creating a Logic App I can find my API App but whenever I try to use it I get the following error:
Failed to fetch swagger. Ensure you have CORS enabled on the endpoint
and are calling an HTTPS endpoint.
I'm using the default https url for the API definition in the API App:
https://microsoft-SOME-LONG-MS-INTERNAL-ID.azurewebsites.net/swagger/docs/v1
The swagger docs have been provided in my C# web API application through Swashbuckle.
For CORS I've set a single * item.
This didn't seem sufficient for the Logic App to access the API App I then configured Authentication / Authorization for the API App to use Azure Active Directory (express), creating an AD Azure App.
I believe the issue will be one of configuring security which is all pretty new to me in Azure. I'd like to make the API App inaccessible externally, but available to Web Apps and Logic Apps within my Azure subscription.
I've not added any authentication mechanism to the ASP.NET web application itself as I figured the web application would effectively be sitting in a private network on Azure. Perhaps this is a bad assumption and I need to add authentication to allow Azure AD to work?
Any pointers / suggestions?
Turns out I needed to update the Azure SDK for Visual Studio. I had an older version that was deploying a preview Api App which resulted in a "Api app host" type being deployed rather that an "API app" type.
Everything works after the update and I've found some documentation for securing the API App and making it available in the Logic App - https://azure.microsoft.com/en-us/documentation/articles/app-service-logic-custom-hosted-api/

How to Integrate non ASP.NET application as a Relying party in Azure ACS?

We have a web application hosted on Linux platform using Apache and PHP. We would like to configure this application as a relying party in Azure ACS. All the examples I see show how to do this for an ASP.NET application. Is it possible to make a non ASP.NET as a relying party in Azure?
Yes you can setup your PHP web application as a relying party but you will need to leverage a claims-aware security provider like SimpleSamlPhp (https://simplesamlphp.org/).

Resources