if(재능이 없으면 시간으로 극복하라){return 성공;}

SAP BTP - CAP내에서의 역할 및 권한 부여 설정하기

risk-service.cds 파일에서 entity의 속성을 변경

using { sap.ui.riskmanagement as my } from '../db/schema';

@path: 'service/risk'
service RiskService {
  entity Risks @(restrict : [
            {
                grant : [ 'READ' ],
                to : [ 'RiskViewer' ]
            },
            {
                grant : [ '*' ],
                to : [ 'RiskManager' ]
            }
    ]) as projection on my.Risks;
    annotate Risks with @odata.draft.enabled;
  entity Mitigations @(restrict : [
            {
                grant : [ 'READ' ],
                to : [ 'RiskViewer' ]
            },
            {
                grant : [ '*' ],
                to : [ 'RiskManager' ]
            }
    ])as projection on my.Mitigations;
    annotate Mitigations with @odata.draft.enabled;
}

실행 버튼을 누르니 아이디/비밀번호 입력창이 나왔다. image RiskManager라는 계정에 Risk와 Mitigation에 대한 계정을 설정한건데 그렇다면 RiskManager라는 계정은 어떻게 생성하는가?

후에는 데이터베이스 쪽으로 전환할 수 있지만 예제에서는 pacakage.json에 선언해서 사용한다.

image

RiskViewer로 설정한 계정은 Read만 할 수 있고 RiskManager로 설정한 계정은 모든 권한을 준다.

RiskViewr 계정으로 로그인하여 편집을 눌러보자 image

오류 발생 image

RiskManager 계정으로 로그인하여 편집을 눌러보자.

수정 가능 image

위와 같은 방법으로 계정 생성 및 계정 별 권한을 줄 수 있다는 것을 알았다.

나중엔 디비에서 가지고 온 데이터 기반으로 하는 방법을 알아보자. 덧붙여 파일 디비에는 테스트 안하는지도 궁금