Quantcast
Channel: WebAPI – leastprivilege.com
Viewing all articles
Browse latest Browse all 228

ASP.NET Web API Security: Setting up the Sample

$
0
0

You can download the complete source from here. The Web API security sample is in samples/web api security.

On my machine I have mapped the samples/web api security/webhost directory to IIS. I am sure you can use IIS Express as well, but ultimately I find it easier to use IIS (especially combined with SSL). Once you have that mapping in place, set the start URL in Visual Studio and you should be able to simply F5 the MVC project in Visual Studio.

In the login screen, you can use whatever username you like, just use a password that equals the username.

LoginForm

As you can see on the screenshot, I use SSL. This is not a strict requirement, but I only tested the SSL case.

To use the various clients, you also need to adjust some values in the Constants.cs in the PortableCommon project:

//

// change the below constants to match your local system

//

 

public const string WebHostName = “roadie”;

public const string SelfHostName = “roadie”;

 

public const string WebHostAppName = “/webapisecurity/api/”;

public const string SelfHostAppName = “/webapisecurity/api/”;

 

public const string WebHostBaseAddress =
“https:// “
+ WebHostName + WebHostAppName;

public const string SelfHostBaseAddress =
“https:// “
+ SelfHostName + SelfHostAppName;

I assume this is pretty self-explaining. Adjust your hostname here, and the virtual path. I recommend you simply use webapisecurity just as I did.


Filed under: IdentityModel, WebAPI

Viewing all articles
Browse latest Browse all 228

Trending Articles