Palus-Somni-Team / shikicinema-server

2 stars 0 forks source link

#92 Implement OAuth Code Flow #95

Closed Smarthard closed 1 year ago

Smarthard commented 1 year ago

Что реализовано

Реализован провайдер только для Shikimori (/oauth/shikimori).

Контроллер защищен от неавторизованных пользователей, т.е. перед обращением нужно войти в аккаунт нашего пользователя. Это сделано, чтобы защитить эндпоинты от абуза сторонними приложениями (=== защита от использования наших oauth клиентов). При обнаружении подозрительной активности от конкретного пользователя можно будет просто его забанить и тем самым закрыть этот контроллер от злоумышленников).

Пример ответа

Ответ с токенами выглядит так:

{
    "accessToken": "<access>",
    "refreshToken": "<refresh>",
    "scope": "scope1 scope2 scope3",
    "expires": "1970-01-01T00:00:00.000Z"
}
github-actions[bot] commented 1 year ago

Coverage report

St.:grey_question:
Category Percentage Covered / Total
🟢 Statements
94.05% (+0.07% 🔼)
1028/1093
🟢 Branches
82.39% (-0.11% 🔻)
131/159
🟢 Functions
86.9% (-1.35% 🔻)
219/252
🟢 Lines
93.33% (+0.02% 🔼)
867/929
Show new covered files 🐣
|
St.:grey_question:
| File | Statements | Branches | Functions | Lines | | :----------------------------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------- | :--------- | :------- | :-------- | :----- | | 🟢 |
`...` / where-parser.utils.ts
| 100% | 100% | 100% | 100% | | 🟢 |
`...` / shikimori-oauth.config.ts
| 100% | 100% | 100% | 100% | | 🟢 |
`...` / oauth.module.ts
| 100% | 100% | 100% | 100% | | 🟢 |
`...` / oauth-with-authorization.controller.ts
| 100% | 100% | 100% | 100% | | 🟢 | src/types/index.ts | 100% | 100% | 100% | 100% | | 🟢 |
`...` / ban-status.enum.ts
| 100% | 100% | 100% | 100% | | 🟢 |
`...` / ban-status.guard.ts
| 100% | 57.14% | 100% | 100% | | 🟢 |
`...` / shikimori-transform.interceptor.ts
| 88.89% | 50% | 50% | 85.71% |
Show files with reduced coverage 🔻
|
St.:grey_question:
| File | Statements | Branches | Functions | Lines | | :----------------------------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------- | :------------------------------------------------------------- | :------------------------------------------------------------ | :------------------------------------------------------------- | :------------------------------------------------------------ | | 🟢 |
`...` / postgres.utils.ts
| 100% |
87.5% (-1.39% 🔻)
| 100% | 100% | | 🟡 |
`...` / admin-user.controller.ts
|
71.43% (-2.76% 🔻)
| 100% | 28.57% |
72% (-3% 🔻)
| | 🟢 |
`...` / index.ts
| 100% | 100% |
75% (-25% 🔻)
| 100% | | 🟢 | test/test.client.ts |
92.19% (-2.89% 🔻)
| 100% |
87.18% (-4.49% 🔻)
|
91.8% (-3.02% 🔻)
|

Test suite run success

147 tests passing in 13 suites.

Report generated by 🧪jest coverage report action from 70e2a4240da84d101eb5fde98e77b60f0b457930

github-actions[bot] commented 1 year ago

Coverage report

St.:grey_question:
Category Percentage Covered / Total
🟢 Statements
93.94% (-0.04% 🔻)
1023/1089
🟢 Branches
82.47% (-0.03% 🔻)
127/154
🟢 Functions
86.8% (-1.46% 🔻)
217/250
🟢 Lines
93.18% (-0.12% 🔻)
861/924
Show new covered files 🐣
|
St.:grey_question:
| File | Statements | Branches | Functions | Lines | | :----------------------------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------- | :--------- | :------- | :-------- | :----- | | 🟢 |
`...` / where-parser.utils.ts
| 100% | 100% | 100% | 100% | | 🟢 |
`...` / shikimori-oauth.config.ts
| 100% | 100% | 100% | 100% | | 🟢 |
`...` / oauth.module.ts
| 100% | 100% | 100% | 100% | | 🟢 |
`...` / oauth-with-authorization.controller.ts
| 100% | 100% | 100% | 100% | | 🟢 |
`...` / no-banned-users-guard.service.ts
| 92.86% | 33.33% | 100% | 90.91% | | 🟢 |
`...` / shikimori-transform.interceptor.ts
| 88.89% | 50% | 50% | 85.71% |
Show files with reduced coverage 🔻
|
St.:grey_question:
| File | Statements | Branches | Functions | Lines | | :----------------------------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------- | :------------------------------------------------------------- | :------------------------------------------------------------ | :------------------------------------------------------------- | :------------------------------------------------------------ | | 🟢 |
`...` / postgres.utils.ts
| 100% |
87.5% (-1.39% 🔻)
| 100% | 100% | | 🟡 |
`...` / admin-user.controller.ts
|
71.43% (-2.76% 🔻)
| 100% | 28.57% |
72% (-3% 🔻)
| | 🟢 |
`...` / index.ts
| 100% | 100% |
75% (-25% 🔻)
| 100% | | 🟢 | test/test.client.ts |
92.19% (-2.89% 🔻)
| 100% |
87.18% (-4.49% 🔻)
|
91.8% (-3.02% 🔻)
|

Test suite run success

147 tests passing in 13 suites.

Report generated by 🧪jest coverage report action from adee6ffcd875879ae0c58bd35c57667a554d29db