- Added FirebaseAuth struct and TokenVerifier interface for verifying Firebase ID tokens. - Introduced FirebaseConfig struct in config to manage Firebase credentials and project ID. - Implemented OAuth handler for Firebase ID token verification in HTTP handlers. - Added middleware for authenticating requests using Firebase tokens. - Updated router to conditionally apply authentication based on configuration. - Created tests for the new authentication middleware. - Added request and response types for Firebase OAuth handling. - Included a sample JSON file for testing purposes.
374 lines
8.9 KiB
YAML
374 lines
8.9 KiB
YAML
basePath: /
|
|
definitions:
|
|
httpapi.CreateShowReq:
|
|
properties:
|
|
ep_num:
|
|
example: 1
|
|
type: integer
|
|
ep_title:
|
|
example: Pilot
|
|
type: string
|
|
playback_length:
|
|
example: "00:24:00"
|
|
type: string
|
|
season_name:
|
|
example: Season 1
|
|
type: string
|
|
start_time:
|
|
description: optional; defaults to 22:00:00
|
|
example: "10:00:00"
|
|
type: string
|
|
required:
|
|
- ep_num
|
|
- ep_title
|
|
- playback_length
|
|
- season_name
|
|
type: object
|
|
httpapi.CurrentResponse:
|
|
properties:
|
|
current_ep:
|
|
example: false
|
|
type: boolean
|
|
date_created:
|
|
example: "2024-02-01T15:04:05Z"
|
|
type: string
|
|
ep_num:
|
|
example: 1
|
|
type: integer
|
|
ep_title:
|
|
example: Pilot
|
|
type: string
|
|
id:
|
|
example: 123
|
|
type: integer
|
|
playback_length:
|
|
example: "00:24:00"
|
|
type: string
|
|
season_name:
|
|
example: Season 1
|
|
type: string
|
|
start_time:
|
|
example: "10:00:00"
|
|
type: string
|
|
type: object
|
|
httpapi.DanimeEpisodeResponse:
|
|
properties:
|
|
ep_num:
|
|
example: 21
|
|
type: integer
|
|
ep_title:
|
|
example: あったんだ。確かに
|
|
type: string
|
|
playback_length:
|
|
example: "00:23:50"
|
|
type: string
|
|
season_name:
|
|
example: フルーツバスケット 2nd season
|
|
type: string
|
|
type: object
|
|
httpapi.FirebaseOAuthReq:
|
|
properties:
|
|
id_token:
|
|
example: <firebase-id-token>
|
|
type: string
|
|
required:
|
|
- id_token
|
|
type: object
|
|
httpapi.FirebaseOAuthRes:
|
|
properties:
|
|
email:
|
|
example: user@example.com
|
|
type: string
|
|
expires:
|
|
example: 1700000000
|
|
type: integer
|
|
issuer:
|
|
example: https://securetoken.google.com/<project>
|
|
type: string
|
|
uid:
|
|
example: abc123
|
|
type: string
|
|
type: object
|
|
httpapi.HTTPError:
|
|
properties:
|
|
error:
|
|
example: invalid payload
|
|
type: string
|
|
type: object
|
|
httpapi.MoveReq:
|
|
properties:
|
|
id:
|
|
example: 123
|
|
type: integer
|
|
ids:
|
|
items:
|
|
type: integer
|
|
type: array
|
|
type: object
|
|
httpapi.MoveRes:
|
|
properties:
|
|
deleted:
|
|
type: integer
|
|
deleted_ids:
|
|
items:
|
|
type: integer
|
|
type: array
|
|
inserted:
|
|
type: integer
|
|
moved_ids:
|
|
items:
|
|
type: integer
|
|
type: array
|
|
skipped:
|
|
type: integer
|
|
skipped_ids:
|
|
items:
|
|
type: integer
|
|
type: array
|
|
type: object
|
|
httpapi.SetCurrentReq:
|
|
properties:
|
|
id:
|
|
example: 123
|
|
type: integer
|
|
start_time:
|
|
example: "21:00:00"
|
|
type: string
|
|
required:
|
|
- id
|
|
- start_time
|
|
type: object
|
|
host: localhost:8082
|
|
info:
|
|
contact: {}
|
|
description: Backend API for watch-party app.
|
|
title: Watch Party Backend API
|
|
version: "1.0"
|
|
paths:
|
|
/api/v1/archive:
|
|
post:
|
|
consumes:
|
|
- application/json
|
|
description: Move one or many IDs from `current` to `current_archive`.
|
|
parameters:
|
|
- description: IDs to move
|
|
in: body
|
|
name: body
|
|
required: true
|
|
schema:
|
|
$ref: '#/definitions/httpapi.MoveReq'
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"200":
|
|
description: OK
|
|
schema:
|
|
$ref: '#/definitions/httpapi.MoveRes'
|
|
"400":
|
|
description: empty ids
|
|
schema:
|
|
$ref: '#/definitions/httpapi.HTTPError'
|
|
"500":
|
|
description: move failed
|
|
schema:
|
|
$ref: '#/definitions/httpapi.HTTPError'
|
|
summary: Move shows to archive
|
|
tags:
|
|
- archive
|
|
/api/v1/current:
|
|
get:
|
|
description: Returns the current row from `current` table.
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"200":
|
|
description: OK
|
|
schema:
|
|
$ref: '#/definitions/httpapi.CurrentResponse'
|
|
"404":
|
|
description: no current row found
|
|
schema:
|
|
$ref: '#/definitions/httpapi.HTTPError'
|
|
"500":
|
|
description: query failed
|
|
schema:
|
|
$ref: '#/definitions/httpapi.HTTPError'
|
|
summary: Get current show
|
|
tags:
|
|
- current
|
|
post:
|
|
consumes:
|
|
- application/json
|
|
description: Set the current show ID and start time.
|
|
parameters:
|
|
- description: Current show payload
|
|
in: body
|
|
name: body
|
|
required: true
|
|
schema:
|
|
$ref: '#/definitions/httpapi.SetCurrentReq'
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"200":
|
|
description: OK
|
|
schema:
|
|
$ref: '#/definitions/httpapi.CurrentResponse'
|
|
"400":
|
|
description: invalid payload or invalid time
|
|
schema:
|
|
$ref: '#/definitions/httpapi.HTTPError'
|
|
"404":
|
|
description: id not found
|
|
schema:
|
|
$ref: '#/definitions/httpapi.HTTPError'
|
|
"500":
|
|
description: update failed
|
|
schema:
|
|
$ref: '#/definitions/httpapi.HTTPError'
|
|
summary: Set current show
|
|
tags:
|
|
- current
|
|
/api/v1/danime:
|
|
get:
|
|
description: Fetch metadata from dアニメストア WS030101 by partId.
|
|
parameters:
|
|
- description: dアニメ partId
|
|
in: query
|
|
name: part_id
|
|
required: true
|
|
type: string
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"200":
|
|
description: OK
|
|
schema:
|
|
$ref: '#/definitions/httpapi.DanimeEpisodeResponse'
|
|
"400":
|
|
description: missing part_id
|
|
schema:
|
|
$ref: '#/definitions/httpapi.HTTPError'
|
|
"502":
|
|
description: scrape failed
|
|
schema:
|
|
$ref: '#/definitions/httpapi.HTTPError'
|
|
summary: Fetch dアニメ episode metadata
|
|
tags:
|
|
- scraper
|
|
/api/v1/oauth/firebase:
|
|
post:
|
|
consumes:
|
|
- application/json
|
|
description: Validate Firebase ID token and return basic claims.
|
|
parameters:
|
|
- description: Firebase ID token
|
|
in: body
|
|
name: body
|
|
required: true
|
|
schema:
|
|
$ref: '#/definitions/httpapi.FirebaseOAuthReq'
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"200":
|
|
description: OK
|
|
schema:
|
|
$ref: '#/definitions/httpapi.FirebaseOAuthRes'
|
|
"400":
|
|
description: invalid payload
|
|
schema:
|
|
$ref: '#/definitions/httpapi.HTTPError'
|
|
"401":
|
|
description: invalid token
|
|
schema:
|
|
$ref: '#/definitions/httpapi.HTTPError'
|
|
"503":
|
|
description: auth disabled
|
|
schema:
|
|
$ref: '#/definitions/httpapi.HTTPError'
|
|
summary: Verify Firebase ID token
|
|
tags:
|
|
- auth
|
|
/api/v1/shows:
|
|
delete:
|
|
description: Delete a row from `current` by ID.
|
|
parameters:
|
|
- description: Show ID
|
|
format: int64
|
|
in: query
|
|
name: id
|
|
required: true
|
|
type: integer
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"204":
|
|
description: No Content
|
|
"400":
|
|
description: invalid id
|
|
schema:
|
|
$ref: '#/definitions/httpapi.HTTPError'
|
|
"404":
|
|
description: id not found
|
|
schema:
|
|
$ref: '#/definitions/httpapi.HTTPError'
|
|
"500":
|
|
description: delete failed
|
|
schema:
|
|
$ref: '#/definitions/httpapi.HTTPError'
|
|
summary: Delete show
|
|
tags:
|
|
- shows
|
|
get:
|
|
description: List all rows from `current` table.
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"200":
|
|
description: OK
|
|
schema:
|
|
items:
|
|
$ref: '#/definitions/httpapi.CurrentResponse'
|
|
type: array
|
|
"500":
|
|
description: list failed
|
|
schema:
|
|
$ref: '#/definitions/httpapi.HTTPError'
|
|
summary: List current shows
|
|
tags:
|
|
- shows
|
|
post:
|
|
consumes:
|
|
- application/json
|
|
description: Insert a new show into `current`.
|
|
parameters:
|
|
- description: New show payload
|
|
in: body
|
|
name: body
|
|
required: true
|
|
schema:
|
|
$ref: '#/definitions/httpapi.CreateShowReq'
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"201":
|
|
description: Created
|
|
schema:
|
|
$ref: '#/definitions/httpapi.CurrentResponse'
|
|
"400":
|
|
description: invalid payload or invalid time/duration
|
|
schema:
|
|
$ref: '#/definitions/httpapi.HTTPError'
|
|
"500":
|
|
description: create failed
|
|
schema:
|
|
$ref: '#/definitions/httpapi.HTTPError'
|
|
summary: Create show
|
|
tags:
|
|
- shows
|
|
schemes:
|
|
- http
|
|
- https
|
|
swagger: "2.0"
|