Exemplo n.º 1
0
        private async Task <bool> IsCodeChallengeValid(string authCode, string codeVerifier)
        {
            var savedCodeChallenge = await dao.GetCodeChallengeByAuthCodeAsync(authCode);

            var checkedCodeChallenge = CodeChallenge.Create(codeVerifier);

            return(savedCodeChallenge == checkedCodeChallenge);
        }
        public void TestPalindrome4()
        {
            //arrange
            string text     = "john";
            bool   expected = false;
            //act
            bool actual = CodeChallenge.isPalindrome(text);

            //assert
            Assert.AreEqual(expected, actual);
        }
        public void TestPalindrome3()
        {
            //arrange
            string text     = "never Odd, or Even.";
            bool   expected = true;
            //act
            bool actual = CodeChallenge.isPalindrome(text);

            //assert
            Assert.AreEqual(expected, actual);
        }
        public void TestPalindrome2()
        {
            //arrange
            string text     = "Racecar";
            bool   expected = true;
            //act
            bool actual = CodeChallenge.isPalindrome(text);

            //assert
            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 5
0
        public CodeChallengeTests()
        {
            var cassettesPath = new DirectoryInfo($"{_baseDirectory}/resources/cassettes");

            _vcr = new VCR(new FileSystemCassetteStorage(cassettesPath));
            var vcrHandler = _vcr.GetVcrHandler();

            vcrHandler.InnerHandler = new HttpClientHandler();
            HttpClient client = new HttpClient(vcrHandler);

            _repository = new CodeChallenge(client);
        }
Exemplo n.º 6
0
        private Dictionary <string, string> AuthorizationParameters(CodeChallenge codeChallenge, string responseType = "code id_token token")
        {
            var qsParameters = new Dictionary <string, string>();

            qsParameters.Add("response_type", responseType);
            qsParameters.Add("redirect_uri", Configuration["auth:redirect"]);
            qsParameters.Add("client_id", Configuration["auth:clientId"]);
            qsParameters.Add("error_uri", Configuration["auth:error"]);
            qsParameters.Add("code_challenge_method", codeChallenge.Method);
            qsParameters.Add("code_challenge", codeChallenge.Challenge);
            qsParameters.Add("scope", Configuration["auth:scope"]);
            qsParameters.Add("nonce", Guid.NewGuid().ToString());
//		qsParameters.Add("response_mode", "form_post");
            qsParameters.Add("state", "i am statefull");
            return(qsParameters);
        }
Exemplo n.º 7
0
        private static async Task <IEnumerable <User> > LoadUsers()
        {
            using (var client = new HttpClient())
            {
                var connector = new CodeChallenge(client);

                var loadJsonTask = connector.LoadDataFromJSON();
                var loadCsvTask  = connector.LoadDataFromCSV();

                await Task.WhenAll(loadCsvTask, loadJsonTask);

                return(loadJsonTask.Result.Concat(loadCsvTask.Result)
                       .Select(userDTO => Parser.parseUserDTO(userDTO, "BR", "BR"))
                       .ToHashSet());
            }
        }
Exemplo n.º 8
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("appsettings.json");

            Configuration = builder.Build();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.Run(async(context) =>
            {
                Console.WriteLine(context.GetType().Name);
                if (context.Request.Path.Equals("/login"))
                {
                    var codeChallenge                    = new CodeChallenge();
                    var authParameters                   = AuthorizationParameters(codeChallenge);
                    Uri endpoint                         = new Uri(new Uri(Configuration["auth:endpoint"]), "/connect/authorize?" + authParameters.GetQueryString());
                    context.Response.StatusCode          = 302;
                    context.Response.Headers["Location"] = endpoint.ToString();
                    context.Response.Cookies.Append("codeChallenge", codeChallenge.Verifier);
                }
                else if (context.Request.Path.Equals("/login-implicit"))
                {
                    var codeChallenge                    = new CodeChallenge();
                    var authParameters                   = AuthorizationParameters(codeChallenge, "token id_token");
                    authParameters["scope"]              = "openid access-features SAAPI userservice";
                    Uri endpoint                         = new Uri(new Uri(Configuration["auth:endpoint"]), "/connect/authorize?" + authParameters.GetQueryString());
                    context.Response.StatusCode          = 302;
                    context.Response.Headers["Location"] = endpoint.ToString();
                    context.Response.Cookies.Append("codeChallenge", codeChallenge.Verifier);
                }
                else if (context.Request.Path.Equals("/logout"))
                {
                    Uri endpoint = new Uri(new Uri(Configuration["auth:endpoint"]), "/connect/endsession" + context.Request.QueryString);
                    context.Response.StatusCode          = 302;
                    context.Response.Headers["Location"] = endpoint.ToString();
                }
                else
                {
                    await context.Response.SendFileAsync("./wwwroot/receive.html");
                }
            });
        }
Exemplo n.º 9
0
 void Start()
 {
     mCodeChallenge = GameObject.Find("Main").GetComponent <CodeChallenge>();
     audio          = this.GetComponent <AudioSource>();
     clickCount     = 0;
 }