File tree Expand file tree Collapse file tree
src/Scim/SimpleIdServer.Scim Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1414using SimpleIdServer . Scim . DTOs ;
1515using SimpleIdServer . Scim . Exceptions ;
1616using SimpleIdServer . Scim . Extensions ;
17+ using SimpleIdServer . Scim . Infrastructure ;
1718using SimpleIdServer . Scim . Persistence ;
1819using SimpleIdServer . Scim . Resources ;
1920using SimpleIdServer . Scim . Serialization ;
2829namespace SimpleIdServer . Scim . Api
2930{
3031 [ Route ( SCIMEndpoints . Bulk ) ]
32+ [ TypeFilter ( typeof ( ActivatorActionFilter ) , Arguments = new object [ ] { "IsBulkEnabled" } ) ]
3133 public class BulkController : Controller
3234 {
3335 private readonly SCIMHostOptions _options ;
Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ public virtual IActionResult Get()
4646 } )
4747 . AddComplexAttribute ( "bulk" , schema . Id , c =>
4848 {
49- c . AddBooleanAttribute ( "supported" , new List < bool > { true } ) ;
49+ c . AddBooleanAttribute ( "supported" , new List < bool > { _options . IsBulkEnabled } ) ;
5050 c . AddIntegerAttribute ( "maxOperations" , new List < int > { _options . MaxOperations } ) ;
5151 c . AddIntegerAttribute ( "maxPayloadSize" , new List < int > { _options . MaxPayloadSize } ) ;
5252 } )
Original file line number Diff line number Diff line change 1+ // Copyright (c) SimpleIdServer. All rights reserved.
2+ // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
3+ using Microsoft . AspNetCore . Mvc ;
4+ using Microsoft . AspNetCore . Mvc . Filters ;
5+ using Microsoft . Extensions . Options ;
6+ using System . Net ;
7+ using System . Reflection ;
8+ using System . Threading . Tasks ;
9+
10+ namespace SimpleIdServer . Scim . Infrastructure
11+ {
12+ public class ActivatorActionFilter : ActionFilterAttribute
13+ {
14+ private readonly bool _isEnabled = true ;
15+
16+ public ActivatorActionFilter ( IOptions < SCIMHostOptions > options , string propertyName )
17+ {
18+ var propertyInfo = typeof ( SCIMHostOptions ) . GetProperty ( propertyName , BindingFlags . Public | BindingFlags . Instance ) ;
19+ if ( propertyInfo != null )
20+ {
21+ var val = propertyInfo . GetValue ( options . Value ) ;
22+ if ( val != null && val . GetType ( ) == typeof ( bool ) ) _isEnabled = ( bool ) val ;
23+ }
24+ }
25+
26+ public override async Task OnActionExecutionAsync ( ActionExecutingContext context , ActionExecutionDelegate next )
27+ {
28+ if ( ! _isEnabled )
29+ {
30+ context . Result = new StatusCodeResult ( ( int ) HttpStatusCode . NotFound ) ;
31+ return ;
32+ }
33+
34+ await next ( ) ;
35+ }
36+ }
37+ }
Original file line number Diff line number Diff line change @@ -65,5 +65,9 @@ public SCIMHostOptions()
6565 /// Function used to generate ServiceProviderConfig identifier.
6666 /// </summary>
6767 public Func < string > ServiceProviderConfigIdGenerator { get ; set ; } = ( ) => Guid . NewGuid ( ) . ToString ( ) ;
68+ /// <summary>
69+ /// Enable or disable bulk operations.
70+ /// </summary>
71+ public bool IsBulkEnabled { get ; set ; } = true ;
6872 }
6973}
You can’t perform that action at this time.
0 commit comments