* License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ require_once sprintf('%s/vendor/autoload.php', dirname(__DIR__)); use SURFnet\VPN\Server\TwoFactor; use SURFnet\VPN\Common\Logger; use SURFnet\VPN\Server\OtpLog; use SURFnet\VPN\Server\Exception\TwoFactorException; $logger = new Logger(basename($argv[0])); $envData = []; try { $envKeys = ['INSTANCE_ID', 'POOL_ID', 'common_name', 'username', 'password']; // read environment variables foreach ($envKeys as $envKey) { $envValue = getenv($envKey); if (empty($envValue)) { throw new RuntimeException(sprintf('environment variable "%s" is not set', $envKey)); } $envData[$envKey] = $envValue; } $otpLog = new OtpLog(new PDO(sprintf('sqlite://%s/openvpn-data/%s/otp.sqlite', dirname(__DIR__), $envData['INSTANCE_ID']))); $connection = new TwoFactor(dirname(__DIR__), $otpLog); $connection->twoFactor($envData); $envData['ok'] = true;
use SURFnet\VPN\Common\Config; use SURFnet\VPN\Common\Http\FormAuthenticationHook; use SURFnet\VPN\Common\Http\FormAuthenticationModule; use SURFnet\VPN\Common\Http\HtmlResponse; use SURFnet\VPN\Common\Http\MellonAuthenticationHook; use SURFnet\VPN\Common\Http\NoCacheHook; use SURFnet\VPN\Common\Http\ReferrerCheckHook; use SURFnet\VPN\Common\Http\Request; use SURFnet\VPN\Common\Http\Service; use SURFnet\VPN\Common\Http\Session; use SURFnet\VPN\Common\Http\TwoFactorHook; use SURFnet\VPN\Common\Http\TwoFactorModule; use SURFnet\VPN\Common\HttpClient\GuzzleHttpClient; use SURFnet\VPN\Common\HttpClient\ServerClient; use SURFnet\VPN\Common\Logger; $logger = new Logger('vpn-admin-portal'); try { $request = new Request($_SERVER, $_GET, $_POST); if (false === ($instanceId = getenv('VPN_INSTANCE_ID'))) { $instanceId = $request->getServerName(); } $dataDir = sprintf('%s/data/%s', dirname(__DIR__), $instanceId); if (!file_exists($dataDir)) { if (false === @mkdir($dataDir, 0700, true)) { throw new RuntimeException(sprintf('unable to create folder "%s"', $dataDir)); } } $config = Config::fromFile(sprintf('%s/config/%s/config.yaml', dirname(__DIR__), $instanceId)); $templateDirs = [sprintf('%s/views', dirname(__DIR__)), sprintf('%s/config/%s/views', dirname(__DIR__), $instanceId)]; $templateCache = null; if ($config->v('enableTemplateCache')) {