Esempio n. 1
0
        public void TokenAuthenticationTest()
        {
            // Create application in case it doesn't exist
            var app = InsertApplication();

            DataLib.Repository repo = new DataLib.Repository();
            var token = repo.GenerateToken(app.Application_Id);

            Assert.IsTrue(repo.CheckTokenAuthentication(token.Token));
        }
Esempio n. 2
0
 public Models.AuthResponse Auth()
 {
     if (System.Threading.Thread.CurrentPrincipal != null &&
         System.Threading.Thread.CurrentPrincipal.Identity.IsAuthenticated)
     {
         var basicAuthenticationIdentity = System.Threading.Thread.CurrentPrincipal.Identity as BasicAuthenticationIdentity;
         if (basicAuthenticationIdentity != null)
         {
             var repo  = new DataLib.Repository();
             var appId = basicAuthenticationIdentity.ApplicationId;
             var token = repo.GenerateToken(appId);
             return(new Models.AuthResponse()
             {
                 Access_Token = token.Token
             });
         }
     }
     return(null);
 }