public async Task <IActionResult> Complete(FileIdentifier id, [FromServices] IUploadedFileRepository uploadedFileRepository) { if (!this.ModelState.IsValid) { return(this.BadRequest()); } UploadedFile?uploadedFile = await uploadedFileRepository.GetFile(id); if (uploadedFile == null) { this._logger.LogWarning(LogEvents.UploadNotFound, "Unable to find uploaded file '{0}'", id); return(this.NotFound("A system error occurred - unable to find just uploaded file")); } if (this.User.HasClaim(KnownClaims.RestrictionId, id.ToString())) { await this.HttpContext.SignOutAsync(KnownAuthenticationScheme.PassphraseScheme); } return(this.View(uploadedFile)); }
public async Task <IActionResult> UploadFileHandler(FileIdentifier id) { var file = await this._uploadedFileRepository.GetFileReservation(id); if (file == null) { this.Response.StatusCode = 404 /* Not Found */; return(this.View("UploadLinkExpired")); } // Set-up authentication ClaimsIdentity userIdentity = new ClaimsIdentity(KnownAuthenticationScheme.PassphraseScheme); userIdentity.AddClaims(new[] { new Claim(ClaimTypes.Name, KnownPolicies.Upload, ClaimValueTypes.String, "https://ifs"), new Claim(KnownClaims.RestrictionId, id.ToString(), ClaimValueTypes.String, "https://ifs"), }); ClaimsPrincipal userPrincipal = new ClaimsPrincipal(userIdentity); AuthenticationProperties authenticationOptions = new AuthenticationProperties { AllowRefresh = true, ExpiresUtc = DateTimeOffset.UtcNow.AddMinutes(30), IsPersistent = false }; await this.HttpContext.SignInAsync(KnownAuthenticationScheme.PassphraseScheme, userPrincipal, authenticationOptions); // Create model for upload UploadModel uploadModel = UploadModelFactory.Create(); uploadModel.FileIdentifier = file.Id; uploadModel.Expiration = file.Metadata.Expiration; uploadModel.IsReservation = true; uploadModel.Sender = file.Metadata.Sender; return(this.View("Index", uploadModel)); }