0

I am in need of implementing Token based Authentication in my web api project. On Googling I came to know about JWT. But now its been a day on scratching my head and googling how to implement JWT for simple Forms Authenications.

The links that I found shows JWT with either OAuth or Identity framework.

But I am NOT using OAuth or Identity framework.

public HTTPStatusCode Login(string userName, string pwd)
{
       if(userName!=null && pwd !=null)
       {
         IDAL dal = new AccountService();
         bool isValid = dal.ValidateUser(userName,pwd); //simple dal method to check for the username & password
         if(isValid)
         {
            //here I need to implement JWT.
            return HTTPStatus.Ok;
         }
         else
         {
            return HTTPStatus.BadRequest;
         }
       }
}

Can somebody share some article that demonstrates how to impment JWT?

aarti
  • 104
  • 1
  • 6
  • 1
    `JWT` doesn't "really' work with username/pwd as your code above shows. If you want "bare bones" JWT and implement it however you deem fit, look into the [Nuget package: JWT](http://www.nuget.org/packages/JWT/). Project is on [Github](https://github.com/jwt-dotnet/jwt) Hth. – EdSF Feb 07 '17 at 21:00
  • 1
    As @EdSF said, JWTs themselves can be created with a simple library (they're just encoded JSON hashes). Using tokens for authentication is a larger concern that touches more of your application than just what the login route returns. I wrote an article (in the context of ASP.NET Core) that covers a very simple case: https://stormpath.com/blog/token-authentication-asp-net-core – Nate Barbettini Feb 07 '17 at 21:54

0 Answers0