public IActionResult UpdateEndpoints(Endpoints model) { if (model.FeedbackEndpoint == null || model.ForumEndpoint == null) { ViewBag.MasterContent = "Master content from: " + LocalAddress(); ViewBag.ForumContent = "Forum application url not set"; ViewBag.FeedbackContent = "Feedback application url not set"; return(View("Index")); } if (model.FeedbackEndpoint == "error" || model.ForumEndpoint == "error") { LogWrite("Hello error from application"); return(View("Index")); } ViewBag.MasterContent = "Master content from: " + LocalAddress(); string ForumUrl = model.ForumEndpoint; string FeedbackUrl = model.FeedbackEndpoint; string ForumContent = ""; using (WebClient client = new WebClient()) { ForumContent = client.DownloadString(ForumUrl + "/Home/Forum"); } LogWrite(ForumUrl); string FeedbackContent = ""; using (WebClient client = new WebClient()) { FeedbackContent = client.DownloadString(FeedbackUrl + "/Home/Feedback"); } LogWrite(FeedbackUrl); ViewBag.ForumContent = ForumContent; ViewBag.FeedbackContent = FeedbackContent; try { AwsParameterStoreClient AwsClient = new AwsParameterStoreClient(Amazon.RegionEndpoint.USEast2); var value = AwsClient.GetValueAsync("TestParameter").Result; ViewBag.SsmParameter = value; } catch (Exception ex) { LogWrite(ex.Message); } //string test = GetAwsParameter("TestParameter"); return(View("Index")); }
/// <summary> /// A simple function that takes a string and does a ToUpper /// </summary> /// <param name="input"></param> /// <param name="context"></param> /// <returns></returns> public async Task <PreTokenGeneration> FunctionHandler(PreTokenGeneration input, ILambdaContext context) { context.Logger.LogLine("Just a test"); var claimsToAdd = new Dictionary <string, string>(); // In order to standardize your parameters system wide you should store any environment variables // in the SSM parameter store so you don't have to manage parameters for each lambda function. var client = new AwsParameterStoreClient(Amazon.RegionEndpoint.USEast1); var role = input.Request.UserAttributes["custom:role"]; context.Logger.LogLine(role); //var kinDb = await client.GetValueAsync("/ConnectionString/Dev/KinhrDB"); var cognitoDb = await client.GetValueAsync("/ConnectionString/Dev/CognitoUsersDB"); context.Logger.LogLine(cognitoDb); context.Logger.LogLine("Before attempting to connect to DB"); var claims = new List <Claim>(); try { using (var connString = new SqlConnection(cognitoDb)) { connString.Open(); var query = @"select c.* from RoleClaims rc inner join Roles r on r.Id = rc.RoleId inner join Claims c on c.Id = rc.ClaimId where r.Code = @Code;"; claims = connString.Query <Claim>(query, new { Code = role }).Take(5).ToList(); context.Logger.LogLine($"{claims.Count()}"); } } catch (Exception ex) { context.Logger.LogLine(ex.Message); } foreach (var claim in claims) { claimsToAdd.Add(claim.Type, claim.Value); } input.Response.ClaimsToAddOrOverride = claimsToAdd; return(input); }