Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0d2ffe0f54 | |||
|
991dc32ce4
|
|||
|
d6a72ace83
|
|||
|
7a0d5dc48c
|
|||
|
4ed4b6e5f4
|
|||
|
4499e20e77
|
39
docker-compose.staging_image.yml
Normal file
39
docker-compose.staging_image.yml
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
version: '3.8'
|
||||||
|
|
||||||
|
services:
|
||||||
|
auth-service_mongo:
|
||||||
|
container_name: ${CONTAINER_PREFIX}-auth-service_mongo
|
||||||
|
env_file:
|
||||||
|
- staging.env
|
||||||
|
networks:
|
||||||
|
- docknet
|
||||||
|
volumes:
|
||||||
|
- '/volume1/docker/labs/auth/mongo:/data/db'
|
||||||
|
# - ./mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro
|
||||||
|
restart: unless-stopped
|
||||||
|
image: mongo:latest
|
||||||
|
auth-service:
|
||||||
|
env_file:
|
||||||
|
- staging.env
|
||||||
|
build: .
|
||||||
|
container_name: ${CONTAINER_PREFIX}-auth-service
|
||||||
|
environment:
|
||||||
|
- DB_HOST=${CONTAINER_PREFIX}-auth-service_mongo
|
||||||
|
labels:
|
||||||
|
- 'traefik.enable=true'
|
||||||
|
- 'traefik.http.routers.grow.rule=Host(`${HOST}`) && Path(`${ROUTE_PREFIX}`)'
|
||||||
|
- 'traefik.http.routers.grow.entrypoints=websecure'
|
||||||
|
- 'traefik.http.routers.grow.tls=true'
|
||||||
|
- 'traefik.http.routers.grow.tls.certresolver=letsencrypt'
|
||||||
|
- 'traefik.http.routers.grow.service=grow-service'
|
||||||
|
- 'traefik.http.services.grow-service.loadbalancer.server.port=${PORT}'
|
||||||
|
networks:
|
||||||
|
- docknet
|
||||||
|
restart: unless-stopped
|
||||||
|
image: node:20-alpine
|
||||||
|
depends_on:
|
||||||
|
- auth-service_mongo
|
||||||
|
networks:
|
||||||
|
docknet:
|
||||||
|
name: docknet
|
||||||
|
external: true
|
||||||
@@ -7,6 +7,7 @@ import Auth from '../../db/model/auth';
|
|||||||
import { sign } from '../../utils/jwt';
|
import { sign } from '../../utils/jwt';
|
||||||
import passport from '../passport';
|
import passport from '../passport';
|
||||||
import { ErrorCodes, getErrorBody } from '../../constants/errors';
|
import { ErrorCodes, getErrorBody } from '../../constants/errors';
|
||||||
|
import { authenticated } from '../middleware/authenication';
|
||||||
|
|
||||||
const routerOpts: Router.IRouterOptions = { prefix };
|
const routerOpts: Router.IRouterOptions = { prefix };
|
||||||
const router: Router = new Router(routerOpts);
|
const router: Router = new Router(routerOpts);
|
||||||
@@ -43,7 +44,10 @@ router.post(process.env.RESET_ROUTE || RESET_ROUTE, async (ctx, next) => {
|
|||||||
ctx.body = { success: false, ...getErrorBody(ErrorCodes.RESET_REQUEST_DATA) };
|
ctx.body = { success: false, ...getErrorBody(ErrorCodes.RESET_REQUEST_DATA) };
|
||||||
});
|
});
|
||||||
|
|
||||||
router.patch('/:record', (ctx: Koa.Context) => {
|
router.patch('/:record', authenticated(), (ctx: Koa.Context) => {
|
||||||
|
if (ctx.user !== ctx.param.record) {
|
||||||
|
ctx.throw(StatusCodes.UNAUTHORIZED);
|
||||||
|
}
|
||||||
const data = Auth.findOneAndUpdate({ record: ctx.params.record });
|
const data = Auth.findOneAndUpdate({ record: ctx.params.record });
|
||||||
if (!data) {
|
if (!data) {
|
||||||
ctx.throw(StatusCodes.NOT_FOUND);
|
ctx.throw(StatusCodes.NOT_FOUND);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@mifi/auth",
|
"name": "@mifi/auth",
|
||||||
"version": "0.0.36",
|
"version": "0.0.37",
|
||||||
"author": "mifi (Mike Fitzpatrick)",
|
"author": "mifi (Mike Fitzpatrick)",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user