Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to replace java-container-security to get rid of deprecated spring-security-oauth2 #372

Closed
santoshkashyap opened this issue Sep 21, 2020 · 3 comments
Assignees

Comments

@santoshkashyap
Copy link

santoshkashyap commented Sep 21, 2020

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
java-container-security
3.14.0

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
Copy link
Contributor

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

@nenaraab nenaraab changed the title Question on dependency to use How to replace java-container-security to get rid of deprecated spring-security-oauth2 Sep 21, 2020
@santoshkashyap
Copy link
Author

santoshkashyap commented Sep 22, 2020

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
Copy link
Contributor

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

@nenaraab nenaraab self-assigned this Sep 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants