I have my authorization server on ip 172.30.0.2, and a resource server on 172.30.0.3.
Inside the resource server's application.yml, I have:
security:
oauth2:
resource:
userInfoUri: http://172.30.0.2:8080/v1/user
with this configuration it works fine. But if I use:
http://domain-management-query.domain-management-ms:8080/v1/user
I receive a 400 error. I receive the same error by issuing the command with wget form the command line from the resouceserver container.
How can I use docker domains instead of a prefixed ip?
I'm not using docker-compose for the domain-management-query.domain-management-ms, but this docker run command:
docker run -it --rm -p 8080:8080 --network=jacopetto -v $(pwd):/home/gradle/project --net-alias=domain-management-query.domain-management-ms uniroma1/j8-gradle-ms:1.0 /bin/sh
From the other service I can ping it and resolve it by hostname.
My configuration is from this book: https://github.com/carnellj/spmia-chapter7/ (Authentication-service + organization-service).
resource service:
@Configuration
public class ResourceServerConfiguration extends
ResourceServerConfigurerAdapter {
@Override
public void configure(HttpSecurity http) throws Exception{
http.cors().disable().authorizeRequests().anyRequest().authenticated();
}
@Bean
RequestDumperFilter requestDumperFilter() {
return new RequestDumperFilter();
}
}
Authorization Service:
@Configuration
public class WebSecurityConfigurer extends WebSecurityConfigurerAdapter {
@Autowired
private DataSource dataSource;
// The Authentication-
//ManagerBean is used
//by Spring Security to
//handle authentication.
@Override
@Bean
public AuthenticationManager authenticationManagerBean() throws Exception {
return super.authenticationManagerBean();
}
/*
The UserDetailsService is used by Spring
Security to handle user information that
will be returned the Spring Security.
*/
@Override
@Bean
public UserDetailsService userDetailsServiceBean() throws Exception {
return super.userDetailsServiceBean();
}
/**
* The configure() method is
* where you’ll define users, their
* passwords, and their roles.
*/
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication()
.withUser("john.carnell")
.password("{noop}password1")
.roles("USER")
.and()
.withUser("william.woodward")
.password("{noop}password2")
.roles("USER", "ADMIN")
;
}
}
AuthorizationServerConfigurerAdapter:
@Configuration
public class JWTOAuth2Config extends AuthorizationServerConfigurerAdapter {
@Autowired
private AuthenticationManager authenticationManager;
@Autowired
private UserDetailsService userDetailsService;
/**
* Which *clients* are going to register to the service.
*/
@Override
public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
clients.inMemory()
.withClient("jacopetto")
.secret("{noop}thisissecret")
.authorizedGrantTypes("refresh_token",
"password",
"client_credentials")
.scopes("webclient", "mobileclient");
}
@Override
public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
endpoints
.authenticationManager(authenticationManager)
.userDetailsService(userDetailsService);
}
@Override
public void configure(AuthorizationServerSecurityConfigurer oauthServer) throws Exception {
oauthServer.allowFormAuthenticationForClients();
}
}
I've also tried to shorten the hostname to dom-manag-query.d-m
but seems not working.