Skip to content

Commit

Permalink
Refactor API Auth to support other identifiers
Browse files Browse the repository at this point in the history
- not just X.509, we want to allow OIDC based access to the
  API.
  • Loading branch information
gregcorbett committed Jul 8, 2022
1 parent f780966 commit 7593956
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion htdocs/PI/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ function authByCert() {
// Check if it is registered API Authentication credential.

$authEntServ = \Factory::getAPIAuthenticationService();
$authEnt = $authEntServ->getAPIAuthentication($this->dn, "X509");
$authEnt = $authEntServ->getAPIAuthentication($this->dn);

if (!is_null($authEnt)) {
$authEntServ->updateLastUseTime($authEnt);
Expand Down
6 changes: 2 additions & 4 deletions lib/Gocdb_Services/APIAuthenticationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,19 @@ function __construct() {
* Returns the APIAuthentication entity associated with the given identifier.
*
* @param string $ident Identifier (e.g. X.509 DN as string)
* @param string $type Identifyer type (e.g. "X509")
* @return \APIAuthentication APIAuthentication associated with this identifier
*/
public function getAPIAuthentication($ident, $type) {
public function getAPIAuthentication($ident) {

if (!is_string($ident)) {
throw new \LogicException("Expected string APIAuthentication identifier.");
}

$dql = "SELECT a FROM APIAuthentication a " .
"WHERE (a.identifier = :ident AND a.type = :type)" ;
"WHERE (a.identifier = :ident)" ;

$qry = $this->em->createQuery($dql);
$qry->setParameter('ident', $ident);
$qry->setParameter('type', $type);

$apiAuth = $qry->getOneOrNullResult();

Expand Down

0 comments on commit 7593956

Please sign in to comment.