Skip to content

Commit aa41b0c

Browse files
committed
feat: add the ability to disable ils user creation when using sso
This patch adds the ability to disable the creation of users when using SSO for login
1 parent cce4787 commit aa41b0c

File tree

5 files changed

+211
-143
lines changed

5 files changed

+211
-143
lines changed

code/aspen_app/app-configs/apps.json

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"LiDA-Europe": {
3+
"name": "Aspen-LiDA",
4+
"slug": "aspen-lida",
5+
"scheme": "aspenlida",
6+
"easId": "d0550b19-7df2-4a61-9fe1-e063f51e778e",
7+
"reverseDns": "com.jacobomara9011.aspenlida",
8+
"discoveryUrl": "https://greenhouse.aspendiscovery.co.uk/",
9+
"greenhouseUrl": "https://greenhouse.aspendiscovery.co.uk/",
10+
"libraryId": "1",
11+
"themeId": "1",
12+
"background": "#ffffff",
13+
"sentryProject": "aspen-lida",
14+
"sentryAuth": "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",
15+
"sentryDsn": "https://148acf47870cac6cce07e74327a60e0c@o4506319477604352.ingest.us.sentry.io/4506319478980608",
16+
"ascAppId": "6475778273",
17+
"appleTeamId": "A2N3J9ACDY",
18+
"ascApiKeyPath": "0",
19+
"ascApiKeyIssuerId": "e5007c12-0b4e-4d61-b7c0-0fe5d0a00e02",
20+
"ascApiKeyId": "6D59Y34BU4",
21+
"googleServiceKeyPath": "./GOOGLE_SERVICES_JSON"
22+
}
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"expoProjectOwner": "jacobomara9011",
3+
"versionCode": "1",
4+
"buildCode": "1",
5+
"sentryProjectOwner": "jacobomara9011",
6+
"sentryAuthToken": "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",
7+
"devAppleId": "jacob.omara@ptfs-europe.com",
8+
"ascApiKeyPath": "not_needed",
9+
"ascApiKeyIssuerId": "e5007c12-0b4e-4d61-b7c0-0fe5d0a00e02",
10+
"ascApiKeyId": "6D59Y34BU4",
11+
"googleServiceKeyPath": "./GOOGLE_SERVICES_JSON",
12+
"greenhouseUrl": "https://greenhouse.aspendiscovery.co.uk/",
13+
"language": "English",
14+
"country": "United Kingdom",
15+
"googleApiKeyAndroid": "1",
16+
"googleApiKeyApple": "2"
17+
}

code/web/sys/Authentication/SAMLAuthentication.php

+11-5
Original file line numberDiff line numberDiff line change
@@ -205,17 +205,23 @@ public function validateAccount() {
205205
$ssoArray = $this->mapSAMLAttributesToSSOArray($attributes);
206206

207207
if($this->ssoAuthOnly === false) {
208-
$ilsUserArray = $this->setupILSUser($ssoArray);
209-
if(!$this->validateWithILS($ssoArray)) {
210-
if($this->selfRegister($ilsUserArray)) {
211-
return $this->validateWithILS($ssoArray);
212-
} else {
208+
$ilsUserArray = $this->setupILSUser($ssoArray);
209+
if(!$this->validateWithILS($ssoArray)) {
210+
if ($this->config->createUserInIls) {
211+
if($this->selfRegister($ilsUserArray)) {
212+
return $this->validateWithILS($ssoArray);
213+
} else {
213214
AspenError::raiseError(new AspenError('Unable to register a new account with ILS during SAML authentication.'));
214215
return false;
216+
}
217+
} else {
218+
AspenError::raiseError(new AspenError('User does not exist in the ILS and autocreation of ILS users is disabled.'));
219+
return false;
215220
}
216221
} else {
217222
return $this->validateWithILS($ssoArray);
218223
}
224+
219225
} else {
220226
if(!$this->validateWithAspen($this->uid)) {
221227
$newUser = $this->selfRegisterAspenOnly($ssoArray);

code/web/sys/Authentication/SSOSetting.php

+10-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class SSOSetting extends DataObject {
1414
public $forceReAuth;
1515
public $restrictByIP;
1616
public $updateAccount;
17+
public $createUserInIls;
1718

1819
//oAuth
1920
public $clientId;
@@ -232,7 +233,15 @@ public static function getObjectStructure($context = ''): array {
232233
'label' => 'Update users ILS account information with data from the IdP when logging in using the data mapping provided',
233234
'description' => 'Whether or not users ILS account information is updated each time they log in using the data mapping provided',
234235
'default' => 0,
235-
],
236+
],
237+
'createUserInIls' => [
238+
'property' => 'createUserInIls',
239+
'type' => 'checkbox',
240+
'label' => 'Create ILS users when a matching user is not found from the IdP data in the ILS',
241+
'description' => 'Whether or not to automatically create the ILS user if no match is found between IdP data and the ILS.',
242+
'default' => 1,
243+
'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'
244+
],
236245
'oAuthConfigSection' => [
237246
'property' => 'oAuthConfigSection',
238247
'type' => 'section',

0 commit comments

Comments
 (0)