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 replace java-container-security to get rid of deprecated spring-security-oauth2 #372

Closed santoshkashyap closed 4 years ago

santoshkashyap commented 4 years ago

Hi,

I have a question on maven dependencies for xsuaa. In our Spring boot project, we have the following dependency: `

com.sap.cloud.security.xsuaa
        <artifactId>java-container-security</artifactId>
        <version>3.14.0</version>

and

import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer; import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;

@EnableWebSecurity @EnableResourceServer // deprecated public class WebSecurityConfig extends ResourceServerConfigurerAdapter { // ResourceServerConfigurerAdapter is also deprecated // rest of the code `

With this we also get spring-security-oauth2:2.5.0.RELEASE dependency as a transitive. Since, this is deprecated, is it now recommended to use the maven artifact - xsuaa-spring-boot-starter instead of java-container-security as above ? From the nice set of usage samples provided, I think sample fits our Spring boot app (MVC) Thank you

Regards, Santosh

nenaraab commented 4 years ago

Hi @santoshkashyap

yes, in case you like to get rid of the deprecated sping-security-oauth2 lib and you have implemented a spring-boot application, this might fit best.

Please have also a look at this migration guide: https://github.com/SAP/cloud-security-xsuaa-integration/blob/master/spring-xsuaa/Migration_JavaContainerSecurityProjects.md

Best regards, Nena

santoshkashyap commented 4 years ago

Hi @nenaraab , Thank you for quick response. The link to migration guide is exactly what I was looking for 👍 However, I have a follow-up question

  1. Consumers create a service binding for our spring boot service in SCP CF which gives them credentials(clientID, url and clientSecret). Using the credentials and also the service url provided( via service binding VCAP) they can invoke the service APIs passing the auth token obtained from client id/secret via the token endpoint
  2. Our application now needs to validate the incoming request by checking for scopes and allow or block access accordingly. Currently, we use the com.sap.xs2.security:java-container-security for this purpose and are now considering to migrate to the new xsuaa-spring-boot-starter to avoid spring oauth deprecation issue. Is this recommended ?

Regards, Santosh

nenaraab commented 4 years ago

Hi @santoshkashyap

The readme here provides an overview about all Java open-source client libraries, that are provided here: https://github.com/SAP/cloud-security-xsuaa-integration/blob/master/README.md

These migration guides supports you to migrate from

Recommended replacement for Spring 5 based and Spring Boot applications is spring-xsuaa.
Please check the Migration Guide.

Recommended replacement for J2EE applications is SAP Java Buildpack (>= version 1.26.1).
Please check the Migration Guide.

Recommended replacement for Java native applications is java-security.
If you like to have a smooth migration experience, and like to stick to the Spring Security OAuth (deprecated) you can follow this Migration Guide.

Best regards, Nena