Springboot app localhost login works fine but not on server

Hello,

I am creating a spring boot app with okta to sign in the users to the app. The integration itself works fine when the app is running on localhost. When running on the server with proper domain, the login flow stops at http://domain/login?error. This is after going to /okta, /authorize, /. Anything I am missing?

Thanks
Indresh

Have you whitelisted the callback url in the okta app dashboard?

Yes, I have. Also, I can see the app going through /okta, /authorize, /. But then it is navigating to /login as if to indicate that login did not happen.

Best Regards,
Indresh

Hi @indreshms

Can you please open a support ticket with us at developers@okta.com in order to check the internal logs and see why this error occurs?

Appears to be an issue with your SecurityConfiguration class in Spring Boot. Try this:

package yourpackagename;

import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;

@Configuration
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
    @Override
    public void configure(HttpSecurity http) throws Exception {
        http.antMatcher("/**").authorizeRequests()
            .antMatchers("/").permitAll()
            .anyRequest().authenticated()
            .and()
            .oauth2Login();
    }
}