joshp23 / YOURLS-AuthMgrPlus

Seperates user data & manages authorization with role-based access controls (RBAC)
GNU General Public License v3.0
35 stars 19 forks source link

Plugin admin page for role administration, etc. #4

Open joshp23 opened 5 years ago

joshp23 commented 5 years ago

In reference to @nicwaller's issue https://github.com/nicwaller/yourls-authmgr-plugin/issues/10, there should/could be an admin page to manage users/roles. Some work has been done on this here https://github.com/joshp23/YOURLS-AuthMgrPlus/commit/1977912f40df9a583016017fa5fb2ef253b5e4ba

clmcavaney commented 5 years ago

This would be handy to provide simpler management of user roles without having to edit the user/config.php file for each users role. I would like to contribute to a solution here, but not 100% sure where to start. From what Nic (@nicwaller) first explored it looks like a form to display the current roles. Just not sure where the roles would be stored. It looks like updates might be ephemeral and not committed to a database.

Is anybody else keen?

joshp23 commented 5 years ago

I would start with moving users to the database, hashing passwords with password_hash(), and verifying users with something like

// intercept the login process
yourls_add_filter( 'is_valid_user', 'amp_is_valid_user' );
// returns true/false
function amp_is_valid_user( $value ) {
    $user = $_REQUEST['username'];
    if ( check_DB_for_user( $user ) == true ) {
        $pass = $_REQUEST['password'];
        $hash = get_user_hashed_pass_from_DB( $user );
        $value = password_verify( $pass , $hash );
    }
    return $value;
}

Making sure to extend this to address API calls, etc.

This would of course require the creation of a new user table, where roles are assigned. This would also invite a reconsideration of how the concept of ownership is currently managed in relation to URLs.

Then I would add or expand on Nick's simple admin page to deal with role assignment, etc.

denics commented 1 year ago

related to #44