Skip to content
Snippets Groups Projects
Commit 88174f1c authored by Demian Katz's avatar Demian Katz
Browse files

Standardized behavior related to blank passwords.

parent e01bd1eb
Branches
Tags
No related merge requests found
...@@ -149,9 +149,19 @@ class CAS extends AbstractBase ...@@ -149,9 +149,19 @@ class CAS extends AbstractBase
} }
} }
// Save credentials if applicable: // Save credentials if applicable. Note that we want to allow empty
// passwords (see https://github.com/vufind-org/vufind/pull/532), but
// we also want to be careful not to replace a non-blank password with a
// blank one in case the auth mechanism fails to provide a password on
// an occasion after the user has manually stored one. (For discussion,
// see https://github.com/vufind-org/vufind/pull/612). Note that in the
// (unlikely) scenario that a password can actually change from non-blank
// to blank, additional work may need to be done here.
if (!empty($user->cat_username)) { if (!empty($user->cat_username)) {
$user->saveCredentials($user->cat_username, $catPassword); $user->saveCredentials(
$user->cat_username,
empty($catPassword) ? $user->getCatPassword() : $catPassword
);
} }
// Save and return the user object: // Save and return the user object:
......
...@@ -289,9 +289,19 @@ class LDAP extends AbstractBase ...@@ -289,9 +289,19 @@ class LDAP extends AbstractBase
} }
} }
// Save credentials if applicable: // Save credentials if applicable. Note that we want to allow empty
// passwords (see https://github.com/vufind-org/vufind/pull/532), but
// we also want to be careful not to replace a non-blank password with a
// blank one in case the auth mechanism fails to provide a password on
// an occasion after the user has manually stored one. (For discussion,
// see https://github.com/vufind-org/vufind/pull/612). Note that in the
// (unlikely) scenario that a password can actually change from non-blank
// to blank, additional work may need to be done here.
if (!empty($user->cat_username)) { if (!empty($user->cat_username)) {
$user->saveCredentials($user->cat_username, $catPassword); $user->saveCredentials(
$user->cat_username,
empty($catPassword) ? $user->getCatPassword() : $catPassword
);
} }
// Update the user in the database, then return it to the caller: // Update the user in the database, then return it to the caller:
......
...@@ -121,21 +121,18 @@ class Shibboleth extends AbstractBase ...@@ -121,21 +121,18 @@ class Shibboleth extends AbstractBase
} }
} }
// Save credentials if applicable. Note that if $catPassword is empty, // Save credentials if applicable. Note that we want to allow empty
// we'll pass through the existing password already in the database; // passwords (see https://github.com/vufind-org/vufind/pull/532), but
// otherwise, when users log out, their passwords may be cleared from // we also want to be careful not to replace a non-blank password with a
// the database. We can't simply skip saving credentials when the password // blank one in case the auth mechanism fails to provide a password on
// is empty, because in some scenarios, an empty password is normal // an occasion after the user has manually stored one. (For discussion,
// (see https://github.com/vufind-org/vufind/pull/532 for details). // see https://github.com/vufind-org/vufind/pull/612). Note that in the
// Note that this leaves an edge case where, if a user changes their // (unlikely) scenario that a password can actually change from non-blank
// password from something to nothing, VuFind will not properly clear it // to blank, additional work may need to be done here.
// out. This seems unlikely, but if it is encountered, we may need to
// add more logic here. See https://github.com/vufind-org/vufind/pull/612
// for related discussion.
if (!empty($user->cat_username)) { if (!empty($user->cat_username)) {
$user->saveCredentials( $user->saveCredentials(
$user->cat_username, $user->cat_username,
empty($catPassword) ? $user->cat_password : $catPassword empty($catPassword) ? $user->getCatPassword() : $catPassword
); );
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment