2023-10-05 11:42:24 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2014-2023 the original author or authors.
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
2023-11-05 10:54:42 +01:00
|
|
|
package catering;
|
2023-10-05 11:42:24 +02:00
|
|
|
|
|
|
|
import org.salespointframework.EnableSalespoint;
|
|
|
|
import org.springframework.boot.SpringApplication;
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
|
|
|
import org.springframework.security.config.annotation.web.configurers.HeadersConfigurer.FrameOptionsConfig;
|
|
|
|
import org.springframework.security.web.SecurityFilterChain;
|
2023-11-06 19:48:33 +01:00
|
|
|
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
|
|
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
2023-10-05 11:42:24 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The main application class.
|
|
|
|
*/
|
|
|
|
@EnableSalespoint
|
|
|
|
public class Application {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The main application method
|
2023-11-15 15:35:53 +01:00
|
|
|
*
|
2023-10-05 11:42:24 +02:00
|
|
|
* @param args application arguments
|
|
|
|
*/
|
|
|
|
public static void main(String[] args) {
|
|
|
|
SpringApplication.run(Application.class, args);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Configuration
|
|
|
|
static class WebSecurityConfiguration {
|
|
|
|
|
|
|
|
@Bean
|
2023-11-06 19:48:33 +01:00
|
|
|
SecurityFilterChain WebSecurity(HttpSecurity http) throws Exception {
|
2023-10-05 11:42:24 +02:00
|
|
|
|
|
|
|
return http
|
|
|
|
.headers(headers -> headers.frameOptions(FrameOptionsConfig::sameOrigin))
|
|
|
|
.csrf(csrf -> csrf.disable())
|
2023-11-06 19:48:33 +01:00
|
|
|
.formLogin(login -> login.loginPage("/login").loginProcessingUrl("/login"))
|
2023-10-05 11:42:24 +02:00
|
|
|
.logout(logout -> logout.logoutUrl("/logout").logoutSuccessUrl("/"))
|
2023-11-11 17:56:01 +01:00
|
|
|
.exceptionHandling(exceptionHandling -> exceptionHandling.accessDeniedPage("/unauthorized"))
|
2023-10-05 11:42:24 +02:00
|
|
|
.build();
|
|
|
|
}
|
|
|
|
}
|
2023-11-06 19:48:33 +01:00
|
|
|
|
|
|
|
@Configuration
|
|
|
|
static class WebConfiguration implements WebMvcConfigurer {
|
|
|
|
@Override
|
|
|
|
public void addViewControllers(ViewControllerRegistry registry) {
|
|
|
|
registry.addViewController("/login").setViewName("login");
|
|
|
|
registry.addViewController("/").setViewName("index");
|
|
|
|
}
|
|
|
|
}
|
2023-10-05 11:42:24 +02:00
|
|
|
}
|