Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions backend/src/main/java/io/f1/backend/BackendApplication.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package io.f1.backend;

import io.f1.backend.domain.user.dto.OAuthRedirectProperties;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;

@EnableJpaAuditing
@SpringBootApplication
@EnableConfigurationProperties(OAuthRedirectProperties.class)
public class BackendApplication {

public static void main(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.f1.backend.domain.user.app.handler;

import io.f1.backend.domain.user.dto.OAuthRedirectProperties;
import io.f1.backend.domain.user.dto.UserPrincipal;

import jakarta.servlet.http.HttpServletRequest;
Expand All @@ -17,6 +18,8 @@
@RequiredArgsConstructor
public class OAuthSuccessHandler extends SimpleUrlAuthenticationSuccessHandler {

private final OAuthRedirectProperties redirectProperties;

@Override
public void onAuthenticationSuccess(
HttpServletRequest request, HttpServletResponse response, Authentication authentication)
Expand All @@ -25,11 +28,9 @@ public void onAuthenticationSuccess(
response.setContentType("application/json;charset=UTF-8");

if (principal.getUserNickname() == null) {
String SIGNUP_REDIRECT_URL = "http://localhost:3000/signup";
getRedirectStrategy().sendRedirect(request, response, SIGNUP_REDIRECT_URL);
getRedirectStrategy().sendRedirect(request, response, redirectProperties.signupUrl());
} else {
String MAIN_REDIRECT_URL = "http://localhost:3000/room";
getRedirectStrategy().sendRedirect(request, response, MAIN_REDIRECT_URL);
getRedirectStrategy().sendRedirect(request, response, redirectProperties.mainUrl());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package io.f1.backend.domain.user.dto;

import org.springframework.boot.context.properties.ConfigurationProperties;

@ConfigurationProperties(prefix = "custom.oauth.redirect")
public record OAuthRedirectProperties(String signupUrl, String mainUrl) {}
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.time.LocalDateTime;

@Getter
@Setter // quizService의 퀴즈 조회 메서드 구현 시까지 임시 사용
@Entity
@Table(name = "`user`")
@NoArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import io.f1.backend.domain.user.app.handler.CustomAuthenticationEntryPoint;
import io.f1.backend.domain.user.app.handler.OAuthSuccessHandler;
import io.f1.backend.domain.user.app.handler.UserAndAdminLogoutSuccessHandler;
import io.f1.backend.global.filter.DevTokenAuthFilter;

import lombok.RequiredArgsConstructor;

Expand All @@ -19,7 +18,6 @@
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;

@Configuration
@EnableWebSecurity
Expand All @@ -40,8 +38,6 @@ public class SecurityConfig {
public SecurityFilterChain userFilterChain(HttpSecurity http) throws Exception {
http.csrf(AbstractHttpConfigurer::disable)
.cors(Customizer.withDefaults())
.addFilterBefore(
new DevTokenAuthFilter(), UsernamePasswordAuthenticationFilter.class)
.exceptionHandling(
exception ->
exception.authenticationEntryPoint(customAuthenticationEntryPoint))
Expand Down

This file was deleted.

6 changes: 6 additions & 0 deletions backend/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ server:
secure: true
http-only: true
timeout: ${SESSION_TIMEOUT}

custom:
oauth:
redirect:
signup-url: ${SIGNUP_URL}
main-url: ${MAIN_URL}
---
spring:
config:
Expand Down