-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* code builds * fixed data repository update logic * removed obsolete using * Removed try/catch from controller * added missing service * bug fix * downgraded package * ignore props causing trouble * Switch for properties in Datarepository * fixed repository logic * merged main * back to dummy implementation in repository --------- Co-authored-by: tba76 <[email protected]> Co-authored-by: Bakken <[email protected]>
- Loading branch information
1 parent
4a86bba
commit 4df2e32
Showing
28 changed files
with
1,773 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace Altinn.Platform.Storage.Configuration | ||
{ | ||
/// <summary> | ||
/// Configuration object used to hold general settings for the storage application. | ||
/// </summary> | ||
public class GeneralSettings | ||
{ | ||
/// <summary> | ||
/// Open Id Connect Well known endpoint. Related to JSON WEB token validation. | ||
/// </summary> | ||
public string OpenIdWellKnownEndpoint { get; set; } | ||
|
||
/// <summary> | ||
/// Hostname | ||
/// </summary> | ||
public string Hostname { get; set; } | ||
|
||
/// <summary> | ||
/// Name of the cookie for runtime | ||
/// </summary> | ||
public string RuntimeCookieName { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the URI for the SBL Bridge Authorization API. | ||
/// </summary> | ||
public Uri BridgeApiAuthorizationEndpoint { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the scopes for Instance Read. | ||
/// </summary> | ||
public List<string> InstanceReadScope { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the cache lifetime for text resources. | ||
/// </summary> | ||
public int TextResourceCacheLifeTimeInSeconds { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the cache lifetime for application title dictionary. | ||
/// </summary> | ||
public int AppTitleCacheLifeTimeInSeconds { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the cache lifetime for application metadata document. | ||
/// </summary> | ||
public int AppMetadataCacheLifeTimeInSeconds { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Altinn.Platform.Storage.Helpers; | ||
using Altinn.Platform.Storage.Interface.Models; | ||
using Altinn.Platform.Storage.Services; | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace Altinn.Platform.Storage.Controllers | ||
{ | ||
/// <summary> | ||
/// Handles operations for signing all or a subset of dataelements for an instance | ||
/// </summary> | ||
[Route("storage/api/v1/instances")] | ||
[ApiController] | ||
public class SignController : ControllerBase | ||
{ | ||
private readonly IInstanceService _instanceService; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="SignController"/> class | ||
/// </summary> | ||
/// <param name="instanceService">A instance service with instance related business logic.</param> | ||
public SignController(IInstanceService instanceService) | ||
{ | ||
_instanceService = instanceService; | ||
} | ||
|
||
/// <summary> | ||
/// Create signature document from listed data elements | ||
/// </summary> | ||
/// <param name="instanceOwnerPartyId">The party id of the instance owner.</param> | ||
/// <param name="instanceGuid">The guid of the instance</param> | ||
/// <param name="signRequest">Signrequest containing data element ids and sign status</param> | ||
[Authorize(Policy = AuthzConstants.POLICY_INSTANCE_SIGN)] | ||
[HttpPost("{instanceOwnerPartyId:int}/{instanceGuid:guid}/sign")] | ||
[ProducesResponseType(StatusCodes.Status201Created)] | ||
[ProducesResponseType(StatusCodes.Status400BadRequest)] | ||
[Produces("application/json")] | ||
public async Task<ActionResult> Sign([FromRoute] int instanceOwnerPartyId, [FromRoute] Guid instanceGuid, [FromBody] SignRequest signRequest) | ||
{ | ||
if (string.IsNullOrEmpty(signRequest.Signee.UserId)) | ||
{ | ||
return Problem("The 'UserId' parameter must be defined for signee.", null, 400); | ||
} | ||
|
||
await _instanceService.CreateSignDocument(instanceOwnerPartyId, instanceGuid, signRequest, User.GetUserIdAsInt().Value); | ||
return StatusCode(201, "SignDocument is created"); | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/Extensions/Storage/ContentDispositionHeaderValueExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using Microsoft.Extensions.Primitives; | ||
using Microsoft.Net.Http.Headers; | ||
|
||
namespace Altinn.Platform.Storage.Extensions | ||
{ | ||
/// <summary> | ||
/// Extensions to simplify the use of <see cref="ContentDispositionHeaderValue"/>. | ||
/// </summary> | ||
public static class ContentDispositionHeaderValueExtensions | ||
{ | ||
/// <summary> | ||
/// Obtain the filename value from FileNameStar or FileName if the FileNameStar property is empty. | ||
/// Then remove any quotes and clean the filename with the AsFileName method. | ||
/// </summary> | ||
/// <param name="contentDisposition">The ContentDispositionHeaderValue object to get a filename from.</param> | ||
/// <returns>A filename cleaned of any impurities.</returns> | ||
public static string GetFilename(this ContentDispositionHeaderValue contentDisposition) | ||
{ | ||
StringSegment filename = contentDisposition.FileNameStar.HasValue | ||
? contentDisposition.FileNameStar | ||
: contentDisposition.FileName; | ||
|
||
return HeaderUtilities.RemoveQuotes(filename).Value.AsFileName(false); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using System; | ||
using System.IO; | ||
using System.Linq; | ||
|
||
namespace Altinn.Platform.Storage.Extensions | ||
{ | ||
/// <summary> | ||
/// Extensions to facilitate sanitization of string values | ||
/// </summary> | ||
public static class StringExtensions | ||
{ | ||
/// <summary> | ||
/// Sanitize the input as a file name. | ||
/// </summary> | ||
/// <param name="input">The input variable to be sanitized.</param> | ||
/// <param name="throwExceptionOnInvalidCharacters">Throw exception instead of replacing invalid characters with '_'.</param> | ||
/// <returns>A filename cleaned of any impurities.</returns> | ||
public static string AsFileName(this string input, bool throwExceptionOnInvalidCharacters = true) | ||
{ | ||
if (string.IsNullOrWhiteSpace(input)) | ||
{ | ||
return input; | ||
} | ||
|
||
char[] illegalFileNameCharacters = Path.GetInvalidFileNameChars(); | ||
if (throwExceptionOnInvalidCharacters) | ||
{ | ||
if (illegalFileNameCharacters.Any(ic => input.Any(i => ic == i))) | ||
{ | ||
throw new ArgumentOutOfRangeException(nameof(input)); | ||
} | ||
|
||
return input; | ||
} | ||
|
||
return illegalFileNameCharacters.Aggregate(input, (current, c) => current.Replace(c, '_')); | ||
} | ||
} | ||
} |
Oops, something went wrong.