0

I'm a simple system in PHP and codeigniter and need a simple but better way to manage users and their access to the system. So after some search I found interesting topics about access control but I'm still in doubt about if that's a good approach or not.

The role and user perm tables is because some users should have a different access that is not defined by any role. and the user_permission will always have priority over role_permission. For instance, a user has a role that have access to user exclusion but a admin created a user_perm denying user exclusion, so this particular user won't be able to delete users.

Any help will be appreciated.

    CREATE TABLE users
    (
      id PRIMARY KEY,
      username,
      password,
      role_id,
      first_name,
      last_name,
      ...
    );

    CREATE TABLE roles
    (
      id PRIMARY KEY,
      name
    );
    CREATE TABLE actions 
    (
      id PRIMARY KEY,
      name,
    );
    CREATE TABLE role_permission 
    (
      id PRIMARY KEY,
      action_id,
      permission BOOLEAN
    );

    CREATE TABLE user_permission
    (
      id serial NOT NULL PRIMARY KEY,
      action_id,
      permission BOOLEAN
    );

1 Answer 1

0

you forgot a table for relationship between the role- id to multiple users - id.... so each user would have a role and on basis of the role he would get permissions.. or else u can add a field role_id to users table..

2
  • changed, the role_id is on user table now. Feb 20, 2015 at 18:23
  • ok great.. i guess the rest is fine... its upon u how to implement and keep a check of each user during performing the specific action... Feb 20, 2015 at 18:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.