Amazon Lambda – Part 7 – Intermediate .NET 4.6.1 API Secured with [Authorize]

Source Code – https://github.com/ehelin/AmazonLambdaApi (look for commit around the date of the blog post)

Following this process (see reference #1), I was able to secure the .NET 4.6.1 GET API using the [Authorize] decorator very easily (locally).  I will explore other ways to secure Web API’s in the next blog entry before moving onto the Angular JS site addition.

My steps using the above process were as follows:

1) Adding the ‘[Authorize]’ decorator to a method or class restricts access
One

2) This call registers a user for accessTwo

3) This call retrieves a token for that userThree

4) Using the token, access is grantedFour

5) Same call, but from the .NET Core Service ImplementationFive

NOTE: To replicate something like this on production, a developer would either need to migrate the database created by Visual Studio or migrate the tables/stored procedures into a database that is available.  I believe the local database Visual Studio created for me is in the App_Data folder of the .NET 4.6.1 Web API and is related to the .NET 2.0 Membership provider created by Microsoft in the past (my guess).

db

Stay tuned!

References

1) https://blogs.msdn.microsoft.com/martinkearn/2015/03/25/securing-and-securely-calling-web-api-and-authorize/

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s