user permission table design

Asked 2 years ago, Updated 2 years ago, 118 views

What I'm going to do now is to store multiple roles for each user, and there are several permissions attached to the role.

user1.Role = [writer, reader]
user2.Role = [editor, reader]

writer.permission = [write]
reader.permission = [read]
editor.permission = [write, delete]

You want to store this information in the DB. Writers, writes, and so on are stored in text or in predefined integers.

My idea is to make the table user, role, permission, role-permission, and tighten the role with user.role_id,

The role-permission has duplicated permission.id and role.id, so how about finding permission.id with role.id and rejoining it?

It's been so long since I've touched a DB, so honestly, I don't have any DB concept A clear solution is good, but I would appreciate it if you could give me a keyword on how to find out.

database spring-data-jpa

2022-09-22 08:12

1 Answers

It's a self-answer. That's what they call Role Based Access Control.

I looked up some implementations of RBAC and implemented them similarly.


2022-09-22 08:12

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.