| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- <?php
- /* Forward root to /status */
- $app->get('', function ($request, $response, $args) {
- return $response
- ->withHeader('Location', '/api/v2/status')
- ->withStatus(302);
- });
- $app->get('/', function ($request, $response, $args) {
- return $response
- ->withHeader('Location', '/api/v2/status')
- ->withStatus(302);
- });
- $app->get('/status', function ($request, $response, $args) {
- /**
- * @OA\Get(
- * path="/api/v2/status",
- * summary="Query Organizr API to perform a Status Check",
- * @OA\Response(
- * response="200",
- * description="Success",
- * @OA\JsonContent(ref="#/components/schemas/status"),
- * ),
- * @OA\Response(response="401",description="Unauthorized")
- * )
- */
- $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
- if ($Organizr->checkRoute($request)) {
- $GLOBALS['api']['response']['data'] = array(
- 'status' => 'ok',
- 'api_version' => '2.0',
- 'organizr_version' => $Organizr->version
- );
- }
- $response->getBody()->write(jsonE($GLOBALS['api']));
- return $response
- ->withHeader('Content-Type', 'application/json;charset=UTF-8')
- ->withStatus($GLOBALS['responseCode']);
- });
- $app->any('/auth', function ($request, $response, $args) {
- /**
- * @OA\Get(
- * path="/api/v2/auth",
- * summary="Nginx auth_request",
- * @OA\Parameter(
- * name="group",
- * description="The id of the group allowed",
- * @OA\Schema(
- * type="integer",
- * format="int64",
- * ),
- * in="query",
- * required=false
- * ),
- * @OA\Parameter(
- * name="whitelist",
- * description="Whitelisted Ip's",
- * @OA\Schema(
- * type="array",
- * @OA\Items(
- * type="string",
- * ),
- * ),
- * in="query",
- * explode=false,
- * required=false
- * ),
- * @OA\Parameter(
- * name="blacklist",
- * description="Blacklisted Ip's",
- * @OA\Schema(
- * type="array",
- * @OA\Items(
- * type="string",
- * ),
- * ),
- * in="query",
- * explode=false,
- * required=false
- * ),
- * @OA\Response(
- * response="200",
- * description="Success",
- * ),
- * @OA\Response(response="401",description="Unauthorized"),
- * )
- */
- $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
- $Organizr->auth();
- $response->getBody()->write(jsonE($GLOBALS['api']));
- return $response
- ->withHeader('Content-Type', 'application/json;charset=UTF-8')
- ->withStatus($GLOBALS['responseCode']);
- });
- $app->any('/auth-{group}', function ($request, $response, $args) {
- $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
- $_GET['group'] = $args['group'];
- $Organizr->auth();
- $response->getBody()->write(jsonE($GLOBALS['api']));
- return $response
- ->withHeader('Content-Type', 'application/json;charset=UTF-8')
- ->withStatus($GLOBALS['responseCode']);
- });
- $app->any('/auth/[{group}[/{type}[/{ips}]]]', function ($request, $response, $args) {
- $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
- $_GET['group'] = $args['group'];
- $_GET['type'] = $args['type'];
- $_GET['ips'] = $args['ips'];
- $Organizr->auth();
- $response->getBody()->write(jsonE($GLOBALS['api']));
- return $response
- ->withHeader('Content-Type', 'application/json;charset=UTF-8')
- ->withStatus($GLOBALS['responseCode']);
- });
- $app->get('/launch', function ($request, $response, $args) {
- $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
- $tabInfo = $Organizr->getUserTabsAndCategories();
- $GLOBALS['api']['response']['data']['categories'] = ($tabInfo['categories']) ?? false;
- $GLOBALS['api']['response']['data']['tabs'] = ($tabInfo['tabs']) ?? false;
- $GLOBALS['api']['response']['data']['user'] = $Organizr->user;
- $GLOBALS['api']['response']['data']['branch'] = $Organizr->config['branch'];
- $GLOBALS['api']['response']['data']['theme'] = $Organizr->config['theme'];
- $GLOBALS['api']['response']['data']['style'] = $Organizr->config['style'];
- $GLOBALS['api']['response']['data']['version'] = $Organizr->version;
- $GLOBALS['api']['response']['data']['settings'] = $Organizr->organizrSpecialSettings();
- $GLOBALS['api']['response']['data']['plugins'] = $Organizr->pluginGlobalList();
- $GLOBALS['api']['response']['data']['appearance'] = $Organizr->loadAppearance();
- $GLOBALS['api']['response']['data']['status'] = $Organizr->status();
- $GLOBALS['api']['response']['data']['sso'] = $Organizr->ssoCookies();
- $response->getBody()->write(jsonE($GLOBALS['api']));
- return $response
- ->withHeader('Content-Type', 'application/json;charset=UTF-8')
- ->withStatus($GLOBALS['responseCode']);
-
- });
|