Creating roles and permissions from the database
We have utilized UserDetailsService
and UserDetails
interfaces in handling user credentials and information but the information, still came from HashMap
with static
data. This recipe will show us how to archive all the user credentials and information to a database to be fetched by a custom UserDetails
class.
Getting started
Open the MySQL server to alter our hrs
schema. Also, utilize the same project ch04
for this recipe.
How to do it...
- Before we start the main recipe, let us add the following tables in our
hrs
schema:
- The
userdetails
class will contain the usual general user information, whilelogindetails
contains theusername
,password
, andencrypted password
of each user. On the other hand,role_permission
contains all the roles and access permissions of each user inlogindetails
. A Permission is defined as the allowableCRUD
transaction to be performed by a user, such asREAD
,WRITE
,VIEW
,DELETE
, andREPORT
, which is different from the...