I am working on Spring Cloud + Boot example. In this example I am looking to do SSO. When I run this application, I get the response fine, but looks like
Multiple markers at this line - The type NoOpPasswordEncoder is deprecated - The method getInstance() from the type NoOpPasswordEncoder is deprecated
application.properties
server.port: 9000
server.servlet.context-path: /services
security.oauth2.client.clientId: pluralsight
security.oauth2.client.clientSecret: pluralsightsecret
security.oauth2.client.authorized-grant-types: authorization_code,refresh_token,password,client_credentials
security.oauth2.client.scope:toll_read,toll_report
ServiceConfig.java
@Configuration
public class ServiceConfig extends GlobalAuthenticationConfigurerAdapter {
@Override
public void init(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication()
.passwordEncoder(NoOpPasswordEncoder.getInstance())
.withUser("agoldberg").password("pass1").roles("USER")
.and()
.withUser("bgoldberg").password("pass2").roles("USER", "OPERATOR");
}
}
MainMethod:
@SpringBootApplication
@EnableAuthorizationServer
public class PluralsightSpringcloudM4SecureauthserverApplication {
public static void main(String[] args) {
SpringApplication.run(PluralsightSpringcloudM4SecureauthserverApplication.class, args);
}
}
But STS, shows error. What is the replacement of the deprecated method ?
I was able to solve this issue using below code. I am using Spring Boot version 2.0.4.RELEASE
. Done !
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.authentication.configuration.GlobalAuthenticationConfigurerAdapter;
@Configuration
public class ServiceConfig extends GlobalAuthenticationConfigurerAdapter {
@Override
public void init(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication()
.withUser("agoldberg").password("{noop}pass1").roles("USER")
.and()
.withUser("bgoldberg").password("{noop}pass2").roles("USER", "OPERATOR");
}
}