cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

CAP JAVA: CDS service with $batch requires authentication

christoffer_fuss
Participant
0 Likes
568

Hello,

I have a CAP JAVA application where I defined a service with public entities and protected entities with requires annotation like this:

christoffer_fuss_0-1709628385428.png
I can consume all my public entities without authentication. 
But the $batch request gives a 401 error and requires authentication.
How can I make the $batch public as well with requires annotation?
I tried with spring security config:

christoffer_fuss_1-1709628754589.png

This makes the $batch public but then I cannot get the authentication info of logged in users, so 

userInfo.isAuthenticated() is always false (also for logged in users).

christoffer_fuss_2-1709629147112.png

What is the best way to solve this?

Best regards and many thanks,

Chris

 

 

 

Accepted Solutions (0)

Answers (1)

Answers (1)

OlegsBugrovs
Newcomer
0 Likes

I would recommend to split entities into two services (code duplications are fine in this case). Service in CAP is supposed to be for one purpose, in case if you need both authenticated and public access to one service, it clearly indicates you are using one service for more than one purpose.