문제

I have table tbl_projects with a field "role". I want to use this field as parameter to filter data that each user have access. Example: I am employee from HR(my role) and I can't see projects from IT(other role).

My application use OSAuth. How can I build a view in firebird that filter the data based in all roles?

Example: This view filter only 'HR' role. I need filter for all roles.

CREATE OR ALTER VIEW HR_PROJECTS_VIEW(
    (_other_fields_)
    "ROLE")
AS
select
    P.(_other_fields_)
    P.ROLE
from 
    TBL_PROJECTS P
where 
    P.ROLE = 'HR';
도움이 되었습니까?

해결책

Use the CURRENT_ROLE context variable:

CREATE OR ALTER VIEW HR_PROJECTS_VIEW(
...
where 
    P.ROLE = CURRENT_ROLE;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top