Search code examples
javaspring-bootdesign-patternsarchitecturesetup-project

Login System Design - For CRM Project


Building a customer relationship management system.

  • A particular company can buy our product to manage their customers
  • Once the company buys our product they will be assigned with username and password for logging into the application.
  • company: is the main admin to the application they can also add new admins to monitor their customers

How to Design a login system with multiple roles?

  • Company as main admin ex: XYZ solutions(Username:xyz@gmail.com, Password: Xyz123) can log in and can also add new admin say for example sub-admin:Santhosh@xyz.com.

  • now Santhosh@xyz.com (SUB ADMIN) should also be able to log in.

  • also need to limit the admins to 5: any idea how to achieve this?.

How to design the login system to this scenario and how should be my database, to save usernames and passwords of both admin and sub admin?

using java 8 with spring has my framework and MySQL as backend


Solution

  • Define company/Users/Role/Permissions. Your roles would be pretty abstract buts its the permissions that will define the role of the user. For example, User with SystemAdmin role can do almost anything because the permissions that will define the system admin role will allow her to do it. On the other hand regular user will have limited selection of permissions like, execute transactions, access certain UI but will not be able to change configurations etc. Basically your permission will define what roles can have and then use attach or assign those roles to the users created under the company. You question basically seems more from the roles and permission rather than login. Hope this helps and let me know if you need more clarifications.