Base solution for your next web application
Open Closed

Token Based Authentication in ASP.NET Zero #384


User avatar
0
terrybentley created

I have been struggling for a couple days trying to get token based authentication working with the ASP.NET Zero framework. I will need this to secure the APIs that will be used by third party software as well as my web app. I have been able to get the sample provided in the link <a class="postlink" href="http://bitoftech.net/2014/06/01/token-based-authentication-asp-net-web-api-2-owin-asp-net-identity/">http://bitoftech.net/2014/06/01/token-b ... -identity/</a> working but am having trouble transitioning this sample which uses the basic Microsoft.AspNet.Identity to using the enhanced Abp.Authorization framework in ASP.NET Zero.

Any assistance gratefully accepted.


1 Answer(s)
  • User Avatar
    0
    hikalkan created
    Support Team

    Hi,

    I will implement this in next versions. Fortunately, I implemented it for simple ABP template. It will be similar for AspNet Zero.

    First, create an "ABP + module zero" template from <a class="postlink" href="http://www.aspnetboilerplate.com/Templates">http://www.aspnetboilerplate.com/Templates</a> and download it. It implements token based auth.

    Key parts are;

    • AccountController: <a class="postlink" href="https://github.com/aspnetboilerplate/module-zero-template/blob/master/src/AbpCompanyName.AbpProjectName.WebApi/Api/Controllers/AccountController.cs">https://github.com/aspnetboilerplate/mo ... troller.cs</a> This is web API Controller to authenticate.

    • <a class="postlink" href="https://github.com/aspnetboilerplate/module-zero-template/blob/master/src/AbpCompanyName.AbpProjectName.WebApi/Api/AbpProjectNameWebApiModule.cs#L22">https://github.com/aspnetboilerplate/mo ... ule.cs#L22</a> This line added Bearer auth filter.

    • <a class="postlink" href="https://github.com/aspnetboilerplate/module-zero-template/blob/master/src/AbpCompanyName.AbpProjectName.WebSpaAngular/App_Start/Startup.cs#L23">https://github.com/aspnetboilerplate/mo ... tup.cs#L23</a> And this line enables it.

    I implemented it using this tutorial: <a class="postlink" href="http://bitoftech.net/2014/06/01/token-based-authentication-asp-net-web-api-2-owin-asp-net-identity/">http://bitoftech.net/2014/06/01/token-b ... -identity/</a>