File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change 11<?php
22
33return [
4+ "trace " => env ('SCIM_TRACE ' ,false ),
5+ // below, if we ever get 'sure' that we can change this default to 'true' we should
6+ "standards_compliance " => env ('SCIM_STANDARDS_COMPLIANCE ' , false ),
47 "publish_routes " => true
58];
Original file line number Diff line number Diff line change 66use Illuminate \Http \Request ;
77use ArieTimmerman \Laravel \SCIMServer \Exceptions \SCIMException ;
88
9+ function undefault_schema (\stdClass $ parsed_json )
10+ {
11+ foreach ($ parsed_json AS $ key => $ value ) {
12+ if (stristr ($ key ,'urn:ietf:params:scim:schemas:core: ' ) !== false ) {
13+ unset($ parsed_json ->{$ key }); //yank it out
14+ foreach ($ value AS $ subkey => $ subval ) { //iterate through *its* subkey/subvals...
15+ // TODO should we check if the original keys exist? Only overwrite them if they don't?
16+ $ parsed_json ->{$ subkey } = $ subval ;
17+ }
18+ }
19+ }
20+ return $ parsed_json ;
21+ }
22+
923class SCIMHeaders
1024{
1125 public function handle (Request $ request , Closure $ next )
@@ -15,6 +29,21 @@ public function handle(Request $request, Closure $next)
1529 }
1630
1731 $ response = $ next ($ request );
32+
33+ if (config ('scim.standards_compliance ' )) {
34+ $ response_content = json_decode ($ response ->content ());
35+
36+ if (!$ response_content ->totalResults ) {
37+ $ response ->setContent (json_encode (undefault_schema ($ response_content )));
38+ } else {
39+ $ final_response = [];
40+ foreach ($ response_content ->Resources as $ index => $ object ) {
41+ $ final_response [] = undefault_schema ($ object );
42+ }
43+ $ response_content ->Resources = $ final_response ;
44+ $ response ->setContent (json_encode ($ response_content ));
45+ }
46+ }
1847
1948 return $ response ->header ('Content-Type ' , 'application/scim+json ' );
2049 }
You can’t perform that action at this time.
0 commit comments