SAP / cloud-security-services-integration-library

Integration libraries and samples for authenticating users and clients bound to XSUAA authentication and authorization service or Identity authentication service.
Apache License 2.0
151 stars 136 forks source link

How to write a servlet that on request will do all token exchanges, set required cookies and redirect caller #454

Closed maxvader closed 3 years ago

maxvader commented 3 years ago

Hello, we need to allow our customers to access directly to our angular application that is behind the application router without showing the usual cloud foundry login page. So we thought that we have no alternative than:

Will this scenario work? Can you point me to the java code that will do the login in cf, generate cookies, etc?

Thank you!

nenaraab commented 3 years ago

Hi @maxvader,

Best regards, Nena

maxvader commented 3 years ago

Hi @nenaraab , I am aware that my question seems like a lazy newbie question, I was trying to be most concise as possible. A year ago I contacted you for a very similar problem, related to our use of sapjco3 in CF enviroment. Our architecture uses Spring and the most relevant packages are : com.sap.cloud.security.xsuaa spring-xsuaa and token-client, org.springframework.security spring-security-oauth2-resource-server and spring-security-oauth2-jose, neo-java-web-api, javax.servlet-api.

On why the user is unable to access directly via the router: we absolutely need to have a direct login without showing the Cloud Foundry form. This because it is an integration and the user expects to click on a link and open our page. The user is already logged in another system and absolutely doesn't want to log in again. Too bad our commercial sold that... Se we think to provide the necessary parameters encoded in the url and let some java code do the login part.

I even thought about other ways, like IDP federation, but my collegues told me that the login form would appear even in that case (I have no experience on that, maybe they are wrong).

So, sorry for coming here with this strange question, you are the most competent people I know of. I tried in the past to ask question on sap forums but no one was able to answer. I don't know SAP Jam, I tried once but it seemed to me to be invitation only, if you can let me in I will gladly enter. My business email is: massimo.nann@horsa.it

nenaraab commented 3 years ago

Hi @maxvader

Still not sure whether I've understood your scenario.

Further ideas...

Best regards, Nena

maxvader commented 3 years ago

Thank you @nenaraab , you opened me a lot of possibilities. I have to admit that despite using CF for some time some concepts are still vague to me. I guess we will try first with basic auth or no auth in the app router, we already have an authentication mechanism in the back end and woul be perfect. Looking around I discovered that is is even possible to get an access token directly from XSUAA with api calls like in this tutorial (it's for ABAP but they are just http calls), but that would require some code.

I need to ask you just one last question: the IDP case. We have SAP Identity Authentication configured for CF and the customer uses his own IDP for the sofware that will display the link to our application. You are saying that in some way the customer IDP can be connected or federated with CF to skip the app router phase? This would be very useful and interesting... I promise this is the last question :-)

nenaraab commented 3 years ago

Hi @maxvader

in regard to the access token from xsuaa... in java you can leverage the token-client that implements some of the token flows: https://docs.cloudfoundry.org/api/uaa/version/74.1.0/index.html#token

In regard to you last question, could you please open a new issue with this question, then i could forward it to the experts (pls. expect some delay).

Best regards, Nena