I am trying to deploy my springboot app to heroku but I am getting an error that it cannot find a JwtDecoder bean. I have tried googling it a bit but can't find anything that helps. Everything works fine locally, just not when deployed to heroku.
Here is my heroku log --tail:
2021-02-27T20:18:45.134160+00:00 app[web.1]: ***************************
2021-02-27T20:18:45.134160+00:00 app[web.1]: APPLICATION FAILED TO START
2021-02-27T20:18:45.134160+00:00 app[web.1]: ***************************
2021-02-27T20:18:45.134161+00:00 app[web.1]:
2021-02-27T20:18:45.134161+00:00 app[web.1]: Description:
2021-02-27T20:18:45.134161+00:00 app[web.1]:
2021-02-27T20:18:45.134179+00:00 app[web.1]: Method springSecurityFilterChain in
org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration 
required a bean of type 'org.springframework.security.oauth2.jwt.JwtDecoder' that 
could not be found.
2021-02-27T20:18:45.134179+00:00 app[web.1]: 
2021-02-27T20:18:45.134179+00:00 app[web.1]:
2021-02-27T20:18:45.134180+00:00 app[web.1]: Action:
2021-02-27T20:18:45.134180+00:00 app[web.1]:
2021-02-27T20:18:45.134181+00:00 app[web.1]: Consider defining a bean of type 
'org.springframework.security.oauth2.jwt.JwtDecoder' in your configuration.
WebSecurityConfig:
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
    @Override
    protected void configure(HttpSecurity http) throws Exception{
        http.csrf().disable().cors().configurationSource(corsConfigurationSource())
                .and()
                .authorizeRequests()
                .antMatchers("/*")
                .authenticated()
                .and()
                .oauth2ResourceServer()
                .jwt();
    }
I'm not sure what else to include... Feel free to comment on what else I should add. Or, the repo is at https://github.com/AndreTheTallGuy/Kelp2
Thank you in advance for any help you may be able to provide!
Try to specify the jwk-set-uri configuration in application.yml:
spring:
  security:
    oauth2:
      resourceserver:
        jwt:
          jwk-set-uri: https://example.com/.well-known/jwks.json
For application.properties:
spring.security.oauth2.resourceserver.jwt.jwk-set-uri=https://example.com/.well-known/jwks.json
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With