@@ -45,6 +45,7 @@ public class InstancesController : ControllerBase
4545 private readonly GeneralSettings _generalSettings ;
4646 private readonly IRegisterService _registerService ;
4747 private readonly IApplicationService _applicationService ;
48+ private readonly IProcessAuthorizer _processAuthorizer ;
4849
4950 /// <summary>
5051 /// Initializes a new instance of the <see cref="InstancesController"/> class
@@ -57,6 +58,7 @@ public class InstancesController : ControllerBase
5758 /// <param name="registerService">the instance register service.</param>
5859 /// <param name="applicationService">the application service.</param>
5960 /// <param name="settings">the general settings.</param>
61+ /// <param name="processAuthorizer">the process authorizer.</param>
6062 public InstancesController (
6163 IInstanceRepository instanceRepository ,
6264 IPartiesWithInstancesClient partiesWithInstancesClient ,
@@ -65,7 +67,8 @@ public InstancesController(
6567 IInstanceEventService instanceEventService ,
6668 IRegisterService registerService ,
6769 IApplicationService applicationService ,
68- IOptions < GeneralSettings > settings
70+ IOptions < GeneralSettings > settings ,
71+ IProcessAuthorizer processAuthorizer
6972 )
7073 {
7174 _instanceRepository = instanceRepository ;
@@ -77,6 +80,7 @@ IOptions<GeneralSettings> settings
7780 _registerService = registerService ;
7881 _applicationService = applicationService ;
7982 _generalSettings = settings . Value ;
83+ _processAuthorizer = processAuthorizer ;
8084 }
8185
8286 /// <summary>
@@ -911,9 +915,11 @@ await _instanceEventService.DispatchEvent(
911915 /// <param name="presentationTexts">Collection of changes to the presentation texts collection.</param>
912916 /// <param name="cancellationToken">CancellationToken</param>
913917 /// <returns>The instance that was updated with an updated collection of presentation texts.</returns>
914- [ Authorize ( Policy = AuthzConstants . POLICY_INSTANCE_WRITE ) ]
918+ [ Authorize ]
915919 [ HttpPut ( "{instanceOwnerPartyId:int}/{instanceGuid:guid}/presentationtexts" ) ]
916920 [ ProducesResponseType ( StatusCodes . Status200OK ) ]
921+ [ ProducesResponseType ( StatusCodes . Status400BadRequest ) ]
922+ [ ProducesResponseType ( StatusCodes . Status403Forbidden ) ]
917923 [ Consumes ( "application/json" ) ]
918924 [ Produces ( "application/json" ) ]
919925 public async Task < ActionResult < Instance > > UpdatePresentationTexts (
@@ -934,6 +940,11 @@ CancellationToken cancellationToken
934940 cancellationToken
935941 ) ;
936942
943+ if ( ! await _processAuthorizer . AuthorizePresentationTextsUpdate ( instance ) )
944+ {
945+ return Forbid ( ) ;
946+ }
947+
937948 if ( instance . PresentationTexts == null )
938949 {
939950 instance . PresentationTexts = new Dictionary < string , string > ( ) ;
@@ -969,10 +980,11 @@ CancellationToken cancellationToken
969980 /// <param name="dataValues">Collection of changes to the data values collection.</param>
970981 /// <param name="cancellationToken">CancellationToken</param>
971982 /// <returns>The instance that was updated with an updated collection of data values.</returns>
972- [ Authorize ( Policy = AuthzConstants . POLICY_INSTANCE_WRITE ) ]
983+ [ Authorize ]
973984 [ HttpPut ( "{instanceOwnerPartyId:int}/{instanceGuid:guid}/datavalues" ) ]
974985 [ ProducesResponseType ( StatusCodes . Status200OK ) ]
975986 [ ProducesResponseType ( StatusCodes . Status400BadRequest ) ]
987+ [ ProducesResponseType ( StatusCodes . Status403Forbidden ) ]
976988 [ Consumes ( "application/json" ) ]
977989 [ Produces ( "application/json" ) ]
978990 public async Task < ActionResult < Instance > > UpdateDataValues (
@@ -993,6 +1005,11 @@ CancellationToken cancellationToken
9931005 cancellationToken
9941006 ) ;
9951007
1008+ if ( ! await _processAuthorizer . AuthorizeDataValuesUpdate ( instance ) )
1009+ {
1010+ return Forbid ( ) ;
1011+ }
1012+
9961013 instance . DataValues ??= new Dictionary < string , string > ( ) ;
9971014
9981015 List < string > updateProperties = [ ] ;
0 commit comments