Вот класс конфигурации безопасности
Код: Выделить всё
@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
http
.csrf((csrf) -> csrf
.csrfTokenRepository(csrfTokenRepository()))
.csrf((csrf) -> csrf
.csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse()))
.authorizeHttpRequests((requests) -> requests
.requestMatchers("/", "/login", "/signup",
"buyer/buyer-registration",
"buyer/buyer-reg-success", "buyer/buyer-reg-error", "/registration-error").permitAll()
.requestMatchers("/edit", "/delete").authenticated()
.anyRequest().authenticated())
.formLogin((form) -> form
.loginPage("/login")
.defaultSuccessUrl("/home", true)
.failureUrl("/login?error=true")
.permitAll())
.logout((logout) -> logout
.logoutSuccessUrl("/")
.permitAll())
.sessionManagement((session) -> session
.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
.authenticationProvider(authenticationProvider)
.addFilterBefore(jwtAuthFilter, UsernamePasswordAuthenticationFilter.class);
Конфигурация безопасности и коды Thymeleaf
Код: Выделить всё
Buyer Registration
Buyer Registration
Username:
First Name:
Last Name:
Location
Kindred:
Village:
Community:
LGA:
State:
Country:
Google Location
Google Coordinates:
Register
Код: Выделить всё
2024-06-20 07:16:00 DEBUG o.s.orm.jpa.JpaTransactionManager - Initiating transaction commit
2024-06-20 07:16:00 DEBUG o.s.orm.jpa.JpaTransactionManager - Committing JPA transaction on EntityManager [SessionImpl(1555152978)]
2024-06-20 07:16:00 DEBUG o.s.orm.jpa.JpaTransactionManager - Closing JPA EntityManager [SessionImpl(1555152978)] after transaction
2024-06-20 07:16:00 DEBUG o.s.s.j.JdbcIndexedSessionRepository - Cleaned up 0 expired sessions
2024-06-20 07:16:06 DEBUG o.s.security.web.FilterChainProxy - Securing POST /buyer/registerNewBuyer
2024-06-20 07:16:06 DEBUG o.s.s.w.h.S.SESSION_LOGGER - No session found by id: Caching result for getSession(false) for this HttpServletRequest.
2024-06-20 07:16:06 DEBUG o.s.s.w.a.AnonymousAuthenticationFilter - Set SecurityContextHolder to anonymous SecurityContext
2024-06-20 07:16:06 DEBUG o.s.s.web.DefaultRedirectStrategy - Redirecting to http://localhost:8080/login
2024-06-20 07:16:06 DEBUG o.s.security.web.FilterChainProxy - Securing GET /login
2024-06-20 07:16:06 DEBUG o.s.s.w.h.S.SESSION_LOGGER - No session found by id: Caching result for getSession(false) for this HttpServletRequest.
2024-06-20 07:16:06 DEBUG o.s.s.w.a.AnonymousAuthenticationFilter - Set SecurityContextHolder to anonymous SecurityContext
2024-06-20 07:16:06 DEBUG o.s.security.web.FilterChainProxy - Secured GET /login
2024-06-20 07:16:06 DEBUG o.s.web.servlet.DispatcherServlet - GET "/login", parameters={}
2024-06-20 07:16:06 DEBUG o.s.s.w.h.S.SESSION_LOGGER - No session found by id: Caching result for getSession(false) for this HttpServletRequest.
2024-06-20 07:16:06 DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped to com.marketgb.productgb.AuthenticationController#login(Model)
2024-06-20 07:16:06 DEBUG o.s.u.f.SpringTemplateLoader - Looking for FreeMarker template with name [login_en_US.ftlh]
2024-06-20 07:16:06 DEBUG o.s.u.f.SpringTemplateLoader - Looking for FreeMarker template with name [login_en.ftlh]
2024-06-20 07:16:06 DEBUG o.s.u.f.SpringTemplateLoader - Looking for FreeMarker template with name [login.ftlh]
2024-06-20 07:16:06 DEBUG o.s.w.s.v.ContentNegotiatingViewResolver - Selected 'text/html' given [text/html, application/xhtml+xml, image/avif, image/webp, image/apng, application/xml;q=0.9, */*;q=0.8, application/signed-exchange;v=b3;q=0.7]
2024-06-20 07:16:06 DEBUG o.s.s.w.h.S.SESSION_LOGGER - No session found by id: Caching result for getSession(false) for this HttpServletRequest.
2024-06-20 07:16:06 DEBUG o.s.web.servlet.DispatcherServlet - Completed 200 OK
2024-06-20 07:16:06 DEBUG o.s.s.w.h.S.SESSION_LOGGER - No session found by id: Caching result for getSession(false) for this HttpServletRequest.
2024-06-20 07:16:06 DEBUG o.s.c.f.c.c.BeanFactoryAwareFunctionRegistry - Function 'favicon.ico' is not found in cache
2024-06-20 07:16:06 DEBUG o.s.c.f.c.c.BeanFactoryAwareFunctionRegistry - Function 'favicon.ico' is not available in FunctionCatalog or BeanFactory
2024-06-20 07:16:06 DEBUG o.s.c.f.c.c.BeanFactoryAwareFunctionRegistry - Function 'favicon.ico' is not found in cache
2024-06-20 07:16:06 DEBUG o.s.c.f.c.c.BeanFactoryAwareFunctionRegistry - Function 'favicon.ico' is not found in cache
2024-06-20 07:16:06 DEBUG o.s.c.f.c.c.BeanFactoryAwareFunctionRegistry - Function 'favicon.ico' is not available in FunctionCatalog or BeanFactory
2024-06-20 07:16:06 DEBUG o.s.c.f.c.c.BeanFactoryAwareFunctionRegistry - Function 'favicon.ico' is not found in cache
2024-06-20 07:16:06 DEBUG o.s.security.web.FilterChainProxy - Securing GET /favicon.ico
2024-06-20 07:16:06 DEBUG o.s.s.w.h.S.SESSION_LOGGER - No session found by id: Caching result for getSession(false) for this HttpServletRequest.
2024-06-20 07:16:06 DEBUG o.s.s.w.a.AnonymousAuthenticationFilter - Set SecurityContextHolder to anonymous SecurityContext
2024-06-20 07:16:06 DEBUG o.s.s.web.DefaultRedirectStrategy - Redirecting to http://localhost:8080/login
2024-06-20 07:16:06 DEBUG o.s.security.web.FilterChainProxy - Securing GET /login
2024-06-20 07:16:06 DEBUG o.s.s.w.h.S.SESSION_LOGGER - No session found by id: Caching result for getSession(false) for this HttpServletRequest.
2024-06-20 07:16:06 DEBUG o.s.s.w.a.AnonymousAuthenticationFilter - Set SecurityContextHolder to anonymous SecurityContext
2024-06-20 07:16:06 DEBUG o.s.security.web.FilterChainProxy - Secured GET /login
2024-06-20 07:16:06 DEBUG o.s.web.servlet.DispatcherServlet - GET "/login", parameters={}
2024-06-20 07:16:06 DEBUG o.s.s.w.h.S.SESSION_LOGGER - No session found by id: Caching result for getSession(false) for this HttpServletRequest.
2024-06-20 07:16:06 DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped to com.marketgb.productgb.AuthenticationController#login(Model)
2024-06-20 07:16:06 DEBUG o.s.w.s.v.ContentNegotiatingViewResolver - Selected '*/*' given [image/avif, image/webp, image/apng, image/svg+xml, image/*, */*;q=0.8]
2024-06-20 07:16:06 DEBUG o.s.s.w.h.S.SESSION_LOGGER - No session found by id: Caching result for getSession(false) for this HttpServletRequest.
2024-06-20 07:16:06 DEBUG o.s.web.servlet.DispatcherServlet - Completed 200 OK
2024-06-20 07:16:06 DEBUG o.s.s.w.h.S.SESSION_LOGGER - No session found by id: Caching result for getSession(false) for this HttpServletRequest.
2024-06-20 07:17:00 DEBUG o.s.orm.jpa.JpaTransactionManager - Creating new transaction with name [null]: PROPAGATION_REQUIRES_NEW,ISOLATION_DEFAULT
2024-06-20 07:17:00 DEBUG o.s.orm.jpa.JpaTransactionManager - Opened new EntityManager [SessionImpl(874249822)] for JPA transaction
2024-06-20 07:17:00 DEBUG o.s.orm.jpa.JpaTransactionManager - Exposing JPA transaction as JDBC [org.springframework.orm.jpa.vendor.HibernateJpaDialect$HibernateConnectionHandle@2b52e6c4]
2024-06-20 07:17:00 DEBUG o.s.jdbc.core.JdbcTemplate - Executing prepared SQL update
2024-06-20 07:17:00 DEBUG o.s.jdbc.core.JdbcTemplate - Executing prepared SQL statement [DELETE FROM SPRING_SESSION
WHERE EXPIRY_TIME < ?
Подробнее здесь: https://stackoverflow.com/questions/786 ... -hibernate