hubzero / hubzero-cms

Platform for Scientific Collaboration
https://hubzero.org
GNU General Public License v2.0
47 stars 57 forks source link

[NCN-633] Rework user secret into core hubzero plugin #1693

Closed jsperhac closed 4 months ago

jsperhac commented 8 months ago

Dependencies

This work is part of Epic NCN-434, whose PRs should all be deployed together:

Summary

This code adds functionality to the existing Hubzero core plugin, plgUserHubzero. The new functionality creates and maintains a unique 32 character user secret for each Hub user, at login time. If the user has an existing secret, that secret is retained. If the user is ever deidentified, the plugin will null out the user secret.

User secrets are stored in the jos_users.secret column, which is created on up migration of this plugin. At up migration time, new unique secrets are then generated for all users who have logged in during the past 1 year. The jos_users.secret column is removed on down migration of this plugin.

Motivation

The goal is to create the secret once per user under normal conditions. The user secret can then be hashed with a unique Hub secret and a unique email campaign secret to create a unique code. This code can be used to form a URL that will be emailed to the user to provide them with link-based access to a secure Hub page without requiring login. Should a security incident occur, the user secret can be reset in the admin interface; this is done in com_members PR #1683

Development

This development was done for Nanohub, as part of the Epic NCN-434, "Salesforce Newsletter Expiration Token Rewrite". Details of development task cards:

Epic: NCN-434

Code Description

The functionality uses the standard Hubzero plugin architecture, including a migration script that creates and populates, or drops, the secret database column. The changes here add to the existing plugin's public onUserLogin() and onUserDeidentify() functions, as well as creating several protected functions that generate the secret, check for the secret, and save or null the secret.

Testing

This plugin was tested on an AWS Hubzero instance running on CentOS7 and previously on a local VirtualBox Hubzero instance. Tests included:

Deployment

This plugin should be deployed with other changes stemming from Nanohub epic NCN-434. Hotfixing should not be necessary.

Revisions

This work was initially developed as a standalone plugin, found in PR #1663.

Following initial code review, these revisions were completed (as of 14 Sep 23):

This work was subsequently moved to the plgUserHubzero plugin.

jsperhac commented 7 months ago

@dbenham, I removed the enablePlugin() and disablePlugin() calls and rebased this work as discussed. Thank you!

jsperhac commented 4 months ago

(Superceded by #1704 )