Compare commits
66 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0d2ffe0f54 | |||
|
991dc32ce4
|
|||
|
d6a72ace83
|
|||
|
7a0d5dc48c
|
|||
|
4ed4b6e5f4
|
|||
|
4499e20e77
|
|||
|
fbc1e55e5c
|
|||
|
653fc7d52f
|
|||
|
84881edb61
|
|||
|
c8b1b72694
|
|||
|
73cd1d794a
|
|||
|
28ac23d8f2
|
|||
|
71b7519a53
|
|||
|
28ee1a9d1e
|
|||
|
f327c6e06e
|
|||
|
799ff00f9c
|
|||
|
369e3f4b5c
|
|||
|
3788de2609
|
|||
|
0f9aafe418
|
|||
|
13b90e9ee6
|
|||
|
6e19a6217d
|
|||
|
34fd4e7304
|
|||
|
5e04012aa4
|
|||
|
e8f2928543
|
|||
|
91a3b2fabf
|
|||
|
964b9a03ef
|
|||
|
bf693645d4
|
|||
|
082b4826c2
|
|||
|
e68c3002d8
|
|||
|
30d2f4a644
|
|||
|
875a45f2b8
|
|||
|
6bf7afbe09
|
|||
|
5c94dbbff5
|
|||
|
cb44eb1fab
|
|||
|
df63d7947f
|
|||
|
01a5ff907c
|
|||
|
e22e3d8bc3
|
|||
|
efecd78355
|
|||
|
ed4246ba0e
|
|||
|
4acc228fe3
|
|||
|
42279b0592
|
|||
|
e417ab64d8
|
|||
|
93b11c3a35
|
|||
|
1ef2c4919e
|
|||
|
6ff8f74317
|
|||
|
bf70ca98f3
|
|||
|
52e5befd93
|
|||
|
a047b49073
|
|||
|
59b20578bb
|
|||
|
cdd6c6a72a
|
|||
|
1d16473d2d
|
|||
|
cd2bef9811
|
|||
|
62118b6d64
|
|||
|
8290b332fb
|
|||
|
61236719f4
|
|||
|
aa699d5009
|
|||
|
9a4f9cdf4c
|
|||
|
5532fc51a9
|
|||
|
99db648a36
|
|||
|
adcab6afcb
|
|||
|
8e40c0a06c
|
|||
|
db5e4858b8
|
|||
|
d800311ae7
|
|||
|
32fdde5d90
|
|||
|
2eacdaeece
|
|||
|
827bce6e1b
|
75
.drone.yml
75
.drone.yml
@@ -62,13 +62,11 @@ trigger:
|
||||
- main
|
||||
event:
|
||||
- pull_request
|
||||
- push
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: Publish Pipeline
|
||||
group: publish
|
||||
|
||||
workspace:
|
||||
path: /drone/grow
|
||||
@@ -80,16 +78,10 @@ steps:
|
||||
- yarn install
|
||||
- yarn build
|
||||
- name: Publish NPM
|
||||
image: plugins/npm
|
||||
image: node:20-alpine
|
||||
failure: ignore
|
||||
settings:
|
||||
username:
|
||||
from_secret: registry_username
|
||||
password:
|
||||
from_secret: registry_password
|
||||
registry: https://git.mifi.dev/api/packages/mifi/npm
|
||||
token:
|
||||
- from_secret: gitea_token
|
||||
commands:
|
||||
- yarn publish -t ${DRONE_TAG}
|
||||
volumes:
|
||||
- name: npmrc
|
||||
path: /drone/grow/.npmrc
|
||||
@@ -109,34 +101,18 @@ steps:
|
||||
- success
|
||||
- failure
|
||||
- name: Publish Image
|
||||
image: docker
|
||||
commands:
|
||||
- docker build -f docker-compose.staging.yml -t git.mifi.dev/mifi/mifi/auth:latest .
|
||||
- docker push git.mifi.dev/mifi/mifi/auth:latest
|
||||
volumes:
|
||||
- name: dockersock
|
||||
path: /var/run/docker.sock
|
||||
- name: dockerconfig
|
||||
path: /drone/grow/.docker/config.json
|
||||
# - name: Publish Image
|
||||
# image: plugins/docker
|
||||
# settings:
|
||||
# auto_tag: true
|
||||
# squash: true
|
||||
# repo: git.mifi.dev/mifi/auth
|
||||
# context: mifi
|
||||
# registry: git.mifi.dev
|
||||
# username:
|
||||
# from_secret: registry_username
|
||||
# password:
|
||||
# from_secret: registry_password
|
||||
# ssh-agent-key:
|
||||
# from_secret: gitea_token
|
||||
volumes:
|
||||
- name: dockersock
|
||||
path: /var/run/docker.sock
|
||||
- name: dockerconfig
|
||||
path: /drone/grow/.docker/config.json
|
||||
image: plugins/docker
|
||||
settings:
|
||||
auto_tag: true
|
||||
repo: git.mifi.dev/mifi/mifi/auth
|
||||
registry: git.mifi.dev
|
||||
debug: true
|
||||
ssh-agent-key:
|
||||
from_secret: reg_token
|
||||
username: <token>
|
||||
password:
|
||||
from_secret: reg_token
|
||||
secrets: [reg_token]
|
||||
- name: Report Image Publish Status
|
||||
image: plugins/webhook
|
||||
settings:
|
||||
@@ -168,10 +144,7 @@ depends_on:
|
||||
- Test Pipeline
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
- main
|
||||
event:
|
||||
- push
|
||||
- tag
|
||||
|
||||
---
|
||||
@@ -186,14 +159,19 @@ steps:
|
||||
- name: Deploy Container
|
||||
image: docker
|
||||
privileged: true
|
||||
environment:
|
||||
CONTAINER_PREFIX: staging
|
||||
HOST: area51.mifi.dev
|
||||
ROUTE_PREFIX: /auth
|
||||
PORT: 9001
|
||||
commands:
|
||||
- docker compose -f docker-compose.staging.yml pull
|
||||
- docker compose -f docker-compose.staging.yml build --no-cache
|
||||
- docker compose -f docker-compose.staging.yml rm --stop
|
||||
- docker compose -f docker-compose.staging.yml up --wait
|
||||
volumes:
|
||||
- name: env
|
||||
path: /drone/grow/.env
|
||||
- name: env-secrets
|
||||
path: /drone/grow/staging.env
|
||||
- name: dockersock
|
||||
path: /var/run/docker.sock
|
||||
- name: dockerconfig
|
||||
@@ -222,7 +200,7 @@ volumes:
|
||||
- name: dockersock
|
||||
host:
|
||||
path: /var/run/docker.sock
|
||||
- name: env
|
||||
- name: env-secrets
|
||||
host:
|
||||
path: /volume1/docker/beethoven/labs-auth/staging.env
|
||||
|
||||
@@ -230,8 +208,7 @@ depends_on:
|
||||
- Test Pipeline
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
- main
|
||||
event:
|
||||
- push
|
||||
- tag
|
||||
- promote
|
||||
target:
|
||||
- production
|
||||
@@ -27,5 +27,3 @@ RESET_VALID_MINUTES=15
|
||||
DEFAULT_TOKEN_DAYS=1
|
||||
|
||||
CONTAINER_PREFIX=dev
|
||||
SERVICE_NAME=auth-service
|
||||
DB_TYPE=mongo
|
||||
16
Dockerfile
16
Dockerfile
@@ -1,13 +1,3 @@
|
||||
# FROM node:20-alpine AS build
|
||||
# RUN mkdir -p /home/node/app/node_modules && chown -R node:node /home/node/app
|
||||
# WORKDIR /home/node/app
|
||||
# COPY package*.json .
|
||||
# COPY dist/lib .
|
||||
# USER node
|
||||
# RUN yarn install --frozen-lockfile --production
|
||||
# COPY --chown=node:node node_modules ./node_modules
|
||||
# CMD ["node", "dist/lib/server/index.js"]
|
||||
|
||||
FROM node:20-alpine AS build
|
||||
WORKDIR /home/node/app
|
||||
COPY package*.json ./
|
||||
@@ -15,14 +5,14 @@ COPY tsconfig.json ./
|
||||
COPY lib ./lib
|
||||
RUN ls -a
|
||||
RUN yarn install
|
||||
RUN yarn build:production
|
||||
RUN yarn build
|
||||
|
||||
## this is stage two , where the app actually runs
|
||||
FROM node:20-alpine AS containerize
|
||||
ENV NODE_ENV ${ENV:-production}
|
||||
WORKDIR /home/node/app
|
||||
COPY package*.json ./
|
||||
RUN yarn install --frozen-lockfile --production
|
||||
COPY --from=0 /home/node/app/dist .
|
||||
EXPOSE 9001
|
||||
EXPOSE 27017
|
||||
EXPOSE ${PORT}
|
||||
CMD ["node","server/index.js"]
|
||||
|
||||
@@ -2,7 +2,10 @@ version: '3.8'
|
||||
|
||||
services:
|
||||
auth-service_mongo:
|
||||
env_file: dev.env
|
||||
env_file: .env.dev
|
||||
build:
|
||||
args:
|
||||
- CONTAINER_PREFIX=${CONTAINER_PREFIX}
|
||||
container_name: ${CONTAINER_PREFIX:-dev}-auth-service_mongo
|
||||
ports:
|
||||
- 27017:27017
|
||||
@@ -14,8 +17,14 @@ services:
|
||||
restart: unless-stopped
|
||||
image: mongo:latest
|
||||
auth-service:
|
||||
env_file: dev.env
|
||||
build: .
|
||||
env_file: .env.dev
|
||||
build:
|
||||
context: .
|
||||
args:
|
||||
- HOST=${HOST}
|
||||
- PORT=${PORT}
|
||||
- ROUTE_PREFIX=${ROUTE_PREFIX}
|
||||
- CONTAINER_PREFIX=${CONTAINER_PREFIX}
|
||||
container_name: ${CONTAINER_PREFIX:-dev}-auth-service
|
||||
ports:
|
||||
- 9001:9001
|
||||
|
||||
@@ -3,15 +3,18 @@ version: '3.8'
|
||||
services:
|
||||
auth-service_mongo:
|
||||
container_name: ${CONTAINER_PREFIX}-auth-service_mongo
|
||||
env_file: .env
|
||||
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
|
||||
image: mongo:latest
|
||||
auth-service:
|
||||
env_file: .env
|
||||
env_file:
|
||||
- staging.env
|
||||
build: .
|
||||
container_name: ${CONTAINER_PREFIX}-auth-service
|
||||
environment:
|
||||
@@ -27,7 +30,7 @@ services:
|
||||
networks:
|
||||
- docknet
|
||||
restart: unless-stopped
|
||||
image: node
|
||||
image: node:20-alpine
|
||||
depends_on:
|
||||
- auth-service_mongo
|
||||
networks:
|
||||
|
||||
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 passport from '../passport';
|
||||
import { ErrorCodes, getErrorBody } from '../../constants/errors';
|
||||
import { authenticated } from '../middleware/authenication';
|
||||
|
||||
const routerOpts: Router.IRouterOptions = { prefix };
|
||||
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) };
|
||||
});
|
||||
|
||||
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 });
|
||||
if (!data) {
|
||||
ctx.throw(StatusCodes.NOT_FOUND);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@mifi/auth",
|
||||
"version": "0.0.26",
|
||||
"version": "0.0.37",
|
||||
"author": "mifi (Mike Fitzpatrick)",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user