From 2cfbf078f475de1c93b9574f2c1ff379be0b7559 Mon Sep 17 00:00:00 2001 From: KiSeungMin Date: Wed, 6 Nov 2024 14:59:56 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20robots.txt=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../aisip/OnO/backend/Auth/SecurityConfig.java | 15 +++++++++------ src/main/resources/static/robots.txt | 6 ++++++ 2 files changed, 15 insertions(+), 6 deletions(-) create mode 100644 src/main/resources/static/robots.txt diff --git a/src/main/java/com/aisip/OnO/backend/Auth/SecurityConfig.java b/src/main/java/com/aisip/OnO/backend/Auth/SecurityConfig.java index 249a71b..3b2b1fd 100644 --- a/src/main/java/com/aisip/OnO/backend/Auth/SecurityConfig.java +++ b/src/main/java/com/aisip/OnO/backend/Auth/SecurityConfig.java @@ -23,6 +23,9 @@ public class SecurityConfig { @Value("${spring.jwt.secret}") private String secret; + @Value("${spring.site.url}") // 애플리케이션의 HTTPS 기본 URL을 환경 변수로 받아옴 + private String siteUrl; + @Bean public JwtTokenFilter jwtTokenFilter() { return new JwtTokenFilter(secret); @@ -38,7 +41,7 @@ public PasswordEncoder passwordEncoder() { @Bean public AuthenticationEntryPoint authenticationEntryPoint() { - return (request, response, authException) -> response.sendRedirect("https://ono-app.com/home"); + return (request, response, authException) -> response.sendRedirect(siteUrl+ "/home"); } @Bean @@ -49,7 +52,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti .cors().and().csrf().disable() .authorizeHttpRequests(authorizeRequests -> authorizeRequests - .requestMatchers("/", "/home","/images/**", "/api/auth/**", "/login", "/css/**", "/js/**").permitAll() + .requestMatchers("/", "/robots.txt", "/home","/images/**", "/api/auth/**", "/login", "/css/**", "/js/**").permitAll() .requestMatchers("/admin/**").hasRole("ADMIN") .anyRequest().authenticated() ) @@ -62,16 +65,16 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti Long adminId = userDetails.getUserId(); String token = jwtTokenProvider.createAccessToken(adminId); response.setHeader("Authorization", "Bearer " + token); - response.sendRedirect("/admin/main"); // 성공 후 관리자 페이지로 이동 + response.sendRedirect(siteUrl + "/admin/main"); // 성공 후 관리자 페이지로 이동 }) .failureHandler((request, response, exception) -> { - response.sendRedirect("/login?error"); + response.sendRedirect(siteUrl + "/login?error"); }) .permitAll() ) .logout(logout -> logout - .logoutUrl("/logout") - .logoutSuccessUrl("/login?logout") + .logoutUrl(siteUrl + "/logout") + .logoutSuccessUrl(siteUrl + "/login?logout") .permitAll() ) .sessionManagement(sessionManagement -> diff --git a/src/main/resources/static/robots.txt b/src/main/resources/static/robots.txt new file mode 100644 index 0000000..8b30208 --- /dev/null +++ b/src/main/resources/static/robots.txt @@ -0,0 +1,6 @@ +User-agent: Googlebot +Disallow: +User-agent: AdsBot-Google +Disallow: +User-agent: Googlebot-Image +Disallow: \ No newline at end of file