From 83061fce6ab9604fb9d582e47d822f074c9d0b27 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Fri, 12 Nov 2021 19:19:22 +0000 Subject: [PATCH] --- server/AyaNova/Controllers/AuthController.cs | 74 -------------------- 1 file changed, 74 deletions(-) diff --git a/server/AyaNova/Controllers/AuthController.cs b/server/AyaNova/Controllers/AuthController.cs index 152eeed5..c89e82df 100644 --- a/server/AyaNova/Controllers/AuthController.cs +++ b/server/AyaNova/Controllers/AuthController.cs @@ -71,80 +71,6 @@ namespace AyaNova.Api.Controllers //NOTE: lockout or other login impacting state is processed later in ReturnUserCredsOnSuccessfulAuthentication() because many of those states need to have exceptions once the user is known //or return alternate result of auth etc - -#if (DEBUG) - - - #region TESTING - - //TEST JWT's with various flaws for testing purposes: - if (creds.Login == "INTEGRATION_TEST") - { - - //build the key (JWT set in startup.cs) - byte[] secretKey = System.Text.Encoding.ASCII.GetBytes(ServerBootConfig.AYANOVA_JWT_SECRET); - - //create a new datetime offset of now in utc time - var iat = new DateTimeOffset(DateTime.Now.ToUniversalTime(), TimeSpan.Zero);//timespan zero means zero time off utc / specifying this is a UTC datetime - var exp = new DateTimeOffset(DateTime.Now.AddDays(30).ToUniversalTime(), TimeSpan.Zero); - string Issuer = "ayanova.com"; - var Algorithm = Jose.JwsAlgorithm.HS256; - - //Pre JWT creation test payloads - switch (creds.Password) - { - case "EXPIRED": - exp = new DateTimeOffset(DateTime.Now.AddDays(-30).ToUniversalTime(), TimeSpan.Zero); - break; - case "WRONG_ISSUER": - Issuer = "Bogus"; - break; - case "NO_ALGORITHM": - Algorithm = Jose.JwsAlgorithm.none; - break; - case "WRONG_SECRET": - secretKey = System.Text.Encoding.ASCII.GetBytes("xxxxxxThisIsObviouslyWrongxxxxxx"); - break; - } - - - var payload = new Dictionary() - { - //{ "iat", iat.ToUnixTimeSeconds().ToString() }, - { "exp", exp.ToUnixTimeSeconds().ToString() },//in payload exp must be in unix epoch time per standard - { "iss", Issuer }, - { "id", "1" } - }; - string TestToken = Jose.JWT.Encode(payload, secretKey, Algorithm); - - - //Post JWT creation test payloads - switch (creds.Password) - { - case "TRUNCATED_SIGNATURE": - TestToken = TestToken.Substring(0, TestToken.Length - 3); - break; - case "TRANSPOSE_SIGNATURE": - //Transpose two characters in the signature - int len = TestToken.Length; - var Transposed = TestToken.Substring(0, len - 5) + TestToken[len - 4] + TestToken[len - 5] + TestToken.Substring(len - 3, 3); - TestToken = Transposed; - break; - } - - - return Ok(ApiOkResponse.Response(new - { - token = TestToken, - name = "SuperUser Account - TESTING", - roles = "0" - })); - - } - - #endregion testing -#endif - if (string.IsNullOrWhiteSpace(creds.Login) || string.IsNullOrWhiteSpace(creds.Password)) { //Make a failed pw wait