File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1212\OC_JSON ::checkAppEnabled ('files_external ' );
1313\OC_JSON ::callCheck ();
1414
15- \OC_JSON ::checkAdminUser ();
15+ // Replaces \OC_JSON::checkAdminUser() to also allow delegated admins access.
16+ $ currentUser = \OC ::$ server ->getUserSession ()->getUser ();
17+ if ($ currentUser === null ) {
18+ \OC_JSON ::error (['message ' => 'Not logged in ' ]);
19+ exit ();
20+ }
21+ $ groupManager = \OC ::$ server ->getGroupManager ();
22+ $ authorizedGroupMapper = \OC ::$ server ->get (\OC \Settings \AuthorizedGroupMapper::class);
23+ $ isAdmin = $ groupManager ->isAdmin ($ currentUser ->getUID ());
24+ // A delegated admin is granted access when their group is authorized for the files_external Admin settings class.
25+ $ isDelegated = in_array (\OCA \Files_External \Settings \Admin::class, $ authorizedGroupMapper ->findAllClassesForUser ($ currentUser ), true );
26+ if (!$ isAdmin && !$ isDelegated ) {
27+ \OC_JSON ::error (['message ' => 'Not authorized ' ]);
28+ exit ();
29+ }
1630
1731$ pattern = '' ;
1832$ limit = null ;
Original file line number Diff line number Diff line change 14071407 <file src =" apps/files_external/ajax/applicable.php" >
14081408 <DeprecatedMethod >
14091409 <code ><![CDATA[ \OC_JSON::callCheck()]]> </code >
1410- <code ><![CDATA[ \OC_JSON::checkAdminUser()]]> </code >
14111410 <code ><![CDATA[ \OC_JSON::checkAppEnabled('files_external')]]> </code >
1411+ <code ><![CDATA[ \OC_JSON::error(['message' => 'Not authorized'])]]> </code >
1412+ <code ><![CDATA[ \OC_JSON::error(['message' => 'Not logged in'])]]> </code >
14121413 <code ><![CDATA[ \OC_JSON::success($results)]]> </code >
1414+ <code ><![CDATA[ getGroupManager]]> </code >
1415+ <code ><![CDATA[ getUserSession]]> </code >
14131416 </DeprecatedMethod >
14141417 </file >
14151418 <file src =" apps/files_external/ajax/oauth2.php" >
You can’t perform that action at this time.
0 commit comments