Welcome to GOCDB
Use of GOCDB is governed by the EGI Acceptable Use Policy which places restrictions on your use of the service.
The GOCDB Privacy Notice describes what personal data is collected and why, and your rights regarding this data.
Please read these documents before accessing GOCDB.
- Access GOCDB
+
+
diff --git a/htdocs/web_portal/components/Get_User_Principle.php b/htdocs/web_portal/components/Get_User_Principle.php
index 15af58eca..efbc20fe2 100644
--- a/htdocs/web_portal/components/Get_User_Principle.php
+++ b/htdocs/web_portal/components/Get_User_Principle.php
@@ -162,21 +162,29 @@ function Get_User_Principle(){
}
/**
- * Get the DN from an x509 cert or null if a user certificate can't be loaded.
- * Called from the PI to authenticate requests using certificates only.
+ * Get the DN from an x509 cert, Principle from oidc token, or null if neither can be loaded.
+ * Called from the PI to authenticate requests using certificates or oidc.
* @return string or null if can't authenticate request
*/
function Get_User_Principle_PI() {
$fwMan = \org\gocdb\security\authentication\FirewallComponentManager::getInstance();
$firewallArray = $fwMan->getFirewallArray();
- try {
+ try{
$x509Token = new org\gocdb\security\authentication\X509AuthenticationToken();
$auth = $firewallArray['fwC1']->authenticate($x509Token);
return $auth->getPrinciple();
} catch(org\gocdb\security\authentication\AuthenticationException $ex){
+ // failed auth, so attempt OIDC auth
+ try{
+ $token = new org\gocdb\security\authentication\IAMAuthToken();
+ $auth = $firewallArray['fwC1']->authenticate($token);
+ return $auth->getPrinciple();
+ } catch(org\gocdb\security\authentication\AuthenticationException $ex){
// failed auth, so return null and let calling page decide to allow
// access or not (some PI methods don't need to be authenticated with a cert)
+ }
}
+
return null;
}
diff --git a/htdocs/web_portal/controllers/site/add_api_auth.php b/htdocs/web_portal/controllers/site/add_api_auth.php
index bbf7cadaa..1dd9b51b9 100644
--- a/htdocs/web_portal/controllers/site/add_api_auth.php
+++ b/htdocs/web_portal/controllers/site/add_api_auth.php
@@ -59,6 +59,7 @@ function draw(\User $user = null, \Site $site = null) {
$params['site'] = $site;
$params['authTypes'] = array();
$params['authTypes'][]='X509';
+ $params['authTypes'][]='OIDC Subject';
show_view("site/add_api_auth.php", $params);
die();
diff --git a/htdocs/web_portal/controllers/site/edit_api_auth.php b/htdocs/web_portal/controllers/site/edit_api_auth.php
index 772c70120..3120cca85 100644
--- a/htdocs/web_portal/controllers/site/edit_api_auth.php
+++ b/htdocs/web_portal/controllers/site/edit_api_auth.php
@@ -61,6 +61,7 @@ function draw(\User $user = null, \APIAuthentication $authEnt = null, \Site $sit
$params['authEnt'] = $authEnt;
$params['authTypes'] = array();
$params['authTypes'][]='X509';
+ $params['authTypes'][]='OIDC Subject';
show_view("site/edit_api_auth.php", $params);
die();
diff --git a/htdocs/web_portal/controllers/user/register.php b/htdocs/web_portal/controllers/user/register.php
index 97e2902c4..6c76ba73d 100644
--- a/htdocs/web_portal/controllers/user/register.php
+++ b/htdocs/web_portal/controllers/user/register.php
@@ -56,10 +56,20 @@ function draw() {
die();
}
+ //Extract users email from oidc claims
+ $authDetails = $_SERVER['OIDC_CLAIM_external_authn'];
+ $startPos = 3+strpos($authDetails, ":", (strpos($authDetails, "MAIL")));
+ $endPos = strpos($authDetails, "\"", 3+$startPos);
+ $length = $endPos-$startPos;
+ $userEmail = substr($authDetails, $startPos, $length);
+
/* @var $authToken \org\gocdb\security\authentication\IAuthentication */
$authToken = Get_User_AuthToken();
$params['authAttributes'] = $authToken->getDetails();
+ $params['given_name'] = $_SERVER['OIDC_CLAIM_given_name'];
+ $params['family_name'] = $_SERVER['OIDC_CLAIM_family_name'];
+ $params['email'] = $userEmail;
$params['dn'] = $dn;
show_view('user/register.php', $params);
}
@@ -91,4 +101,4 @@ function submit() {
}
}
-?>
\ No newline at end of file
+?>
diff --git a/htdocs/web_portal/views/site/add_api_auth.php b/htdocs/web_portal/views/site/add_api_auth.php
index 063d8e344..005e710ac 100644
--- a/htdocs/web_portal/views/site/add_api_auth.php
+++ b/htdocs/web_portal/views/site/add_api_auth.php
@@ -4,7 +4,7 @@
Caution: it is possible to delete information using the write functionality of the API.