diff --git a/htdocs/web_portal/components/Get_User_Principle.php b/htdocs/web_portal/components/Get_User_Principle.php
index 98c64a004..b46f8abb1 100644
--- a/htdocs/web_portal/components/Get_User_Principle.php
+++ b/htdocs/web_portal/components/Get_User_Principle.php
@@ -116,7 +116,12 @@ function Get_User_AuthToken(){
MyStaticAuthTokenHolder::getInstance()->setAuthToken($auth);
return $auth;
}
- return null;
+
+ // We don't want the portal to be exposed without authentication (even
+ // though no actual info is displayed to an unauthenticated user),
+ // so if we have not set the principle/userDetails,
+ // re-direct to our Discovery Service.
+ redirectUserToDiscoveryPage();
}
/**
@@ -190,7 +195,12 @@ function Get_User_Principle(){
}
return $principleString;
}
- return null;
+
+ // We don't want the portal to be exposed without authentication (even
+ // though no actual info is displayed to an unauthenticated user),
+ // so if we have not set the principle/userDetails,
+ // re-direct to our Discovery Service.
+ redirectUserToDiscoveryPage();
}
/**
@@ -217,9 +227,21 @@ function Get_User_Principle_PI() {
}
}
+ # Returning null here is necessary, because parts of the API are exposed
+ # publically, without authentication.
return null;
}
+/*
+ * Prevent the current page from being loaded and redirect the user
+ * to the IdP discovery page (a.k.a the landing page).
+ */
+function redirectUserToDiscoveryPage()
+{
+ $url = \Factory::getConfigService()->getServerBaseUrl();
+ header("Location: " . $url);
+ die();
+}
diff --git a/lib/Authentication/AuthTokens/ShibAuthToken.php b/lib/Authentication/AuthTokens/ShibAuthToken.php
index af6f9a9a2..727ca990e 100644
--- a/lib/Authentication/AuthTokens/ShibAuthToken.php
+++ b/lib/Authentication/AuthTokens/ShibAuthToken.php
@@ -79,11 +79,11 @@ public function getDetails() {
public function getPrinciple() {
return $this->principal;
}
-
-
-
+
+
+
private function getAttributesInitToken(){
- $hostname = $_SERVER['HTTP_HOST']; // don't use $_SERVER['SERVER_NAME'] as this don't support DNS
+ $hostname = $_SERVER['HTTP_HOST']; // don't use $_SERVER['SERVER_NAME'] as this don't support DNS
// specify location of the Shib Logout handler
\Factory::$properties['LOGOUTURL'] = 'https://'.$hostname.'/Shibboleth.sso/Logout';
$idp = isset($_SERVER['Shib-Identity-Provider']) ? $_SERVER['Shib-Identity-Provider'] : '';
@@ -152,8 +152,8 @@ private function getAttributesInitToken(){
}
if(empty($_SERVER['entitlement'])){
die('Did not receive the required entitlement attribute from the EGI Dev Proxy IdP, please contact gocdb-admins');
- }
- $entitlementValuesArray = explode(';', $_SERVER['entitlement']);
+ }
+ $entitlementValuesArray = explode(';', $_SERVER['entitlement']);
if( !in_array('urn:mace:egi.eu:res:gocdb#aai.egi.eu', $entitlementValuesArray) ){
$HTML = '
";
@@ -166,6 +166,46 @@ private function getAttributesInitToken(){
$this->userDetails = array('AuthenticationRealm' => array('EGI Proxy IdP'));
return;
}
+ else if($idp == 'https://aai-demo.eosc-portal.eu/proxy/saml2/idp/metadata.php'){
+ if( empty($_SERVER['voPersonID'])){
+ die('Did not receive required voPersonID attributes from the EOSC Demo Proxy Identity Provider to complete authentication, please contact gocdb-admins');
+ }
+ if(empty($_SERVER['entitlement'])){
+ die('Did not receive the required entitlement attribute from the EOSC Demo Proxy Identity Provider, please contact gocdb-admins');
+ }
+ $entitlementValuesArray = explode(';', $_SERVER['entitlement']);
+ if( !in_array('urn:geant:eosc-portal.eu:res:gocdb.eosc-portal.eu', $entitlementValuesArray) ){
+ $HTML = '
- You authenticated to the EOSC Demo Proxy Identity Provider using a method that does not provide a GOCDB entitlement.
- Login is required with a GOCDB entitlement.
- To gain access, you will need to login to the Proxy IdP using a scheme that provides a gocdb entitlement.
- Please logout or restart your browser and attempt to login again.
';
+ $HTML .= "
";
+ $HTML .= '
Logout';
+ $HTML .= "
";
+ echo ($HTML);
+ die();
+ }
+ $this->principal = $_SERVER['voPersonID'];
+ $this->userDetails = array('AuthenticationRealm' => array('EOSC Demo Proxy IdP'));
+ return;
+ }
+ else if($idp == 'https://aai.eosc-portal.eu/proxy/saml2/idp/metadata.php'){
+ if( empty($_SERVER['voPersonID'])){
+ die('Did not receive required voPersonID attributes from the EOSC Proxy Identity Provider to complete authentication, please contact gocdb-admins');
+ }
+ if(empty($_SERVER['entitlement'])){
+ die('Did not receive the required entitlement attribute from the EOSC Proxy Identity Provider, please contact gocdb-admins');
+ }
+ $entitlementValuesArray = explode(';', $_SERVER['entitlement']);
+ if( !in_array('urn:geant:eosc-portal.eu:res:gocdb.eosc-portal.eu', $entitlementValuesArray) ){
+ $HTML = '
- You authenticated to the EOSC Proxy Identity Provider using a method that does not provide a GOCDB entitlement.
- Login is required with a GOCDB entitlement.
- To gain access, you will need to login to the Proxy IdP using a scheme that provides a gocdb entitlement.
- Please logout or restart your browser and attempt to login again.
';
+ $HTML .= "
";
+ $HTML .= '
Logout';
+ $HTML .= "
";
+ echo ($HTML);
+ die();
+ }
+ $this->principal = $_SERVER['voPersonID'];
+ $this->userDetails = array('AuthenticationRealm' => array('EOSC Proxy IdP'));
+ return;
+ }
}
/**
diff --git a/lib/Gocdb_Services/PI/GetNGIContacts.php b/lib/Gocdb_Services/PI/GetNGIContacts.php
index b094791c3..ed0fdb410 100644
--- a/lib/Gocdb_Services/PI/GetNGIContacts.php
+++ b/lib/Gocdb_Services/PI/GetNGIContacts.php
@@ -285,6 +285,7 @@ private function getXML(){
$xmlContact->addChild('CERTDN', $serv->getIdStringByAuthType($user, 'X.509'));
$xmlContact->addChild('EGICHECKIN', $serv->getIdStringByAuthType($user, 'EGI Proxy IdP'));
$xmlContact->addChild('IRISIAM', $serv->getIdStringByAuthType($user, 'IRIS IAM - OIDC'));
+ $xmlContact->addChild('EOSCAAI', $serv->getIdStringByAuthType($user, 'EOSC Proxy IdP'));
} else {
$xmlContact->addChild('CERTDN', $serv->getDefaultIdString($user));
}
@@ -359,4 +360,4 @@ public function getPostExecutionPageInfo(){
$pageInfo['count'] = $this->resultSetSize;
return $pageInfo;
}
-}
\ No newline at end of file
+}
diff --git a/lib/Gocdb_Services/PI/GetProjectContacts.php b/lib/Gocdb_Services/PI/GetProjectContacts.php
index 9b3e1e191..61165a032 100644
--- a/lib/Gocdb_Services/PI/GetProjectContacts.php
+++ b/lib/Gocdb_Services/PI/GetProjectContacts.php
@@ -264,6 +264,7 @@ private function getXML(){
$xmlContact->addChild('CERTDN', $serv->getIdStringByAuthType($user, 'X.509'));
$xmlContact->addChild('EGICHECKIN', $serv->getIdStringByAuthType($user, 'EGI Proxy IdP'));
$xmlContact->addChild('IRISIAM', $serv->getIdStringByAuthType($user, 'IRIS IAM - OIDC'));
+ $xmlContact->addChild('EOSCAAI', $serv->getIdStringByAuthType($user, 'EOSC Proxy IdP'));
} else {
$xmlContact->addChild('CERTDN', $serv->getDefaultIdString($user));
}
@@ -339,4 +340,4 @@ public function getPostExecutionPageInfo(){
$pageInfo['count'] = $this->resultSetSize;
return $pageInfo;
}
-}
\ No newline at end of file
+}
diff --git a/lib/Gocdb_Services/PI/GetServiceGroupRole.php b/lib/Gocdb_Services/PI/GetServiceGroupRole.php
index 807815537..a80fef2fb 100644
--- a/lib/Gocdb_Services/PI/GetServiceGroupRole.php
+++ b/lib/Gocdb_Services/PI/GetServiceGroupRole.php
@@ -299,6 +299,7 @@ private function getXML(){
$xmlUser->addChild ( 'CERTDN', $serv->getIdStringByAuthType ( $user, 'X.509' ) );
$xmlUser->addChild ( 'EGICHECKIN', $serv->getIdStringByAuthType ( $user, 'EGI Proxy IdP' ) );
$xmlUser->addChild ( 'IRISIAM', $serv->getIdStringByAuthType ( $user, 'IRIS IAM - OIDC' ) );
+ $xmlUser->addChild('EOSCAAI', $serv->getIdStringByAuthType($user, 'EOSC Proxy IdP'));
} else {
$xmlUser->addChild ( 'CERTDN', $serv->getDefaultIdString ( $user ) );
}
@@ -374,4 +375,4 @@ public function getPostExecutionPageInfo(){
$pageInfo['count'] = $this->resultSetSize;
return $pageInfo;
}
-}
\ No newline at end of file
+}
diff --git a/lib/Gocdb_Services/PI/GetSiteContacts.php b/lib/Gocdb_Services/PI/GetSiteContacts.php
index 429e684b8..8648aac6a 100644
--- a/lib/Gocdb_Services/PI/GetSiteContacts.php
+++ b/lib/Gocdb_Services/PI/GetSiteContacts.php
@@ -315,6 +315,7 @@ private function getXML(){
$xmlContact->addChild ( 'CERTDN', $serv->getIdStringByAuthType ( $user, 'X.509' ) );
$xmlContact->addChild ( 'EGICHECKIN', $serv->getIdStringByAuthType ( $user, 'EGI Proxy IdP' ) );
$xmlContact->addChild ( 'IRISIAM', $serv->getIdStringByAuthType ( $user, 'IRIS IAM - OIDC' ) );
+ $xmlContact->addChild('EOSCAAI', $serv->getIdStringByAuthType($user, 'EOSC Proxy IdP'));
} else {
$xmlContact->addChild ( 'CERTDN', $serv->getDefaultIdString ( $user ) );
}
@@ -388,4 +389,4 @@ public function getPostExecutionPageInfo(){
$pageInfo['count'] = $this->resultSetSize;
return $pageInfo;
}
-}
\ No newline at end of file
+}
diff --git a/lib/Gocdb_Services/PI/GetUser.php b/lib/Gocdb_Services/PI/GetUser.php
index 3e0ab0adb..59c6c3e3d 100644
--- a/lib/Gocdb_Services/PI/GetUser.php
+++ b/lib/Gocdb_Services/PI/GetUser.php
@@ -306,6 +306,7 @@ private function getXML() {
$xmlUser->addChild('CERTDN', $serv->getIdStringByAuthType($user, 'X.509'));
$xmlUser->addChild('EGICHECKIN', $serv->getIdStringByAuthType($user, 'EGI Proxy IdP'));
$xmlUser->addChild('IRISIAM', $serv->getIdStringByAuthType($user, 'IRIS IAM - OIDC'));
+ $xmlUser->addChild('EOSCAAI', $serv->getIdStringByAuthType($user, 'EOSC Proxy IdP'));
} else {
$xmlUser->addChild('CERTDN', $serv->getDefaultIdString($user));
}
diff --git a/lib/Gocdb_Services/User.php b/lib/Gocdb_Services/User.php
index c926e8e7f..f46156600 100644
--- a/lib/Gocdb_Services/User.php
+++ b/lib/Gocdb_Services/User.php
@@ -490,9 +490,9 @@ public function getAuthTypes($reducedRealms=true) {
// Hardcoded authentication realms in same order as in token definitions
$x509Realms = ['X.509'];
if ($reducedRealms) {
- $shibRealms = ['EGI Proxy IdP'];
+ $shibRealms = ['EGI Proxy IdP', 'EOSC Proxy IdP'];
} else {
- $shibRealms = ['EUDAT_SSO_IDP', 'UK_ACCESS_FED', 'EGI Proxy IdP'];
+ $shibRealms = ['EUDAT_SSO_IDP', 'UK_ACCESS_FED', 'EGI Proxy IdP', 'EOSC Proxy IdP'];
}
$irisRealms = ['IRIS IAM - OIDC'];
@@ -721,9 +721,6 @@ protected function addUserIdentifierValidation($keyName, $keyValue) {
// Check the ID string does not already exist
$this->valdidateUniqueIdString($keyValue);
-
- // Check auth type is valid
- $this->valdidateAuthType($keyName);
}
/**
@@ -808,9 +805,6 @@ protected function editUserIdentifierValidation(\User $user, \UserIdentifier $id
$this->valdidateUniqueIdString($keyValue);
}
- // Check auth type is valid
- $this->valdidateAuthType($keyName);
-
// If the identifiers key has changed, check there isn't an existing identifier with that key
if ($keyName !== $identifier->getKeyName()) {
$existingIdentifiers = $user->getUserIdentifiers();
@@ -822,17 +816,6 @@ protected function editUserIdentifierValidation(\User $user, \UserIdentifier $id
}
}
- /**
- * Validate authentication type based on known list.
- * @param string $authType
- * @throws \Exception
- */
- protected function valdidateAuthType($authType) {
- if (!in_array($authType, $this->getAuthTypes(false))) {
- throw new \Exception("The authentication type entered is invalid");
- }
- }
-
/**
* Validate ID string is unique.
* Checks both user identifiers and certificateDns