cancel
Showing results for 
Search instead for 
Did you mean: 

CDS annotations: @Capabilities.InsertRestrictions with permissions

06-16-2020 12:30 PM
htammen Active Contributor
4565 views 6 comments
SAP Managed Tags
Subscribe

Hi,

I want to restrict the creation of entities in my CDS service. Only users who are assigned to the 'create' scope should be able to insert a new record. I want the '+' Button in the ListView to be disabled or invisible.

I annotated my entity as follows (according to this documentation https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.Capabilities.V1.m...😞

entity BusinessPartnerGroup @(
    Capabilities:{
        InsertRestrictions:{Insertable: true, Permissions:[{Scopes:[{Scope:'create'}]}]},
        UpdateRestrictions:{Updatable: true},
        DeleteRestrictions:{Deletable: false}},
    restrict:[...])as projection on ds.BusinessPartnerGroup {

In the UI the '+' Button is visible although the user is not assigned to the 'create' scope. Here is an excerpt of the request scopes which I analyzed with debugger.

req.attr.scopes
(8) ['read', 'approve', 'openid', 'any', 'authenticated-user', 'identified-user', 'openid', 'openid']
0:'read'
1:'approve'
2:'openid'
3:'any'
4:'authenticated-user'
5:'identified-user'
6:'openid'
7:'openid'
length:

What is the "SchemeName" in the PermissionType good for? I know an OAuth GrantType, an Authentication scheme and an OData Schema. Which one do I have to use here, if any?

Thanks in advance
Helmut

Accepted Solutions (0)

Answers (2)

Answers (2)

gregorw
SAP Mentor
SAP Mentor

In the SAP Incident 401125 / 2020 that I've raided I got only directed to the page: What's New in SAPUI5 1.76 with the section:

  • Path Support for Insert Restriction

    We now provide dynamic value support for Capabilities.InsertRestriction/Insert by path evaluation in List Reports and Object Pages. For more information, see Defining and Adapting Sections.

Ben
Participant
0 Likes

Hi Helmut

I had a similar problem and I temporarily solved it with following workaround: I created a separate CDS service for those entities and then restricted read/write on Service level..