[rest api 프로젝트 구축] - spring security (8) OAuth - postman 사용

geun kim·2023년 3월 28일
0

REST API 구축

목록 보기
18/20
post-thumbnail

> API 목록

토큰 발급 받기

POST /oauth/token

토큰 갱신 하기

POST /oauth/token

이벤트 등록

POST /api/events

이벤트 목록 조회 : 로그인 한 경우 이벤트 생성 링크 제공

GET /api/events

이벤트 조회 : 로그인 USER가 이벤트 등록자인 경우 수정 링크 제공

GET /api/events/{id}

이벤트 수정 : 등록자가 아닌경우 HttpStatus.UNAUTHORIZED 코드 리턴

PUT /api/events/{id}

POSTMAN 으로 API 테스트

postman 설정 (토큰 발급 받기)
api address : http://localhost:8080/oauth/token

● POST /oauth/token
● BASIC authentication 헤더

○ client Id(myApp) + client secret(pass)

● 요청 본문 폼

○ username: admin@email.com
○ password: admin
○ grant_type: password

postman 설정 (토큰 갱신하기)
api address : http://localhost:8080/oauth/token

● POST /oauth/token
● BASIC authentication 헤더

○ client Id(myApp) + client secret(pass)

● 요청 본문 폼

○ token: 처음에 발급받았던 refersh 토큰
○ grant_type: refresh_token


postman 설정 (이벤트 등록 API)
POST http://localhost:8080/api/events

postman 설정 (이벤트 목록 조회 API)
GET http://localhost:8080/api/events

● 로그인 했을 때

○ 이벤트 생성 링크 제공

로그인 안 했을 때 : 이벤트 생성 링크 없음

로그인 했을 때 : 이벤트 생성 링크 제공

postman 설정 (이벤트 조회 API)
GET http://localhost:8080/api/events/{eventId}

이벤트 Manager가 아닌 경우에는 이벤트 수정 링크 제공 안함

이벤트 Manager인 경우에는 이벤트 수정 링크 제공

postman 설정 (이벤트 수정 API)
PUT http://localhost:8080/api/events/{eventId}

이벤트 수정
이벤트 Manager인 경우에는 정상 처리

이벤트 Manager가 아닌 경우에는 HttpStatus.UNAUTHORIZED (401 Unauthorized) 코드 응답

profile
Devops Load Map

0개의 댓글