Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add the ability to disable ils user creation when using sso #176

Open
wants to merge 1 commit into
base: SSO-disable-ils-user-creation-25.01.01.ptfs
Choose a base branch
from
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions code/web/sys/Authentication/SAMLAuthentication.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,17 +205,23 @@ public function validateAccount() {
$ssoArray = $this->mapSAMLAttributesToSSOArray($attributes);

if($this->ssoAuthOnly === false) {
$ilsUserArray = $this->setupILSUser($ssoArray);
if(!$this->validateWithILS($ssoArray)) {
if($this->selfRegister($ilsUserArray)) {
return $this->validateWithILS($ssoArray);
} else {
$ilsUserArray = $this->setupILSUser($ssoArray);
if(!$this->validateWithILS($ssoArray)) {
if ($this->config->createUserInIls) {
if($this->selfRegister($ilsUserArray)) {
return $this->validateWithILS($ssoArray);
} else {
AspenError::raiseError(new AspenError('Unable to register a new account with ILS during SAML authentication.'));
return false;
}
} else {
AspenError::raiseError(new AspenError('User does not exist in the ILS and autocreation of ILS users is disabled.'));
return false;
}
} else {
return $this->validateWithILS($ssoArray);
}

} else {
if(!$this->validateWithAspen($this->uid)) {
$newUser = $this->selfRegisterAspenOnly($ssoArray);
Expand Down
11 changes: 10 additions & 1 deletion code/web/sys/Authentication/SSOSetting.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class SSOSetting extends DataObject {
public $forceReAuth;
public $restrictByIP;
public $updateAccount;
public $createUserInIls;

//oAuth
public $clientId;
Expand Down Expand Up @@ -232,7 +233,15 @@ public static function getObjectStructure($context = ''): array {
'label' => 'Update users ILS account information with data from the IdP when logging in using the data mapping provided',
'description' => 'Whether or not users ILS account information is updated each time they log in using the data mapping provided',
'default' => 0,
],
],
'createUserInIls' => [
'property' => 'createUserInIls',
'type' => 'checkbox',
'label' => 'Create ILS users when a matching user is not found from the IdP data in the ILS',
'description' => 'Whether or not to automatically create the ILS user if no match is found between IdP data and the ILS.',
'default' => 1,
'note' => 'If the user does not exist in the ILS when we sign in to Aspen with SSO, whether we can create that user in the ILS'
],
'oAuthConfigSection' => [
'property' => 'oAuthConfigSection',
'type' => 'section',
Expand Down
12 changes: 12 additions & 0 deletions code/web/sys/DBMaintenance/version_updates/25.01.00.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,18 @@ function getUpdates25_01_00(): array {
],
//set_hoopla_index_by_day_to_default

//jacob - PTFS-Europe
'sso_do_not_create_user_in_ils' => [
'title' => 'Do not create SSO user in ils',
'description' => 'Ability to stop SSO from creating users in the ils',
'continueOnError' => true,
'sql' => [
'ALTER TABLE sso_setting ADD COLUMN createUserInIls int(11) DEFAULT 1',
]

],
//sso_do_not_create_user_in_ils

];
}

Expand Down
Loading