public void SecretGeneration() { var tuple = W3CUserAuthentication.CreatePublicAndPrivateKey(); Assert.IsNotNull(tuple.Item1); // private key Assert.IsNotNull(tuple.Item2); // public key }
public async Task <IActionResult> GetBlizzardToken([FromQuery] string code, [FromQuery] string redirectUri) { var token = await _authenticationService.GetToken(code, redirectUri); if (token == null) { return(Unauthorized("Sorry H4ckerb0i")); } var userInfo = await _authenticationService.GetUser(token.access_token); if (userInfo == null) { return(Unauthorized("Sorry H4ckerb0i")); } var w3User = await _w3CAuthenticationService.GetUserById(userInfo.battletag); if (w3User == null) { var w3CUserAuthentication = W3CUserAuthentication.Create(userInfo.battletag); await _w3CAuthenticationService.Save(w3CUserAuthentication); return(Ok(w3CUserAuthentication)); } return(Ok(w3User)); }
public void TestJwtTokenGeneration() { var userAuthentication = W3CUserAuthentication.Create("modmoto#2809", _privateKey); Assert.AreEqual( "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJiYXR0bGVUYWciOiJtb2Rtb3RvIzI4MDkiLCJpc0FkbWluIjoiVHJ1ZSIsIm5hbWUiOiJtb2Rtb3RvIn0.dJWTSy3LiWBVzie9gjvD0TO5_mwdi0oUAiEOqGvAqmFfuxM65m5hoAEhRdKFgf_f8H6QxUuEQbtlJrTB2camOYcghwYh3JeML8MM2SoU9FgoLJrXiOBofbTqgeBXeEhp6tcg00S-4P88UxPPxX1BQMiUqzpR0pXr0-ZYaVy0nksImWal9jtRZa5JxK5FJ29D68Ox_kIsWeN-HKX2X9cveKic9PRNoJ9Acb5pBzD0kuoXstbzPlncqGNvzHxE4Fs_J3fUrv9RAouw0FOtWxy-4aAIUCpNuN9SdFrsXqOX0MZMI211vn2uvEbD16SUAMgV2DLRmb3ExDWHgyyaOPLjOvIBPfe5H1fWKC6yIJWtqaPPdSv2n6N-iaBQQ5q1dqJac86x3UcGeJh4PFN8FrqiNqy5ImwyJYbOLwVzG_mAbX1OlblwPVHlf6DwO3LetjIcZrBC_KI-yn0mrCFVvbBSLr1bR2BTEQD38ET4jiy4FieKDjgyiyBgi1TAQlAgk6BjmwuEMjUGKyl5FtDx1SCZNZgk16-Ti0fX_uD20GUbs2xaaDhUgBS7UFa7ZIiCM-sJm3wEFi7BCEVdfGfmO0t_MLhc0eLcawGciBVbiyUt1QHQq45aL9thkE6d8R2X5ZIIYX4ttMUQZGec8w7nzjXFcU8HCJh3_eeMbXyBp1GqTKM", userAuthentication.JWT); }
public void TestPropertyMapping() { var userAuthentication = W3CUserAuthentication.Create("modmoto#2809", _privateKey); Assert.IsTrue(userAuthentication.IsAdmin); Assert.AreEqual("modmoto", userAuthentication.Name); Assert.AreEqual("modmoto#2809", userAuthentication.BattleTag); }
public void JwtCanBeValidated() { var userAuthentication = W3CUserAuthentication.Create("modmoto#2809", _privateKey); var decode = W3CUserAuthentication.FromJWT(userAuthentication.JWT, _publicKey); Assert.AreEqual("modmoto#2809", decode.BattleTag); Assert.AreEqual(true, decode.IsAdmin); Assert.AreEqual("modmoto", decode.Name); Assert.AreEqual(userAuthentication.JWT, decode.JWT); }
public void InvalidSecretThrows() { var userAuthentication = W3CUserAuthentication.Create("modmoto#2809", _privateKey); Assert.IsNull(W3CUserAuthentication.FromJWT(userAuthentication.JWT, _wrongPublicKey)); }