Skip to content

Commit

Permalink
feat: .http 환경변수 env 파일 저장 (#171)
Browse files Browse the repository at this point in the history
* refactor: 불필요한 내용 삭제

* chore: 불필요한 의존성 제거

* feat: .http 토큰 정보 환경변수로 저장
  • Loading branch information
eunbc committed Jan 9, 2024
1 parent 5cbc5b9 commit ee033f8
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 30 deletions.
5 changes: 1 addition & 4 deletions api/api-member/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'

runtimeOnly 'com.h2database:h2'
runtimeOnly 'com.mysql:mysql-connector-j'


// security
implementation 'org.springframework.boot:spring-boot-starter-security'
}
49 changes: 38 additions & 11 deletions api/api-member/http/test.http
Original file line number Diff line number Diff line change
@@ -1,28 +1,51 @@
@token = eyJhbGciOiJIUzI1NiJ9.eyJpZCI6Mywic3ViIjoiZGh4bDUwQG5hdmVyLmNvbSIsImlhdCI6MTcwNDYxNjU4NSwiZXhwIjoyMDY0NjE2NTg1LCJhdXRob3JpdHkiOiJST0xFX1VTRVIifQ.OIiQazdvmv-bsZp0VroiouW5gEqNAj7ROqRTOcLbWXQ
@adminToken = eyJhbGciOiJIUzI1NiJ9.eyJpZCI6Miwic3ViIjoiYWRtaW5AZXhhbXBsZS5jb20iLCJpYXQiOjE3MDQ2Mzc1NzgsImV4cCI6MjA2NDYzNzU3OCwiYXV0aG9yaXR5IjoiUk9MRV9BRE1JTiJ9.lAXg2NbcVeuSak6IW-AUNKC6zqd_0x_ER8RU3CMxNpk

### 토큰 갱신
POST http://localhost:8081/api/v1/auth/refresh
## AUTH

### 로그인 - 슈퍼 관리자
POST http://localhost:8081/api/v1/auth/admin/login
Content-Type: application/json

{
"refreshToken": "a718e554-fad4-48c2-a131-d73228937605"
"email": "[email protected]",
"password": "user1234"
}

### 로그인 - 슈퍼 관리자
### 로그인 - 관리자
POST http://localhost:8081/api/v1/auth/admin/login
Content-Type: application/json

{
"email": "superadmin@example.com",
"email": "admin@example.com",
"password": "user1234"
}

### 멤버 로그인
POST http://localhost:8081/api/v1/auth/members/login
Content-Type: application/json

{
"email": "[email protected]",
"password": "user1234"
}

### 토큰 갱신
POST http://localhost:8081/api/v1/auth/refresh
Content-Type: application/json

{
"refreshToken": "{{refreshToken}}"
}

===

## ADMIN MANAGEMENT

### 관리자 등록 - 슈퍼 관리자
POST http://localhost:8081/api/v1/admin/management
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJpZCI6MSwic3ViIjoic3VwZXJhZG1pbkBleGFtcGxlLmNvbSIsImlhdCI6MTcwNDY0MzY2MSwiZXhwIjoxNzA0NjQ1NDYxLCJhdXRob3JpdHkiOiJST0xFX1NVUEVSQURNSU4ifQ.CGgjH4e4FTvz8s-adQBd2S6T5N8Uo9YLfht3LIkE0Js
Authorization: Bearer {{superAdminToken}}

