Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
11 changes: 7 additions & 4 deletions auth/provider/auth_oidc.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class auth_oidc extends \phpbb\auth\provider\base
private $redirectUrl;
private $workaroundRed;
private $workaroundLogout;
private $acpLogin;

/**
* OIDC Authentication Constructor
Expand Down Expand Up @@ -66,6 +67,8 @@ public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\config
//$this->workaroundRed = 'workaround';//$this->redirectUrl."/workaround";
$red = $this->oidc->getRedirectUrl();
if ($this->dbg()) echo "\n final redirect: $red";
//Check if we're in the ACP
$this->acpLogin = strstr($_SERVER['REQUEST_URI'], "adm");
}

/**
Expand Down Expand Up @@ -103,7 +106,7 @@ public function autologin()
}
$login_called = $_GET['login'];

if ($this->passToOidc())
if ($this->passToOidc() && !$this->acpLogin)
{
$this->workaroundLogout = false;
return $this->oidcLogin();
Expand Down Expand Up @@ -144,7 +147,7 @@ private function oidcLogin()
$oidcUser = new OIDCUser($this->oidc->requestUserInfo());

/* If user does not already exist */
if (!$this->userService->userExists($oidcUser->getPreferredUsername())) {
if (!$this->userService->userExists(preg_replace('/@.*\..*/','',$oidcUser->getPreferredUsername()))) {

/* If configuration allows, create new user */
if ($this->pluginConfig['createIfMissing']) {
Expand All @@ -157,7 +160,7 @@ private function oidcLogin()

} else {
$this->userService->updateUser($oidcUser);
return $this->userService->getUserRow($oidcUser->getPreferredUsername());
return $this->userService->getUserRow(preg_replace('/@.*\..*/','',$oidcUser->getPreferredUsername()));
}
}

Expand All @@ -171,7 +174,7 @@ private function passToOidc()
if ($this->dbg()) echo " called page: $page";
$mode=$_GET['mode'];
$ucp_login= false; //($mode=='login'); //TODO consider all pages with mode=login parameter as login page
$callback_oidc=$_GET['state'] && $_GET['session_state'] && $_GET['code']; //TODO the callback from keycloak to phpbb with login information
$callback_oidc=$_GET['state'] && $_GET['code']; //TODO the callback from keycloak to phpbb with login information
$called_getLogin=($this->workaroundLogout);
if ($this->dbg()) echo " called get_login= $called_getLogin";
return ($ucp_login || $callback_oidc || $called_getLogin);
Expand Down
11 changes: 8 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,19 @@
}
],
"require": {
"jumbojett/openid-connect-php": "^0.7.0",
"php": ">=5.4.0",
"jumbojett/openid-connect-php": "^1.0.2",
"php": ">=7.4.0",
"composer/installers": "~1.0"
},
"extra": {
"display-name": "phpBB OIDC auth",
"soft-require": {
"phpbb/phpbb": "~3.2"
}
},
"config": {
"allow-plugins": {
"composer/installers": true
}
}
}
}
Loading