SAP CAP Blog Posts
cancel
Showing results for 
Search instead for 
Did you mean: 
qmacro
Developer Advocate
Developer Advocate
412

Within the topic of security and data privacy and specifically within security, we have:

  • Authentication: verification of a user's identity
  • Authorization: checking what level of access a given user has

In other words, "who" a user is (authentication), and "how" that user can interact with the resources (authorization).

For authorization, CAP offers role-based access control facilities that revolve around a couple of annotations @requires and @restrict.

The @restrict annotation allows for complex definitions of privilege declarations each of which can combine the granting of access to roles according to specific conditions, in this pattern:

{
  grant:<events>,
  to:<roles>,
  where:<condition>
}

The @requires annotation is actually just a convenience shortcut to something that we might commonly express with a @restrict annotation; for example:

@requires: 'Viewer'

is the equivalent of

@restrict: [ { grant:'*', to:'Viewer' } ]

There's another security related annotation which is in common use, which is actually just another convenience shortcut for:

@restrict: [ { grant:'READ' } ]

What is the name of that annotation?

This is a question from the June Developer Challenge on CAP Knowledge. And don't forget: always submit your answer as a hash, on its own - read the Taking part section of the intro post for more info. At the end of today, this question will be updated with links to further reading on this topic.

Further info:

  • The Authorization topic in Capire is a great resource for CAP-level authorization affordances.
  • CAP's local-first development facilities include the ability to mock authentication, which allows us to embrace auth from the outset rather than avoid it and incur technical and design debt. Read more in the blog post Local-first dev with CAP Node.js - mocking auth.
28 Comments
Dan_Wroblewski
Developer Advocate
Developer Advocate
0 Likes

32cb58f643fbf56f81d4668108a9b50f8e3812e3097f5cc1d3f278a268d246d1

shotokka
Explorer
0 Likes

db37320c40a203dd5281d58490af6a6f50fa855e345093478bf312368ac90ff0

lidavidlee
Explorer
0 Likes

f5cf7aa4351771d6ca108d9edddf2a63d16989a17b48df73e3cb97988912d476

furkan5
Explorer
0 Likes

33cd9787d7ba926d536e327cd0ee9a4e74f50d99295aa144bcf3913dacf2afa4

FlorianP1
Discoverer
0 Likes

95bd94d91732009e953d7219624ffc9d0b51f690f90638bc1a325c96edef92c7

Caisi
Explorer
0 Likes

a4cf83644e685239317285e058f3d4892b402518fd888ead58a1e7734c5fea62

omer_sakar
Active Participant
0 Likes

50645c4d30aa3e04c86f6cfedf0517f5dd158d9206a34cf367b1dbf39ade48fd

0 Likes

47bd441f495f71ae10d402ce3fc44eff5ded3ae8c5f7dce9cc0243ff0f81fe72

RajeshOlive
Explorer
0 Likes

6a441ebff5a8256cbff5ad47ef9e661bb75644850d7c33555d316c0c84063a6a

berkaydurmaz
Explorer
0 Likes

e68252f3028477b04619342c21c82133ae84cdff75ac56b6ebe588b762c0ee25

ankitsrivastav
Explorer
0 Likes

d84a3358c25c6cb21049cd22a042de1a87fcafae0bdc6d0f7aa5cf0b1d4e80cd

sarvesh_agarwal
Explorer
0 Likes

36fdb9ad0a8136afd3ec915de028450f9ba16565579ec18ad1f9935fcacd2867

GauravPhadnis
Product and Topic Expert
Product and Topic Expert
0 Likes

fd7bfedc5aeb61197557b581cded34cebc8b786ac6a0984e0c35b9fc74d29941

kasch-code
Participant
0 Likes

85998df9af8c5f69739547c660489cdd3b411e3ffb77f2d044537c31c88cacbb

VishnAndr
Active Contributor
0 Likes

31fb2819896cde663f85e7b954a4c000b6243526cf366ac35961ce8d5b1587ed

Chaimae_Chairi27
Participant
0 Likes

52c3d644cdc91a96a9b718ca32292f3c5731024db8a85811a06c4b142f62f813

parthasaradhi
Explorer
0 Likes

63c1fa0c12c9e04ccb49fef85898ed7a99ded88292961cde1b05d40f334f5f94

Rupesh_Kumar25
Explorer
0 Likes

d00535efa0895a25def505695fea8cf77cc332fc951e778ca3b69d85baee6d53

ajmaradiaga
Developer Advocate
Developer Advocate
0 Likes

d48b3769427f7d62cb228c786ccda27bf04c36b837f8f76e4f35eab6090c6458

HarshPatelV
Participant

Great explanation of CAP authorization concepts! The comparis makes it much easier to understand how role-based access control is implemented in CAP. The challenge is a nice way to reinforce the use of convenience annotations and their underlying authorization definitions. Thanks for sharing this practical security-focused question!

mvaibhav
Contributor
0 Likes

b6f27f30c72eb20640a6b2d6ae578f5b092c7e9cdf4cdf6cc0a76743004eca17

NiklausB
Discoverer
0 Likes

0cc5abb1f90732d84a1d261de21dc947883396b78ce9d96638df516cfffe3d77

Raphael
Explorer
0 Likes

a20a95d88638f01fc9049680749deeb18cad9a0ef27cb99b1c6adb650b3d1aaf

soheil_st
Explorer
0 Likes

e99970478ac6160330a26c81dfec9ba6aebb5ceb96bd841e80684c7aacd3bcc3

Joery
Participant
0 Likes

d54c3334dacaecd3d915d4e0e89571810d7872402a9c79f5c4ddee18a7b5866b

SergioG_TX
SAP Champion
SAP Champion
0 Likes

46f7e1f8b5cb321ff6e502c53f7bbbce84d210531a0aba2f34bd8b366d275213

NakulG
Explorer
0 Likes

90d9fb673f584cd8f4f36c805de35a15ae2e92ca6e38edd9b72e86aea9f92b95

nagarjundas_1994
Explorer
0 Likes

bfcaa1d12982ec389cc339440e3ffdfbee3b38f86ea41225eb07f8c9067c4828