{
"name": "testAdmin",
Expand All @@ -35,12 +58,12 @@ Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJpZCI6MSwic3ViIjoic3VwZXJhZG1pbkBle

### 관리자 목록 조회 - 슈퍼 관리자
GET http://localhost:8081/api/v1/admin/management
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJpZCI6MSwic3ViIjoic3VwZXJhZG1pbkBleGFtcGxlLmNvbSIsImlhdCI6MTcwNDY0MzY2MSwiZXhwIjoxNzA0NjQ1NDYxLCJhdXRob3JpdHkiOiJST0xFX1NVUEVSQURNSU4ifQ.CGgjH4e4FTvz8s-adQBd2S6T5N8Uo9YLfht3LIkE0Js
Authorization: Bearer {{superAdminToken}}

### 관리자 수정 - 슈퍼 관리자
PATCH http://localhost:8081/api/v1/admin/management/1
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJpZCI6MSwic3ViIjoic3VwZXJhZG1pbkBleGFtcGxlLmNvbSIsImlhdCI6MTcwNDY0MzY2MSwiZXhwIjoxNzA0NjQ1NDYxLCJhdXRob3JpdHkiOiJST0xFX1NVUEVSQURNSU4ifQ.CGgjH4e4FTvz8s-adQBd2S6T5N8Uo9YLfht3LIkE0Js
Authorization: Bearer {{superAdminToken}}

{
"name": "",
Expand All @@ -53,9 +76,11 @@ Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJpZCI6MSwic3ViIjoic3VwZXJhZG1pbkBle

### 관리자 삭제 - 슈퍼 관리자
DELETE http://localhost:8081/api/v1/admin/management?adminIds=1
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJpZCI6MSwic3ViIjoic3VwZXJhZG1pbkBleGFtcGxlLmNvbSIsImlhdCI6MTcwNDY0MzY2MSwiZXhwIjoxNzA0NjQ1NDYxLCJhdXRob3JpdHkiOiJST0xFX1NVUEVSQURNSU4ifQ.CGgjH4e4FTvz8s-adQBd2S6T5N8Uo9YLfht3LIkE0Js
Authorization: Bearer {{superAdminToken}}

===

######
## ADMIN

### 로그인 - 관리자
POST http://localhost:8081/api/v1/auth/admin/login
Expand All @@ -82,7 +107,9 @@ Authorization: Bearer {{adminToken}}
GET http://localhost:8081/api/v1/admin/members/details?memberIds=1,2
Authorization: Bearer {{adminToken}}

#######
===

## MEMBER

### 멤버 일반 회원가입
POST http://localhost:8081/api/v1/members/signup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
@RequiredArgsConstructor
public class MemberService {

// TODO: role의 기본값을 어떻게 할 지 논의해봐야함
private static final String DEFAULT_ROLE_NAME = "ROLE_USER";

private final MemberRepository memberRepository;
private final PasswordEncoder passwordEncoder;

Expand Down
7 changes: 0 additions & 7 deletions api/api-member/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,6 @@ server:
properties:
hibernate.format_sql: true

# H2
datasource:
url: jdbc:h2:mem:devdb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
username: sa
password:
driver-class-name: org.h2.Driver

logging:
level:
org:
Expand Down
10 changes: 5 additions & 5 deletions core/core-infra/src/main/resources/data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ VALUES (5, 'Great event!', 1);
-- Member
INSERT INTO member (name, password, phone_number, email, birth_date, gender, street_address, detail_address, zip_code,
status, provider, role, last_login_at, last_password_updated_at)
VALUES ('김빙봉', '$2a$10$tfdM.PjviEH0zMEXVYjH.ODJPSviQRrYpb17rdMjvJtbWbSnC8nTa', '01012345678', 'john.doe@example.com',
'1990-01-01', 'MALE', '123 Main St', 'Apt 101',
VALUES ('김빙봉', '$2a$10$tfdM.PjviEH0zMEXVYjH.ODJPSviQRrYpb17rdMjvJtbWbSnC8nTa', '01012345678', 'member1@example.com',
'1990-01-01', 'MALE', '경기도 성남시 분당구', '정든마을 101호',
'12345', 'ACTIVE', 'KAKAO', 'ROLE_USER', '2024-01-01T10:00:00', '2024-01-01T10:00:00'),
('이행복', '$2a$10$tfdM.PjviEH0zMEXVYjH.ODJPSviQRrYpb17rdMjvJtbWbSnC8nTa', '01087654321', 'jane.smith@example.com',
'1992-02-02', 'FEMALE', '456 Elm St',
'Suite 202', '54321', 'ACTIVE', 'KAKAO', 'ROLE_USER', '2024-01-01T10:00:00', '2024-01-01T10:00:00');
('이행복', '$2a$10$tfdM.PjviEH0zMEXVYjH.ODJPSviQRrYpb17rdMjvJtbWbSnC8nTa', '01087654321', 'member2@example.com',
'1992-02-02', 'FEMALE', '광주광역시 광산로 67',
'103동 202호', '54321', 'ACTIVE', 'KAKAO', 'ROLE_USER', '2024-01-01T10:00:00', '2024-01-01T10:00:00');

-- Admin
INSERT INTO admin (name, email, password, phone_number, status, role, last_login_at, last_password_updated_at)
Expand Down
12 changes: 12 additions & 0 deletions core/core-infra/src/main/resources/http-client.private.env.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"dev": {
"superAdminToken": "eyJhbGciOiJIUzI1NiJ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MUBleGFtcGxlLmNvbSIsImlhdCI6MTcwNDcxMzE1NywiZXhwIjoxNzM0NzEzMTU3LCJhdXRob3JpdHkiOiJST0xFX1VTRVIifQ.pHXEXGpE0w8V2JmnwOOvLH942oJ1GC1bn3CRHKSskII"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {

private RequestMatcher[] requestPermitAll() {
List<RequestMatcher> requestMatchers = List.of(
antMatcher("/login"),
antMatcher("/api/v1/auth/**"),
antMatcher("/api/v1/members/signup"));
return requestMatchers.toArray(RequestMatcher[]::new);
Expand Down

0 comments on commit ee033f8

Please sign in to comment.