Skip to content

Commit

Permalink
feat: robots.txt 파일 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
KiSeungMin committed Nov 6, 2024
1 parent 0d0a3ed commit 2cfbf07
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/main/java/com/aisip/OnO/backend/Auth/SecurityConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
Expand All @@ -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()
)
Expand All @@ -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 ->
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/static/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
User-agent: Googlebot
Disallow:
User-agent: AdsBot-Google
Disallow:
User-agent: Googlebot-Image
Disallow:

0 comments on commit 2cfbf07

Please sign in to comment.