Skip to content
<?php
/*
* This file is part of rap
* Copyright (C) 2021 Istituto Nazionale di Astrofisica
* SPDX-License-Identifier: GPL-3.0-or-later
*/
namespace RAP;
class MySQLAccessTokenDAO extends BaseMySQLDAO implements AccessTokenDAO {
......
<?php
/*
* This file is part of rap
* Copyright (C) 2021 Istituto Nazionale di Astrofisica
* SPDX-License-Identifier: GPL-3.0-or-later
*/
namespace RAP;
class MySQLJWKSDAO extends BaseMySQLDAO implements JWKSDAO {
......@@ -12,13 +18,16 @@ class MySQLJWKSDAO extends BaseMySQLDAO implements JWKSDAO {
$dbh = $this->getDBHandler();
$query = "INSERT INTO rsa_keypairs(id, private_key, public_key, alg) VALUES (:id, :private_key, :public_key, :alg)";
$query = "INSERT INTO rsa_keypairs(id, private_key, public_key, alg, creation_time) VALUES (:id, :private_key, :public_key, :alg, :creation_time)";
$now = time();
$stmt = $dbh->prepare($query);
$stmt->bindParam(':id', $keyPair->keyId);
$stmt->bindParam(':private_key', $keyPair->privateKey);
$stmt->bindParam(':public_key', $keyPair->publicKey);
$stmt->bindParam(':alg', $keyPair->alg);
$stmt->bindParam(':creation_time', $now);
$stmt->execute();
......@@ -85,48 +94,4 @@ class MySQLJWKSDAO extends BaseMySQLDAO implements JWKSDAO {
return $keyPair;
}
public function getAllPublicJWK(): array {
$dbh = $this->getDBHandler();
$query = "SELECT `kid`, `key`, `url`, `update_time` FROM public_jwk";
$stmt = $dbh->prepare($query);
$stmt->execute();
$keys = [];
foreach ($stmt->fetchAll() as $row) {
array_push($keys, $this->getPublicJWKFromResultRow($row));
}
return $keys;
}
private function getPublicJWKFromResultRow($row): PublicJWK {
$jwk = new PublicJWK ();
$jwk->key = $row['key'];
$jwk->kid = $row['kid'];
$jwk->url = $row['url'];
$jwk->updateTime = $row['update_time'];
return $jwk;
}
public function updatePublicJWK(PublicJWK $jwk) {
$dbh = $this->getDBHandler();
$query = "INSERT INTO public_jwk(kid, `key`, `url`, update_time) VALUES (:kid, :key, :url, :update_time)"
. " ON DUPLICATE KEY UPDATE `key`=:key, `url`=:url, update_time=:update_time";
$stmt = $dbh->prepare($query);
$stmt->bindParam(':kid', $jwk->kid);
$stmt->bindParam(':key', $jwk->key);
$stmt->bindParam(':url', $jwk->url);
$stmt->bindParam(':update_time', $jwk->updateTime);
$stmt->execute();
}
}
<?php
/*
* This file is part of rap
* Copyright (C) 2021 Istituto Nazionale di Astrofisica
* SPDX-License-Identifier: GPL-3.0-or-later
*/
namespace RAP;
class MySQLRefreshTokenDAO extends BaseMySQLDAO implements RefreshTokenDAO {
......
<?php
/* ----------------------------------------------------------------------------
* INAF - National Institute for Astrophysics
* IRA - Radioastronomical Institute - Bologna
* OATS - Astronomical Observatory - Trieste
* ----------------------------------------------------------------------------
*
/*
* This file is part of rap
* Copyright (C) 2016 Istituto Nazionale di Astrofisica
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License Version 3 as published by the
* Free Software Foundation.
*
* 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 General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* SPDX-License-Identifier: GPL-3.0-or-later
*/
namespace RAP;
......
<?php
/*
* This file is part of rap
* Copyright (C) 2021 Istituto Nazionale di Astrofisica
* SPDX-License-Identifier: GPL-3.0-or-later
*/
namespace RAP;
class BadRequestException extends \Exception {
......
<?php
/*
* This file is part of rap
* Copyright (C) 2021 Istituto Nazionale di Astrofisica
* SPDX-License-Identifier: GPL-3.0-or-later
*/
namespace RAP;
class ServerErrorException extends \Exception {
......
<?php
/*
* This file is part of rap
* Copyright (C) 2021 Istituto Nazionale di Astrofisica
* SPDX-License-Identifier: GPL-3.0-or-later
*/
namespace RAP;
class UnauthorizedException extends \Exception {
......
<?php
/*
* This file is part of rap
* Copyright (C) 2021 Istituto Nazionale di Astrofisica
* SPDX-License-Identifier: GPL-3.0-or-later
*/
namespace RAP;
class FacebookLogin extends LoginHandler {
......
<?php
/*
* This file is part of rap
* Copyright (C) 2021 Istituto Nazionale di Astrofisica
* SPDX-License-Identifier: GPL-3.0-or-later
*/
namespace RAP;
class GmsClient {
......
<?php
/*
* This file is part of rap
* Copyright (C) 2021 Istituto Nazionale di Astrofisica
* SPDX-License-Identifier: GPL-3.0-or-later
*/
namespace RAP;
class GoogleLogin extends LoginHandler {
......
<?php
/*
* This file is part of rap
* Copyright (C) 2021 Istituto Nazionale di Astrofisica
* SPDX-License-Identifier: GPL-3.0-or-later
*/
namespace RAP;
class LinkedInLogin extends LoginHandler {
......
<?php
/*
* This file is part of rap
* Copyright (C) 2021 Istituto Nazionale di Astrofisica
* SPDX-License-Identifier: GPL-3.0-or-later
*/
namespace RAP;
/**
......
<?php
/*
* This file is part of rap
* Copyright (C) 2021 Istituto Nazionale di Astrofisica
* SPDX-License-Identifier: GPL-3.0-or-later
*/
namespace RAP;
class OrcidLogin extends LoginHandler {
......
<?php
/*
* This file is part of rap
* Copyright (C) 2021 Istituto Nazionale di Astrofisica
* SPDX-License-Identifier: GPL-3.0-or-later
*/
namespace RAP;
class ShibbolethLogin extends LoginHandler {
......@@ -17,8 +23,8 @@ class ShibbolethLogin extends LoginHandler {
// Search if the user is already registered into RAP using the eppn.
// The persistent id should be a more appropriate identifier, however at IA2
// we need to import all INAF user into RAP, even if they will never register,
// and in that case we know only their eppn.
// we need to import all INAF users into RAP, even if they will never register,
// and in that case we only know their eppn.
$identity = new Identity(Identity::EDU_GAIN);
$identity->typedId = $eppn;
$identity->email = $_SERVER['mail'];
......
<?php
/*
* This file is part of rap
* Copyright (C) 2021 Istituto Nazionale di Astrofisica
* SPDX-License-Identifier: GPL-3.0-or-later
*/
namespace RAP;
class TestLogin extends LoginHandler {
private $fakeIdentities = [];
public function __construct(Locator $locator) {
parent::__construct($locator);
// Create fake identities
$this->fakeIdentities[1] = $this->getFakeIdentity(Identity::EDU_GAIN, 1);
$this->fakeIdentities[2] = $this->getFakeIdentity(Identity::GOOGLE, 2);
$this->fakeIdentities[3] = $this->getFakeIdentity(Identity::LINKEDIN, 3);
}
public function login(): string {
return $this->locator->getBasePath() . '/auth/test/select';
}
public function retrieveToken(int $id): string {
return $this->onIdentityDataReceived($this->fakeIdentities[$id]);
}
private function getFakeIdentity(string $type, int $i): Identity {
$identity = new Identity($type);
$identity->email = 'fake-user' . $i . "@example.com";
$identity->eppn = $identity->email;
$identity->typedId = 'fake-user' . $i;
return $identity;
}
}
<?php
/*
* This file is part of rap
* Copyright (C) 2021 Istituto Nazionale di Astrofisica
* SPDX-License-Identifier: GPL-3.0-or-later
*/
namespace RAP;
class X509Login extends LoginHandler {
......
<?php
/*
* This file is part of rap
* Copyright (C) 2021 Istituto Nazionale di Astrofisica
* SPDX-License-Identifier: GPL-3.0-or-later
*/
namespace RAP;
/**
......
<?php
/*
* This file is part of rap
* Copyright (C) 2021 Istituto Nazionale di Astrofisica
* SPDX-License-Identifier: GPL-3.0-or-later
*/
namespace RAP;
/**
......@@ -15,6 +21,7 @@ class AuthPageModel {
public $facebook;
public $linkedIn;
public $localIdP;
public $test;
//
public $clientIcon;
public $clientTitle;
......@@ -58,6 +65,9 @@ class AuthPageModel {
$this->localIdP = isset($config->authenticationMethods->LocalIdP) &&
in_array(AuthenticationMethods::LOCAL_IDP, $client->authMethods);
$this->test = isset($config->authenticationMethods->test) &&
$config->authenticationMethods->test;
}
}
<?php
/*
* This file is part of rap
* Copyright (C) 2021 Istituto Nazionale di Astrofisica
* SPDX-License-Identifier: GPL-3.0-or-later
*/
namespace RAP;
abstract class AuthenticationMethods {
......
<?php
/*
* This file is part of rap
* Copyright (C) 2021 Istituto Nazionale di Astrofisica
* SPDX-License-Identifier: GPL-3.0-or-later
*/
namespace RAP;
/**
......