Skip to content

Instantly share code, notes, and snippets.

@Jehong-Ahn
Last active May 12, 2016 00:52
Show Gist options
  • Save Jehong-Ahn/9e31b6b74c373805a2c292a5d46ec1f1 to your computer and use it in GitHub Desktop.
Save Jehong-Ahn/9e31b6b74c373805a2c292a5d46ec1f1 to your computer and use it in GitHub Desktop.
SMS Auth API
swagger: '2.0'
info:
title: SMS Auth API
description: |
# Firebase #######################################
## Services
연계된 서비스 정보를 기록
- `id`
- `name`
- `sms_template` 발송할 SMS 양식. 내용에서 코드는 `%CODE%`로 대체.
- `private_key` webhook 요청에 사용
- `webhook` url query로 private_key, phone, session을 함께 요청한다.
## Logs
요청 내역을 기록
- `id`
- `serviceId`
- `phone`
- `datetime`
- `code` 문자로 발송된 코드
- `session` 생성된 세션키
# TODO ####################
장기간 미접속한 번호로 인증 요청 시에, 명의자 변경되었을 수 있으므로 추가적인 인증수단 필요.
------------------------
version: '1.0.0'
host: api.foo.com
basePath: '/v1'
schemes:
- https
consumes:
- 'text/plain; charset=utf-8'
produces:
- 'application/json'
security:
- serviceId: []
securityDefinitions:
serviceId:
description: 세션키를 얻고자 하는 서비스의 id. 무효한 요청 시 `Invalid service ID` 에러를 리턴
type: apiKey
name: serviceId
in: query
required: true
paths:
'/request/code':
post:
summary: 코드키를 요청
parameters:
- name: phone
description: 문자로 코드를 발송할 휴대폰 번호. 앞에 국제전화 코드가 있을수도 있다.
in: query
required: true
type: string
format: tel
description: |
##### Action
1. 서비스 정보를 페치
1. 로그 검사
1. 코드 생성하고, 로그 기록
1. 문자 발송
##### Error
- `Invalid phone number` 전화번호 형식이 무효할때
- `Too many requests` 로그를 검사했을때 스팸이라 판정되면
responses:
200:
description: OK
'/request/session':
post:
summary: 코드키를 제출하고 세션키를 획득
parameters:
- name: code
description: 요청자가 SMS를 통해 받은 코드
in: query
required: true
type: string
description: |
##### Action
1. 서비스 정보를 페치
1. 코드와 로그를 대조하고, 로그 업데이트
1. 세션키 생성
1. 해당 서비스의 webhook실행
##### Error
- `Wrong code` 입력한 코드가 틀릴때
- `Invalid request` 로그에 이상이 있을때
- `Service unavailable` 서비스 webhook실행에 실패했을때
responses:
200:
description: OK
schema:
type: object
properties:
serviceId:
type: string
format: uuid
phone:
type: string
format: tel
sessionKey:
type: string
format: uuid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment