~fkooman/vpn-user-portal

ref: 2.3.10 vpn-user-portal/src/OAuthClientInfo.php -rw-r--r-- 4.7 KiB
e0bd9cc0François Kooman prepare for release 1 year, 19 days 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<?php

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

namespace LC\Portal;

use fkooman\OAuth\Server\ClientInfo;

class OAuthClientInfo
{
    /**
     * @param string $clientId
     *
     * @return false|\fkooman\OAuth\Server\ClientInfo
     */
    public static function getClient($clientId)
    {
        $clientInfo = [
            // Windows
            'org.eduvpn.app.windows' => [
                'redirect_uri_list' => [
                    'http://127.0.0.1:{PORT}/callback',
                    'http://[::1]:{PORT}/callback',
                ],
                'display_name' => 'eduVPN for Windows',
                'require_approval' => true,
            ],
            // Windows (LC)
            'org.letsconnect-vpn.app.windows' => [
                'redirect_uri_list' => [
                    'http://127.0.0.1:{PORT}/callback',
                    'http://[::1]:{PORT}/callback',
                ],
                'display_name' => 'Let\'s Connect! for Windows',
                'require_approval' => true,
            ],
            // Android
            'org.eduvpn.app.android' => [
                'redirect_uri_list' => [
                    'org.eduvpn.app:/api/callback',
                    'https://android.app.eduvpn.org/api/callback',  // Android >= 6
                ],
                'display_name' => 'eduVPN for Android',
                'require_approval' => true,
            ],
            // Android (LC)
            'org.letsconnect-vpn.app.android' => [
                'redirect_uri_list' => [
                    'org.letsconnect-vpn.app:/api/callback',
                    'https://android.app.letsconnect-vpn.org/api/callback',  // Android >= 6
                ],
                'display_name' => 'Let\'s Connect! for Android',
                'require_approval' => true,
            ],
            // iOS
            'org.eduvpn.app.ios' => [
                'redirect_uri_list' => [
                    'org.eduvpn.app.ios:/api/callback',
                    // current app store app uses the link below, keep it until
                    // it is no longer used
                    'https://ios.app.eduvpn.org/auth/app/redirect/',
                ],
                'display_name' => 'eduVPN for iOS',
                'require_approval' => true,
            ],
            // iOS (LC)
            'org.letsconnect-vpn.app.ios' => [
                'redirect_uri_list' => [
                    'org.letsconnect-vpn.app.ios:/api/callback',
                ],
                'display_name' => 'Let\'s Connect! for iOS',
                'require_approval' => true,
            ],
            // macOS
            'org.eduvpn.app.macos' => [
                'redirect_uri_list' => [
                    'org.eduvpn.app:/api/callback',
                    'http://127.0.0.1:{PORT}/callback',
                    'http://[::1]:{PORT}/callback',
                ],
                'display_name' => 'eduVPN for macOS',
                'require_approval' => true,
            ],
            // macOS (LC)
            'org.letsconnect-vpn.app.macos' => [
                'redirect_uri_list' => [
                    'org.letsconnect-vpn.app:/api/callback',
                    'http://127.0.0.1:{PORT}/callback',
                    'http://[::1]:{PORT}/callback',
                ],
                'display_name' => 'Let\'s Connect! for macOS',
                'require_approval' => true,
            ],
            // Linux
            'org.eduvpn.app.linux' => [
                'redirect_uri_list' => [
                    'org.eduvpn.app:/api/callback',
                    'http://127.0.0.1:{PORT}/callback',
                    'http://[::1]:{PORT}/callback',
                ],
                'display_name' => 'eduVPN for Linux',
                'require_approval' => true,
            ],
            // Linux (LC)
            'org.letsconnect-vpn.app.linux' => [
                'redirect_uri_list' => [
                    'org.letsconnect-vpn.app:/api/callback',
                    'http://127.0.0.1:{PORT}/callback',
                    'http://[::1]:{PORT}/callback',
                ],
                'display_name' => 'Let\'s Connect! for Linux',
                'require_approval' => true,
            ],
        ];

        if (!\array_key_exists($clientId, $clientInfo)) {
            return false;
        }

        return new ClientInfo(
            $clientId,
            $clientInfo[$clientId]['redirect_uri_list'],
            null, // no predefined clients have a secret
            $clientInfo[$clientId]['display_name'],
            $clientInfo[$clientId]['require_approval']
        );
    }
}