Monday, December 1, 2014

Azure WebSites and Auth0 integration

A couple of weeks ago, I met with one of my long time friends, @tjanczuk.  Tomek (that is how people call him) is currently working at Auth0.  He was very excited to share with me about his new adventure with this company especially the problem space it is trying to solve.

Auth0 goal is to take care of the hard security aspect for your site and let you focus on your more important business logic.  One crucial necessity for online services is an ability to identify (or authenticate) their users.  If you are a well established company, you can afford to spend money and build one.  However, for start up or small business owners, it may not be cost efficient to do so.  It is even risky if it is not done in a secured manner.

I view Auth0 as a SaaS whose value proposition is to provide a one-stop identity service for your site.  Not only does it make easy (and safe) to secure your sites, it also provides a wide range of integration with popular identity providers such as (Azure Active Directory, Live/MSA accounts, Facebook, Google and much more).  This allows lots of flexibility for end users to sign in to the site.

Since I am one of Azure Websites developers, I took it as an exercise to demonstrate how simple it is to integrate Auth0 to sites hosted on Azure Websites.   I pick 2 simple scenarios below.   Note: you will need an Azure subscription in order to try them.


Scenario 1 Quick Start for Auth0 and Azure Websites

This is a quick start.  It demonstrates how to create a new Azure Websites with Auth0 enabled in one shot.  Simply follow the readme section https://github.com/suwatch/Auth0OAuth repository.

To summarize, all you have to do is to create a new (or use an existing) Auth0 application.   Then simply click the Deploy to Azure button.   This will create and deploy the repository to Azure Websites.  Simply browser to the websites to see how Auth0 works.   All source codes are available as part of the repository.

   

Scenario 2 Add Auth0 to an existing Azure Websites

Let say you already have a website hosted on Azure Websites.   Don't worry if you don't have one, go to Azure Portal and simply create one.  For simplicity, let assume your website's name is foo and its url is http://foo.azurewebsites.net/.   Browse to your site and you should get a standard landing page for Azure Websites.

To enable Auth0 is as simple as to enable the Auth0 site extension for your site.   Here is how.

  • Browse to https://foo.scm.azurewebsites.net/.  This is Site Control Manager (SCM) for your site.  In short, the SCM site (or Kudu service) allows you to manage and diagnose the issue your site.   More info can be found here.

  • One of the powerful feature is Site Extensions.  This enables communities to share and contribute the site extension that would enhance the functionalities of the site.  Select Site Extensions tab.
      

  • Select Gallery tab.



  • You will see many available Site Extensions.  Locate the Auth0 Extension and click install.



  • After install (or uninstall) Site Extension, you will need to restart the site.   To restart, go to Azure Portal, select your site.  You can find the restart button on the command bar at the bottom.  
  • Browse to your site (http://foo.azurewebsite.net/) and follow the instructions.  You should be familiar with this by now.


  • Refresh your site (http://foo.azurewebsite.net/).  You should see now that the site is integrated with Auth0!

All source codes for Site Extension are available at https://github.com/suwatch/Auth0Extension.  Let me know @suwat_ch for any issue.

No comments:

Post a Comment