This repository has been archived by the owner on Jan 25, 2021. It is now read-only.
forked from vufind-org/vufind
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/NLimprovedBackChannel' into development
- Loading branch information
Showing
8 changed files
with
157 additions
and
111 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ national_licence_programme_group_id = 1d3baa7b-da70-440d-b777-5bb2d11f8718 | |
base_endpoint_url = https://eduid.ch/sg/index.php | ||
back_channel_param_entityID = https://eduid.ch/idp/shibboleth | ||
back_channel_endpoint_path = /Shibboleth.sso/AttributeResolver | ||
back_channel_endpoint_host = https://localhost | ||
schema_patch = urn:ietf:params:scim:api:messages:2.0:PatchOp | ||
operation_add = add | ||
operation_remove = remove | ||
|
@@ -13,7 +14,8 @@ allowed_mobile_prefixes[] = +41 79 | |
allowed_mobile_prefixes[] = +41 78 | ||
allowed_mobile_prefixes[] = +41 77 | ||
allowed_mobile_prefixes[] = +41 76 | ||
user_export_path = /local/export/nationalLicence | ||
allowed_mobile_prefixes[] = +41 75 | ||
user_export_path = /local/export/nationalLicencesUsers | ||
user_export_filename = user_export.csv | ||
user_export_default_email_address_to = [email protected] | ||
national_licence_user_fields_to_export[] = home_postal_address | ||
|
@@ -25,22 +27,14 @@ national_licence_user_fields_to_export[] = date_expiration | |
national_licence_user_fields_to_export[] = blocked | ||
national_licence_user_fields_to_export[] = active_last_12_month | ||
national_licence_user_fields_to_export[] = persistent_id | ||
national_licence_user_fields_to_export[] = mobile | ||
national_licence_user_fields_to_export[] = assurance_level | ||
vufind_user_fields_to_export[] = firstname | ||
vufind_user_fields_to_export[] = lastname | ||
vufind_user_fields_to_export[] = email | ||
request_account_extension_expiration_days = 30 | ||
temporary_access_expiration_days = 14 | ||
|
||
[EmailService] | ||
#Change with the production address | ||
default_email_address_from = [email protected] | ||
SmtpOptions.name = host | ||
#Change with production SMTP server host | ||
SmtpOptions.host = smtp.gmail.com | ||
SmtpOptions.port= 587 | ||
SmtpOptions.connection_class = login | ||
SmtpOptions.connection_config[ssl] = tls | ||
|
||
#Unit test configuration | ||
[Test] | ||
switchApi.external_id_test = [email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -164,8 +164,8 @@ protected function getBaseClient( | |
throw new \Exception( | ||
'Was not possible to find the SWITCH API ' . | ||
'credentials. Make sure you have correctly configured the ' . | ||
'"SWITCH_API_USER" and "SWITCH_API_PASSW" either in the ' . | ||
'apache setup or before launching the script.' | ||
'"SWITCH_API_USER" and "SWITCH_API_PASSW" in ' . | ||
'config.ini.' | ||
); | ||
|
||
} | ||
|
@@ -174,6 +174,38 @@ protected function getBaseClient( | |
return $client; | ||
} | ||
|
||
/** | ||
* Get an instance of the HTTP Client with some basic configuration | ||
* for shibboleth back-channel queries. | ||
* | ||
* @return Client | ||
* @throws \Exception | ||
*/ | ||
protected function getBaseClientBackChannel() | ||
{ | ||
$client = new Client( | ||
$this->configNL['back_channel_endpoint_host'] . | ||
$this->configNL['back_channel_endpoint_path'], [ | ||
'maxredirects' => 0, | ||
'timeout' => 30, | ||
'adapter' => 'Zend\Http\Client\Adapter\Curl', | ||
'curloptions' => [ | ||
CURLOPT_SSL_VERIFYHOST => false, | ||
CURLOPT_SSL_VERIFYPEER => false | ||
] | ||
] | ||
); | ||
$client->setHeaders( | ||
[ | ||
'Content-Type' => 'application/json', | ||
'Accept' => 'application/json', | ||
] | ||
); | ||
$client->setMethod(Request::METHOD_GET); | ||
|
||
return $client; | ||
} | ||
|
||
/** | ||
* Add user to the National Licenses Programme group on the National Licenses | ||
* registration platform. | ||
|
@@ -208,7 +240,7 @@ protected function addUserToNationalCompliantGroup($userInternalId) | |
], | ||
], | ||
]; | ||
$str = json_encode($params, JSON_PRETTY_PRINT); | ||
//$str = json_encode($params, JSON_PRETTY_PRINT); | ||
//echo "<pre> $str < /pre>"; | ||
$rawData = json_encode($params, JSON_UNESCAPED_SLASHES); | ||
$client->setRawBody($rawData); | ||
|
@@ -232,7 +264,6 @@ public function userIsOnNationalCompliantSwitchGroup($userExternalId) | |
{ | ||
$internalId = $this->createSwitchUser($userExternalId); | ||
$switchUser = $this->getSwitchUserInfo($internalId); | ||
$id = 'national_licence_programme_group_id'; | ||
foreach ($switchUser->groups as $group) { | ||
$v = $this->configNL['national_licence_programme_group_id']; | ||
if ($group->value === $v) { | ||
|
@@ -346,7 +377,8 @@ public function getUserUpdatedInformation($nameId, $persistentId) | |
'edu_id' => 'uniqueID', | ||
'home_postal_address' => 'homePostalAddress', | ||
'affiliation' => 'affiliation', | ||
'active_last_12_month' => 'swissEduIDUsage1y' | ||
'active_last_12_month' => 'swissEduIDUsage1y', | ||
'assurance_level' => 'swissEduIdAssuranceLevel' | ||
]; | ||
$userFieldsRelation = [ | ||
'username' => 'persistent-id', | ||
|
@@ -397,28 +429,53 @@ public function getUserUpdatedInformation($nameId, $persistentId) | |
*/ | ||
protected function getNationalLicenceUserCurrentInformation($nameId) | ||
{ | ||
//Make http request fro retrieve new edu-ID information usign the back- | ||
//channel api | ||
// @codingStandardsIgnoreStart | ||
/* | ||
* Make http request to retrieve new edu-ID information usign the back- | ||
* channel api | ||
* example : | ||
* | ||
* (very long line) | ||
* curl -k 'https://test.swissbib.ch/Shibboleth.sso/AttributeResolver?entityID=https%3A%2F%2Feduid.ch%2Fidp%2Fshibboleth&nameId=AaduBHpQXrRs9BJqQcB7aLXgWTI%3D&format=urn%3Aoasis%3Anames%3Atc%3ASAML%3A2.0%3Anameid-format%3Apersistent&encoding=JSON%2FCGI' | ||
* | ||
* answer : | ||
* { | ||
* "mobile" : "+41 79 200 00 00", | ||
* "swissLibraryPersonResidence" : "CH", | ||
* "homeOrganizationType" : "others", | ||
* "uniqueID" : "[email protected]", | ||
* "homeOrganization" : "eduid.ch", | ||
* "mail" : "[email protected]", | ||
* "persistent-id" : "https://eduid.ch/idp/shibboleth!https://test.swissbib.ch/shibboleth!AaduBHpQXrRs9BJqQcB7aLXgWTI=", | ||
* "swissEduIdAssuranceLevel" : "mobile:https://eduid.ch/def/loa2;mail:https://eduid.ch/def/loa2;homePostalAddress:https://eduid.ch/def/loa2", | ||
* "givenName" : "Hans", | ||
* "surname" : "Mustermann", | ||
* "homePostalAddress" : "Rue Neuve 5$1222 Geneve$Switzerland", | ||
* "swissEduIDUsage1y" : "TRUE", | ||
* "affiliation" : "affiliate", | ||
* "persistent-id" : "https://eduid.ch/idp/shibboleth!https://test.swissbib.ch/shibboleth!AaduBHpQXrRs9BJqQcB7aLXgWTI=" | ||
* } | ||
*/ | ||
// @codingStandardsIgnoreEnd | ||
|
||
/** | ||
* Client. | ||
* | ||
* @var Client $client | ||
*/ | ||
$client = $this->getBaseClient( | ||
Request::METHOD_GET, | ||
$this->configNL['back_channel_endpoint_path'], | ||
$this->config['Site']['url'] | ||
); | ||
$client = $this->getBaseClientBackChannel(); | ||
$client->setParameterGet( | ||
[ | ||
'entityID' => $this->configNL['back_channel_param_entityID'], | ||
'nameId' => $nameId, | ||
'format' => "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent", | ||
'encoding' => "JSON/CGI" | ||
] | ||
); | ||
$response = $client->send(); | ||
$statusCode = $response->getStatusCode(); | ||
$body = $response->getBody(); | ||
if ($statusCode !== 200) { | ||
if ($statusCode !== 200 or $body == "{}") { | ||
throw new \Exception( | ||
"There was a problem retrieving data for user " . | ||
"with name id: $nameId. Status code: $statusCode result: $body" | ||
|
Oops, something went wrong.