- Spring Security Basic Auth 인증 도입 (Bypass 데이터 API만) - 계정 신청/승인/거절 백엔드 API 및 프론트엔드 구현 - 계정 관리 (CRUD, 비밀번호 재설정, 상태/기간 수정) - 401 응답에 계정 상태 상세 메시지 포함 - Swagger UI Basic Auth 스킴/환경별 그룹 노출 연동 - 신청 폼 정규식 검증 및 접근기간 프리셋 선택
119 lines
2.7 KiB
Java
119 lines
2.7 KiB
Java
package com.snp.batch.global.model;
|
|
|
|
import jakarta.persistence.*;
|
|
import lombok.*;
|
|
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDateTime;
|
|
|
|
/**
|
|
* Bypass API 계정 정보를 저장하는 엔티티
|
|
* 외부 사용자에게 Bypass API 접근 권한을 부여하기 위한 계정 정보 관리
|
|
*
|
|
* JPA를 사용하므로 @PrePersist, @PreUpdate로 감사 필드 자동 설정
|
|
*/
|
|
@Entity
|
|
@Table(name = "bypass_api_account",
|
|
indexes = {
|
|
@Index(name = "idx_bypass_account_username", columnList = "username"),
|
|
@Index(name = "idx_bypass_account_status", columnList = "status")
|
|
}
|
|
)
|
|
@Getter
|
|
@Setter
|
|
@Builder
|
|
@NoArgsConstructor
|
|
@AllArgsConstructor
|
|
public class BypassApiAccount {
|
|
|
|
@Id
|
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
private Long id;
|
|
|
|
/**
|
|
* 로그인 아이디 (고유값)
|
|
*/
|
|
@Column(name = "username", nullable = false, unique = true, length = 50)
|
|
private String username;
|
|
|
|
/**
|
|
* 해시된 비밀번호
|
|
*/
|
|
@Column(name = "password_hash", nullable = false, length = 255)
|
|
private String passwordHash;
|
|
|
|
/**
|
|
* 표시명
|
|
*/
|
|
@Column(name = "display_name", nullable = false, length = 100)
|
|
private String displayName;
|
|
|
|
/**
|
|
* 소속 기관
|
|
*/
|
|
@Column(name = "organization", length = 200)
|
|
private String organization;
|
|
|
|
/**
|
|
* 이메일
|
|
*/
|
|
@Column(name = "email", length = 200)
|
|
private String email;
|
|
|
|
/**
|
|
* 연락처
|
|
*/
|
|
@Column(name = "phone", length = 50)
|
|
private String phone;
|
|
|
|
/**
|
|
* 계정 상태 (ACTIVE, SUSPENDED, EXPIRED)
|
|
*/
|
|
@Enumerated(EnumType.STRING)
|
|
@Column(name = "status", nullable = false, length = 20)
|
|
@Builder.Default
|
|
private AccountStatus status = AccountStatus.ACTIVE;
|
|
|
|
/**
|
|
* 접근 허용 시작일
|
|
*/
|
|
@Column(name = "access_start_date")
|
|
private LocalDate accessStartDate;
|
|
|
|
/**
|
|
* 접근 허용 종료일
|
|
*/
|
|
@Column(name = "access_end_date")
|
|
private LocalDate accessEndDate;
|
|
|
|
/**
|
|
* 생성 일시 (감사 필드)
|
|
*/
|
|
@Column(name = "created_at", nullable = false, updatable = false)
|
|
private LocalDateTime createdAt;
|
|
|
|
/**
|
|
* 수정 일시 (감사 필드)
|
|
*/
|
|
@Column(name = "updated_at", nullable = false)
|
|
private LocalDateTime updatedAt;
|
|
|
|
/**
|
|
* 엔티티 저장 전 자동 호출 (INSERT 시)
|
|
*/
|
|
@PrePersist
|
|
protected void onCreate() {
|
|
LocalDateTime now = LocalDateTime.now();
|
|
this.createdAt = now;
|
|
this.updatedAt = now;
|
|
}
|
|
|
|
/**
|
|
* 엔티티 업데이트 전 자동 호출 (UPDATE 시)
|
|
*/
|
|
@PreUpdate
|
|
protected void onUpdate() {
|
|
this.updatedAt = LocalDateTime.now();
|
|
}
|
|
}
|