# Spring MVC + Okta

**URL:** <https://devforum.okta.com/t/spring-mvc-okta/23886>\
**Category:** OAuth/OIDC\
**Created:** [April 6, 2023, 2:25am UTC](https://devforum.okta.com/t/spring-mvc-okta/23886 "2023-04-06T02:25:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![uma](https://avatars.discourse-cdn.com/v4/letter/u/ba9def/32.png) [@uma](https://devforum.okta.com/u/uma)\
**Post date:** [April 6, 2023, 2:25am UTC](https://devforum.okta.com/t/spring-mvc-okta/23886/1 "2023-04-06T02:25:09Z")

</div>

Hi All,

I am working on to integrate Okta in my Spring MVC project, I searched for Spring projects with Okta but I am finding only Okta with Spring boot project, could you help me with my query to integrate Okta in any spring MVC project?

---

<div class="post-metadata">

**Author:** ![erik](https://avatars.discourse-cdn.com/v4/letter/e/b5ac83/32.png) [@erik](https://devforum.okta.com/u/erik)\
**Post date:** [April 7, 2023, 5:40am UTC](https://devforum.okta.com/t/spring-mvc-okta/23886/2 "2023-04-07T05:40:10Z")

</div>

Hello,

The Okta Spring SDK uses Spring Boot. This SDK relies on Spring Security for most the functionality.

Spring Security has a predefined OAuth provider for Okta, [see here](https://docs.spring.io/spring-security/site/docs/5.2.12.RELEASE/reference/html/oauth2.html#oauth2login-common-oauth2-provider).

The [following tutorial](https://www.baeldung.com/spring-security-5-oauth2-login) demonstrates OAuth with Spring Security in both Spring, and Spring Boot.

Hopefully that helps get you started.

Thank You,

---

<div class="post-metadata">

**Author:** ![uma](https://avatars.discourse-cdn.com/v4/letter/u/ba9def/32.png) [@uma](https://devforum.okta.com/u/uma)\
**Post date:** [May 3, 2023, 6:12pm UTC](https://devforum.okta.com/t/spring-mvc-okta/23886/3 "2023-05-03T18:12:18Z")

</div>

Thank you so much! I will take a look and come back with any questions.

---

<div class="post-metadata">

**Author:** ![uma](https://avatars.discourse-cdn.com/v4/letter/u/ba9def/32.png) [@uma](https://devforum.okta.com/u/uma)\
**Post date:** [May 10, 2023, 12:38am UTC](https://devforum.okta.com/t/spring-mvc-okta/23886/4 "2023-05-10T00:38:47Z")

</div>

I tried following this blog and having the below issue. Any help in this regard is much appreciated!

@Bean  
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {  
http  
.csrf().disable()  
.authorizeRequests()  
.antMatchers(“/”).permitAll()  
// all other requests  
.anyRequest().authenticated()  
// set logout URL  
.and().logout().logoutSuccessUrl(“/”)  
.addLogoutHandler(new CustomLogoutHandler())  
// enable OAuth2/OIDC  
.and().oauth2Client()  
.and().oauth2Login()  
.defaultSuccessUrl(“/loginSuccess.rest”, true);;  
return http.build();  
}

It kicks in Okta login widget and after login it’s going in a loop and not returning to the client application.

---

<div class="post-metadata">

**Author:** ![andrea](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/andrea/32/2172_2.png) [@andrea](https://devforum.okta.com/u/andrea)\
**Post date:** [February 13, 2024, 11:07pm UTC](https://devforum.okta.com/t/spring-mvc-okta/23886/5 "2024-02-13T23:07:06Z")

</div>

Closed on February 13, 2024, 11:07pm UTC


