Closed brynwhyman closed 3 years ago
This code in LoginSession::handlePermission()
should probably be changed from
// Members can manage their own sessions
if ($this->ID == $member->ID) {
return true;
}
// Access to SecurityAdmin implies session management permissions
return Permission::checkMember($member, 'CMS_ACCESS_SecurityAdmin');
to
// Members can manage their own sessions
if ($this->MemberID === $member->ID) {
return true;
}
return false;
Probably worth updating following code in LoginSessionController::removeLoginSession()
:
$id = $request->param('ID');
$loginSession = LoginSession::get()->byID($id);
to
$id = $request->param('ID');
$memberID = Security::getCurrentUser()->ID;
$loginSession = LoginSession::get()->filter(['ID' => $id, 'MemberID' => $memberID])->first();
The current permission model is poorly implemented. MemberExtension
has a bunch of logic to determine if the current user can edit and/or view the current session, but it completely bypasses LoginSession::canView
/LoginSession::canEdit
methods.
MemberExtension
is also a PermissionProvider
for SESSION_MANAGER_ADMINISTER_SESSIONS
. If we want a permission provider, it should be on LoginSession
because that's the object we are managing.
MemberExtension
also tries to set the SessionManagerField to read-only if you are only allowed to view the current login session. However, we don't have a read-only view for this field.
LoginSession::handlePermission
looks pretty good and already has permission extensibility built-in like @bergice mentioned in backlog grooming.
Here's what I want to do:
MemberExtension
PermissionProvider
logicSessionManagerField
to readonly if the user doesn't have canDelete
permission and spin off an issue to implement a read-only view for this field.CMS_ACCESS_SecurityAdmin
CanEdit
to always return false
... the idea is that you should never be able to directly update a LoginSession
object.CanCreate
to always return false
for the same reasonCanView
and CanDelete
to be based on the owner of the LoginSessionLooks good
how you could implement your own permission layer if you wanted to.
How do you see this working?
You would stick an extension on LoginSession
an hook into the canView
/canDelete
extension points.
Maybe you use a pre-existing permission to decide if the user can delete the login session. Maybe you just check if the current user can edit the member. Maybe you implement your own permission provider. Ultimately, that's a decision the developer has to make for themselves.
We've got a follow up issue to explore this in further detail https://github.com/silverstripe/silverstripe-session-manager/issues/57#issuecomment-819161619
The ability for Developers to alter the behaviour (and allow other users to access member session data) should be documented so the feature is discoverable
I've made a suggestion in https://github.com/silverstripe/silverstripe-session-manager/issues/63 that we should recommend that if the behaviour is altered, the privileged user should get both CanView and CanDelete actions (given there's no read-only view).
Linked PR has been merged
Noted on the pull request there's an issue with non-admin users revoking sessions. We've agreed to split that of as a separate issue. https://github.com/silverstripe/silverstripe-session-manager/issues/67
Overview
A user should be the only one who can view and manage existing sessions.
Currently with this module installed, a user who has access to view other member profiles (like the default Administrator role) has the ability to view and manage their sessions. This shouldn't be the case.
Acceptance Criteria
Pull request