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

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.NoOpPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
Expand All @@ -31,14 +32,33 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
auth ->
auth.requestMatchers(SecurityEndpoints.PUBLIC.getMatchers())
.permitAll()
.requestMatchers(SecurityEndpoints.ADMIN.getMatchers())
.hasRole("ADMIN")
.requestMatchers("/auth/login", "/auth/logout")
.permitAll()
.requestMatchers(SecurityEndpoints.DATA_ADMIN.getMatchers())
.hasAuthority("SUPER_ADMIN")
.requestMatchers(SecurityEndpoints.DATA_ENGINEER.getMatchers())
.hasAnyAuthority(
"SUPER_ADMIN", "ADMIN", "SENIOR_DATA_ENGINEER", "DATA_ENGINEER")
.requestMatchers(SecurityEndpoints.ANALYST.getMatchers())
.hasAnyAuthority(
"SUPER_ADMIN",
"ADMIN",
"SENIOR_DATA_ENGINEER",
"DATA_ENGINEER",
"SENIOR_DATA_ANALYST",
"DATA_ANALYST",
"VIEWER")
.requestMatchers(SecurityEndpoints.OPS.getMatchers())
.hasAnyAuthority(
"SUPER_ADMIN", "ADMIN", "SENIOR_DATA_ENGINEER", "DATA_ENGINEER")
.requestMatchers(SecurityEndpoints.USER.getMatchers())
.hasRole("USER")
.authenticated()
.anyRequest()
.authenticated())
.formLogin(form -> form.loginPage("/login").defaultSuccessUrl("/").permitAll())
.logout(logout -> logout.logoutSuccessUrl("/login").permitAll())
.formLogin(AbstractHttpConfigurer::disable)
.logout(
logout -> logout.logoutUrl("/auth/logout").logoutSuccessUrl("/auth/login").permitAll())
.csrf(AbstractHttpConfigurer::disable) // API 사용을 위해 CSRF 비활성화
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,20 @@ public enum SecurityEndpoints {
PUBLIC(
"/", "/login", "/register", "/api/public/**", "/health", "/css/**", "/js/**", "/images/**"),

ADMIN("/admin/**", "/api/admin/**", "/management/**", "/actuator/**"),
// 데이터 관리 관련 엔드포인트
DATA_ADMIN("/admin/**", "/api/admin/**", "/management/**", "/actuator/**"),

USER("/user/**", "/api/user/**", "/profile/**", "/dashboard");
// 데이터 엔지니어 전용 엔드포인트
DATA_ENGINEER("/api/preprocessing/**", "/api/pipeline/**", "/api/jobs/**"),

// 분석가 전용 엔드포인트
ANALYST("/api/analysis/**", "/api/reports/**", "/api/dashboard/**"),

// 운영 관련 엔드포인트
OPS("/api/scheduler/**", "/api/monitoring/**"),

// 일반 사용자 엔드포인트
USER("/user/**", "/profile/**");

private final String[] patterns;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.gltkorea.icebang.domain.auth.controller;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.gltkorea.icebang.domain.auth.dto.LoginRequest;
import com.gltkorea.icebang.domain.auth.service.AuthService;

import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;

@RequestMapping("/auth")
@RestController
@RequiredArgsConstructor
public class AuthController {
private final AuthService authService;

@PostMapping("/login")
public ResponseEntity<?> login(
@RequestBody LoginRequest loginRequest, HttpServletRequest request) {
authService.login(loginRequest.getUserName(), loginRequest.getPassword());

request.getSession(true);
return ResponseEntity.ok("success"); // @TODO:: 201로 변경
}
}
Loading
Loading