chore: plans 폴더 git 추적 제거 및 코드 업데이트
- plans/ 폴더를 .gitignore에 추가하고 git 추적에서 제거 - WtmAuthController, UserRoleRepository 수정 - ApprovalPendingView, auth.service 수정 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
이 Commit은 다음에 포함되어 있습니다:
@@ -1,21 +1,48 @@
|
||||
package kr.co.accura.wtm.api;
|
||||
|
||||
import kr.co.accura.wbx.spring.auth.WbxUserDetails;
|
||||
import kr.co.accura.wtm.domain.user.repository.UserRoleRepository;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* WTM-specific auth endpoints that supplement wbx-spring-core's AuthController.
|
||||
* <p>
|
||||
* wbx-spring-core already provides: /api/wtm/auth/login, /me, /refresh, /logout, /password/change.
|
||||
* This controller adds only the MISSING endpoints: SSO and password-reset.
|
||||
* Overrides /me to include WTM role information from user_roles table.
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
public class WtmAuthController {
|
||||
|
||||
private final UserRoleRepository userRoleRepository;
|
||||
|
||||
/**
|
||||
* 내 정보 조회 — WTM 역할 포함 (별도 경로)
|
||||
*/
|
||||
@GetMapping("/api/wtm/auth/me/profile")
|
||||
public Map<String, Object> me(@AuthenticationPrincipal WbxUserDetails user) {
|
||||
// wtm user_roles에서 역할 코드 조회 (email 매칭)
|
||||
List<String> roles = userRoleRepository.findRoleCodesByUserEmail(user.getEmail());
|
||||
if (roles.isEmpty() && user.isAdmin()) {
|
||||
roles = List.of("SA");
|
||||
}
|
||||
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("id", user.getId());
|
||||
result.put("email", user.getEmail());
|
||||
result.put("username", user.getUsername());
|
||||
result.put("full_name", user.getFullName());
|
||||
result.put("is_admin", user.isAdmin());
|
||||
result.put("department_id", user.getDepartmentId() != null ? user.getDepartmentId() : 0);
|
||||
result.put("roles", roles);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* SSO initiation — redirects to OAuth2 authorization endpoint.
|
||||
* Requires Azure Entra ID configuration.
|
||||
|
||||
@@ -2,6 +2,8 @@ package kr.co.accura.wtm.domain.user.repository;
|
||||
|
||||
import kr.co.accura.wtm.domain.user.entity.UserRole;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
@@ -14,4 +16,7 @@ public interface UserRoleRepository extends JpaRepository<UserRole, Long> {
|
||||
List<UserRole> findByUser_IdAndProjectId(Long userId, Long projectId);
|
||||
|
||||
void deleteByUser_IdAndProjectId(Long userId, Long projectId);
|
||||
|
||||
@Query("SELECT r.code FROM UserRole ur JOIN ur.role r JOIN ur.user u WHERE u.email = :email")
|
||||
List<String> findRoleCodesByUserEmail(@Param("email") String email);
|
||||
}
|
||||
|
||||
새 Issue에서 참조
사용자 차단