我有一个具有两个域模型 Organization 和 TicketQuestion 的应用程序。经过身份验证的用户想要创建具有组织属性的票证,以解决每个用户允许某个组织的问题,如下所示:
用户 1 允许组织 1
用户 2 允许组织 2
TicketController.java 有创建票的保存方法。我有这个漏洞:User1 可以使用具有 Organization2 的票证调用方法(该票证没有权限)。我正在使用 Hibernate 过滤器在 GET 方法中授权数据,但我不知道如何保护用户想要持久且没有权限的数据??
/ticket/save
{
id:-1,
organization:{
id:2,
title:'organization2' //not allowed this organization
}
}
@Entity
@Table(name = "core_organization_structure")
public class OrganizationStructure {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "title", nullable = false)
private String title;
}
@Entity
@Table(name = "core_Ticket")
public class Ticket {
..some prop
@ManyToOne
@JoinColumn(name = "org_id", nullable = false)
private OrganizationStructure org;
}