swapnil skate
swapnil skate

Reputation: 83

spring boot Oauth Okta 404 on redirect

My Spring Boot app giving me an error as 404 after redirecting from the Okta server. May I have some help to solve this. My configurations are as below.

This is my Okta server redirect

https://dev-40483106.okta.com/oauth2/default/v1/authorize?response_type=code&client_id=0oa3p7a86ycJ7olpP5d7&scope=openid%20email&state=xVpkZIPGaGqAQCZIMXZgTrbmKmHJbcKbtM95KO9RwVU%3D&redirect_uri=http://localhost:8082/mms-sso/auth&nonce=cPdNAYT4tQ9mAjhj4HUiynBEQVAnJHnBTIezqquOpJM

This is my Redirect URI where I am getting a 404 error

http://localhost:8082/mms-sso/auth?code=rOh9u2fwBTB7gasIMUgtjIDMs5_Sydqz-0O_jG5Qhj0&state=xVpkZIPGaGqAQCZIMXZgTrbmKmHJbcKbtM95KO9RwVU%3D

Below is the screenshot

[![error-404][1]][1]

 spring:
  security:
    oauth2:
      client:
        registration:
          okta:
            client-id: clientId
            client-secret: secret
            scope: openid, email
            authorization-grant-type: authorization_code
            redirect-uri: http://localhost:8082/mms-sso/auth
        provider:
          okta:
             issuer-uri: https://dev-40483106.okta.com/oauth2/default
             authorization-uri: https://dev-40483106.okta.com/oauth2/default/v1/authorize                     
        resource:
          server: http://localhost:8081
server: 
  port: 8082
  servlet: 
    context-path: /ui-one

security config


       protected void configure(HttpSecurity http) throws Exception {
           http.authorizeRequests().antMatchers("/login**", "/auth/**", 
               "/auth?**").permitAll().anyRequest().authenticated().and()
                .oauth2Login();


Okta config

Sign-in redirect URIs - http://localhost:8082/mms-sso/auth

Sign out redirect URI - http://localhost:8082/mms-sso/, http://localhost:8082/mms-sso/logout

Controller for redirect

    @GetMapping("/auth")
    String home(@AuthenticationPrincipal OidcUser user) {
        
                return "Welcome to MMS SSO";
        
    }

Upvotes: 0

Views: 990

Answers (1)

Philipp Grigoryev
Philipp Grigoryev

Reputation: 2118

Your controller mapping is for /auth but in redirect you specify it as /mmo-sso/auth.

Upvotes: 0

Related Questions