mirror of
https://github.com/BrenBroZAYT/gameyfin.git
synced 2026-06-16 16:20:04 +00:00
Fix redirection to /setup Page
This commit is contained in:
@@ -20,7 +20,8 @@ class SecurityConfig : VaadinWebSecurity() {
|
|||||||
override fun configure(http: HttpSecurity) {
|
override fun configure(http: HttpSecurity) {
|
||||||
// Configure your static resources with public access before calling super.configure(HttpSecurity) as it adds final anyRequest matcher
|
// Configure your static resources with public access before calling super.configure(HttpSecurity) as it adds final anyRequest matcher
|
||||||
http.authorizeHttpRequests { auth: AuthorizeHttpRequestsConfigurer<HttpSecurity>.AuthorizationManagerRequestMatcherRegistry ->
|
http.authorizeHttpRequests { auth: AuthorizeHttpRequestsConfigurer<HttpSecurity>.AuthorizationManagerRequestMatcherRegistry ->
|
||||||
auth.requestMatchers(AntPathRequestMatcher("/public/**")).permitAll()
|
auth.requestMatchers("/setup").permitAll()
|
||||||
|
.requestMatchers("/public/**").permitAll()
|
||||||
}
|
}
|
||||||
|
|
||||||
super.configure(http)
|
super.configure(http)
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class SetupDataLoader(
|
|||||||
log.info { "We will now set up some data..." }
|
log.info { "We will now set up some data..." }
|
||||||
|
|
||||||
setupRoles()
|
setupRoles()
|
||||||
setupUsers()
|
//setupUsers()
|
||||||
|
|
||||||
log.info { "Setup completed..." }
|
log.info { "Setup completed..." }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import jakarta.servlet.*
|
|||||||
import jakarta.servlet.http.HttpServletRequest
|
import jakarta.servlet.http.HttpServletRequest
|
||||||
import jakarta.servlet.http.HttpServletResponse
|
import jakarta.servlet.http.HttpServletResponse
|
||||||
import org.springframework.core.annotation.Order
|
import org.springframework.core.annotation.Order
|
||||||
import org.springframework.http.HttpStatus
|
|
||||||
import org.springframework.stereotype.Component
|
import org.springframework.stereotype.Component
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
|
||||||
@@ -20,14 +19,24 @@ class SetupFilter(
|
|||||||
val req = servletRequest as HttpServletRequest
|
val req = servletRequest as HttpServletRequest
|
||||||
val res = servletResponse as HttpServletResponse
|
val res = servletResponse as HttpServletResponse
|
||||||
|
|
||||||
val isSetupUri = req.requestURI.contains("/v1/setup")
|
val isSetupUri = req.requestURI.startsWith("/setup")
|
||||||
|
val isLoginUri = req.requestURI.startsWith("/login")
|
||||||
|
|
||||||
if (setupService.isSetupCompleted() && !isSetupUri ||
|
// Skip this filter if the urls don't match
|
||||||
!setupService.isSetupCompleted() && isSetupUri
|
if (!(isSetupUri || isLoginUri)) {
|
||||||
) {
|
|
||||||
filterChain.doFilter(req, res)
|
filterChain.doFilter(req, res)
|
||||||
} else {
|
return
|
||||||
res.status = HttpStatus.FORBIDDEN.value()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val isSetupComplete = setupService.isSetupCompleted()
|
||||||
|
|
||||||
|
if (isSetupUri && isSetupComplete) {
|
||||||
|
res.sendRedirect("/login")
|
||||||
|
} else if (isLoginUri && !isSetupComplete) {
|
||||||
|
res.sendRedirect("/setup")
|
||||||
|
}
|
||||||
|
|
||||||
|
// took me longer than I want to admit to realize you always need to call doFilter() at the end
|
||||||
|
filterChain.doFilter(req, res)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user