Skip to content

Commit

Permalink
Fixed startup issues
Browse files Browse the repository at this point in the history
  • Loading branch information
xmppjingle committed Jan 18, 2023
1 parent 5a433f5 commit bde4b82
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import io.lettuce.core.RedisClient
import io.lettuce.core.api.StatefulRedisConnection
import io.lettuce.core.api.sync.RedisCommands
import io.lettuce.core.dynamic.RedisCommandFactory
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.beans.factory.annotation.Value
import org.springframework.data.redis.core.RedisTemplate
import org.springframework.security.authentication.AuthenticationManager
import org.springframework.security.authentication.BadCredentialsException
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken
import org.springframework.security.core.Authentication
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter
import org.springframework.stereotype.Component
import javax.annotation.PostConstruct
import javax.servlet.http.HttpServletRequest
import javax.servlet.http.HttpServletResponse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import org.springframework.beans.factory.annotation.Autowired
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.http.HttpMethod
import org.springframework.security.authentication.AuthenticationManager
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity
import org.springframework.security.config.annotation.web.builders.HttpSecurity
import org.springframework.security.config.annotation.web.builders.WebSecurity
Expand All @@ -22,8 +23,7 @@ import springfox.documentation.spring.web.plugins.Docket
@Component
internal class SecurityConfig : WebSecurityConfigurerAdapter() {

@Autowired
lateinit var apiKeyAuthFilter: ApiKeyAuthFilter
private lateinit var apiKeyAuthFilter: ApiKeyAuthFilter

@Throws(Exception::class)
override fun configure(web: WebSecurity) {
Expand All @@ -46,6 +46,7 @@ internal class SecurityConfig : WebSecurityConfigurerAdapter() {

@Throws(java.lang.Exception::class)
override fun configure(http: HttpSecurity) {
apiKeyAuthFilter = ApiKeyAuthFilter(authenticationManager())
http.addFilterBefore(apiKeyAuthFilter, UsernamePasswordAuthenticationFilter::class.java)
.authorizeRequests()
// Whitelisted endpoints that do not require authentication
Expand All @@ -63,4 +64,9 @@ internal class SecurityConfig : WebSecurityConfigurerAdapter() {
.paths(PathSelectors.any())
.build()
}
}

@Bean
override fun authenticationManagerBean(): AuthenticationManager {
return super.authenticationManagerBean()
}
}

0 comments on commit bde4b82

Please sign in to comment.