~fkooman/vpn-user-portal

ref: 95ea2e8af7075e5438c55710dd89d3d76a72504b vpn-user-portal/web/well-known.php -rw-r--r-- 1.5 KiB
95ea2e8aFrançois Kooman remove config in well-known.php 3 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php

/*
 * eduVPN - End-user friendly VPN.
 *
 * Copyright: 2016-2019, The Commons Conservancy eduVPN Programme
 * SPDX-License-Identifier: AGPL-3.0+
 */

require_once dirname(__DIR__).'/vendor/autoload.php';
$baseDir = dirname(__DIR__);

use LC\Common\FileIO;
use LC\Common\Http\JsonResponse;
use LC\Common\Http\Request;

try {
    $request = new Request($_SERVER, $_GET, $_POST);

    if (false === $appRoot = getenv('VPN_APP_ROOT')) {
        $appRootUri = sprintf('%s://%s', $request->getScheme(), $request->getAuthority());
    } else {
        $appRootUri = sprintf('%s://%s%s', $request->getScheme(), $request->getAuthority(), $appRoot);
    }

    $jsonData = [
        'api' => [
            'http://eduvpn.org/api#2' => [
                'api_base_uri' => $appRootUri.'/api.php',
                'authorization_endpoint' => $appRootUri.'/_oauth/authorize',
                'token_endpoint' => $appRootUri.'/oauth.php/token',
            ],
            'http://eduvpn.org/api#3' => [
                'api_endpoint' => $appRootUri.'/api.php/v3',
                'authorization_endpoint' => $appRootUri.'/_oauth/authorize',
                'token_endpoint' => $appRootUri.'/oauth.php/token',
            ],
        ],
        'v' => trim(FileIO::readFile(sprintf('%s/VERSION', $baseDir))),
    ];

    $response = new JsonResponse($jsonData);
    $response->addHeader('Cache-Control', 'no-store');
    $response->send();
} catch (Exception $e) {
    $response = new JsonResponse(['error' => $e->getMessage()], 500);
    $response->send();
}