cancel
Showing results for 
Search instead for 
Did you mean: 

How to access IAS login name in CAP CDS?

karstenvoigt
Participant
0 Kudos

Hi,

I have the following challenge: restrictions should be checked based on the login name in the IAS (please don't ask why, a very old HANA application is being migrated to the BTP).

XSUAA with an IAS tenant as IdP is used for authentication/ authorization. In IAS, the login name was included as an assertion attribute (as login_name). Unfortunately, the attribute doesn't seem to arrive in the service. A logging of the value req.user.login_name leads to an undefined. If I understood the documentation at https://cap.cloud.sap/docs/guides/authorization correctly, the attribute should actually have been mapped.

The authorization check (@restrict then also works wonderfully with undefined as the value for $user.login_name).

The service is used by a UI5 application (with token forward to the service) using the same IAS tenant and the same XSUAA instance. The output of the user data in the UI5 application contains the mapped attribute (output via sap-approuter-userapi).

What is the right way to get your own attributes from the IAS into the CAP application (Node.js) and how can they be accessed there? Is there a guide/documentation somewhere that I've overlooked? Any hint is welcome.

Thanks.

Regards

Karsten

View Entire Topic
WouterLemaire
Active Contributor
0 Kudos
karstenvoigt
Participant
0 Kudos

Thanks for the referenced links. Now I was able to find the my mistake. I've already added the attribute references to xs-security.json; but in SAP BTP cockpit the default roles were already create from template without attribute references. I had to drop the generated default roles to "enable" the attribute references. (The build log shows a message, that the xsuaa could not be updated; but the app deployment didn't fail, so I haven't seen the deployment issue.)

abranjan
Active Participant
0 Kudos

Hi karsten.voigt,
What did you meant by "I had to drop the generated default roles to "enable" the attribute references."
I am facing the exact same issue. Wanted to know how you solved it.

Thanks in advance.