public async Task <IActionResult> CreateOrUpdatePlatform( [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "platforms")] HttpRequest req, [Table(PlatformsTableName)] IAsyncCollector <PlatformEntity> entityCollector) { if (!ValidatePermission(req)) { return(new UnauthorizedResult()); } string platformDtoJson = await req.ReadAsStringAsync(); PlatformDto platformDto = JsonConvert.DeserializeObject <PlatformDto>(platformDtoJson); PlatformEntity platformEntity = _mapper.Map <PlatformEntity>(platformDto); platformEntity.ETag = "*"; await entityCollector.AddAsync(platformEntity); await entityCollector.FlushAsync(); string platformGetUrl = $"{req.Scheme}://{req.Host}/api/platforms/{platformEntity.PartitionKey}"; PlatformDto updatedPlatformDto = _mapper.Map <PlatformDto>(platformEntity); return(new CreatedResult(platformGetUrl, updatedPlatformDto)); }
public IActionResult GetNewPlatform( [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "new-platform")] HttpRequest req, [LtiAdvantage] LtiToolPublicKey publicKey) { if (!ValidatePermission(req)) { return(new UnauthorizedResult()); } string platformId = GeneratePlatformID(); PlatformDto platformDto = new PlatformDto { Id = platformId, LoginUrl = $"{ConnectApiBaseUrl}/oidc-login/{platformId}", LaunchUrl = $"{ConnectApiBaseUrl}/lti-advantage-launch/{platformId}", PublicKey = publicKey.PemString, ToolJwk = JsonConvert.SerializeObject(publicKey.Jwk), ToolJwkSetUrl = $"{ConnectApiBaseUrl}/jwks/{platformId}", DomainUrl = new Uri(ConnectApiBaseUrl).Authority }; return(new OkObjectResult(platformDto)); }
public IActionResult GetPlatform( [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "platforms/{platformId}")] HttpRequest req, [LtiAdvantage] LtiToolPublicKey publicKey, [Table(PlatformsTableName, "{platformId}", "{platformId}")] PlatformEntity platformEntity) { if (!ValidatePermission(req)) { return(new UnauthorizedResult()); } PlatformDto platformDto = _mapper.Map <PlatformDto>(platformEntity); platformDto.PublicKey = publicKey.PemString; platformDto.ToolJwk = JsonConvert.SerializeObject(publicKey.Jwk); return(new OkObjectResult(platformDto)); }