Compare commits
31 Commits
6bf7afbe09
...
0.0.37
| 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
|
185
.drone.yml
185
.drone.yml
@@ -1,70 +1,69 @@
|
||||
# kind: pipeline
|
||||
# type: docker
|
||||
# name: Test Pipeline
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: Test Pipeline
|
||||
|
||||
# workspace:
|
||||
# path: /drone/grow
|
||||
workspace:
|
||||
path: /drone/grow
|
||||
|
||||
# steps:
|
||||
# - name: yarn install
|
||||
# image: node:latest
|
||||
# commands:
|
||||
# - yarn install
|
||||
# - name: Code Style Checks
|
||||
# image: node:latest
|
||||
# commands:
|
||||
# - yarn prettier
|
||||
# - name: Lint
|
||||
# image: node:latest
|
||||
# commands:
|
||||
# - yarn lint
|
||||
# - name: Unit Tests
|
||||
# image: node:latest
|
||||
# commands:
|
||||
# - yarn test
|
||||
# - name: Send Test Status Notification
|
||||
# image: plugins/webhook
|
||||
# settings:
|
||||
# urls: https://lab.mifi.dev/hooks/9p65zpagctgkmndo8nwwm4199r
|
||||
# content_type: application/json
|
||||
# template: |
|
||||
# {
|
||||
# "icon_url":"https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/120/apple/198/freezing-face_1f976.png",
|
||||
# "text": "[{{ repo.name }} - Build # {{ build.number }}] Code Quality Checks {{ build.status }} {{#success build.status}}:tada:{{else}}:poop:{{/success}}",
|
||||
# "username":"DroneBot"
|
||||
# }
|
||||
# when:
|
||||
# status:
|
||||
# - success
|
||||
# - failure
|
||||
# - name: Build
|
||||
# image: node:latest
|
||||
# commands:
|
||||
# - yarn build
|
||||
# - name: Send Build Status Notifications
|
||||
# image: plugins/webhook
|
||||
# settings:
|
||||
# urls: https://lab.mifi.dev/hooks/9p65zpagctgkmndo8nwwm4199r
|
||||
# content_type: application/json
|
||||
# template: |
|
||||
# {
|
||||
# "icon_url":"https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/120/apple/198/freezing-face_1f976.png",
|
||||
# "text": "[{{ repo.name }} - Build # {{ build.number }}] Build package {{ build.status }} {{#success build.status}}:tada:{{else}}:poop:{{/success}}",
|
||||
# "username":"DroneBot"
|
||||
# }
|
||||
# when:
|
||||
# status:
|
||||
# - success
|
||||
# - failure
|
||||
steps:
|
||||
- name: yarn install
|
||||
image: node:latest
|
||||
commands:
|
||||
- yarn install
|
||||
- name: Code Style Checks
|
||||
image: node:latest
|
||||
commands:
|
||||
- yarn prettier
|
||||
- name: Lint
|
||||
image: node:latest
|
||||
commands:
|
||||
- yarn lint
|
||||
- name: Unit Tests
|
||||
image: node:latest
|
||||
commands:
|
||||
- yarn test
|
||||
- name: Send Test Status Notification
|
||||
image: plugins/webhook
|
||||
settings:
|
||||
urls: https://lab.mifi.dev/hooks/9p65zpagctgkmndo8nwwm4199r
|
||||
content_type: application/json
|
||||
template: |
|
||||
{
|
||||
"icon_url":"https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/120/apple/198/freezing-face_1f976.png",
|
||||
"text": "[{{ repo.name }} - Build # {{ build.number }}] Code Quality Checks {{ build.status }} {{#success build.status}}:tada:{{else}}:poop:{{/success}}",
|
||||
"username":"DroneBot"
|
||||
}
|
||||
when:
|
||||
status:
|
||||
- success
|
||||
- failure
|
||||
- name: Build
|
||||
image: node:latest
|
||||
commands:
|
||||
- yarn build
|
||||
- name: Send Build Status Notifications
|
||||
image: plugins/webhook
|
||||
settings:
|
||||
urls: https://lab.mifi.dev/hooks/9p65zpagctgkmndo8nwwm4199r
|
||||
content_type: application/json
|
||||
template: |
|
||||
{
|
||||
"icon_url":"https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/120/apple/198/freezing-face_1f976.png",
|
||||
"text": "[{{ repo.name }} - Build # {{ build.number }}] Build package {{ build.status }} {{#success build.status}}:tada:{{else}}:poop:{{/success}}",
|
||||
"username":"DroneBot"
|
||||
}
|
||||
when:
|
||||
status:
|
||||
- success
|
||||
- failure
|
||||
|
||||
# trigger:
|
||||
# branch:
|
||||
# - main
|
||||
# event:
|
||||
# # - pull_request
|
||||
# - push
|
||||
trigger:
|
||||
branch:
|
||||
- main
|
||||
event:
|
||||
- pull_request
|
||||
|
||||
# ---
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: Publish Pipeline
|
||||
@@ -79,27 +78,13 @@ steps:
|
||||
- yarn install
|
||||
- yarn build
|
||||
- name: Publish NPM
|
||||
image: node:latest
|
||||
image: node:20-alpine
|
||||
failure: ignore
|
||||
commands:
|
||||
- yarn npm publish
|
||||
- yarn publish -t ${DRONE_TAG}
|
||||
volumes:
|
||||
- name: npmrc
|
||||
path: /drone/grow/.npmrc
|
||||
# - name: Publish NPM
|
||||
# image: plugins/npm
|
||||
# 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
|
||||
# volumes:
|
||||
# - name: npmrc
|
||||
# path: /drone/grow/.npmrc
|
||||
- name: Report NPM Publish Status
|
||||
image: plugins/webhook
|
||||
settings:
|
||||
@@ -116,16 +101,18 @@ steps:
|
||||
- success
|
||||
- failure
|
||||
- name: Publish Image
|
||||
image: docker
|
||||
commands:
|
||||
# - 'docker login git.mifi.dev'
|
||||
- 'docker build -t git.mifi.dev/mifi/mifi/auth:latest -t git.mifi.dev/mifi/mifi/auth:${DRONE_TAG} .'
|
||||
- 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
|
||||
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:
|
||||
@@ -153,15 +140,12 @@ volumes:
|
||||
host:
|
||||
path: /volume1/docker/beethoven/labs-auth/.npmrc
|
||||
|
||||
# depends_on:
|
||||
# - Test Pipeline
|
||||
depends_on:
|
||||
- Test Pipeline
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
- main
|
||||
event:
|
||||
- push
|
||||
# - tag
|
||||
- tag
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
@@ -220,12 +204,11 @@ volumes:
|
||||
host:
|
||||
path: /volume1/docker/beethoven/labs-auth/staging.env
|
||||
|
||||
# depends_on:
|
||||
# - Test Pipeline
|
||||
depends_on:
|
||||
- Test Pipeline
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
- main
|
||||
event:
|
||||
- push
|
||||
# - tag
|
||||
- promote
|
||||
target:
|
||||
- production
|
||||
@@ -5,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"]
|
||||
|
||||
@@ -9,6 +9,7 @@ services:
|
||||
- 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:
|
||||
@@ -17,7 +18,7 @@ services:
|
||||
build: .
|
||||
container_name: ${CONTAINER_PREFIX}-auth-service
|
||||
environment:
|
||||
- DB_HOST=${CONTAINER_PREFIX:-mifi}-auth-service_mongo
|
||||
- DB_HOST=${CONTAINER_PREFIX}-auth-service_mongo
|
||||
labels:
|
||||
- 'traefik.enable=true'
|
||||
- 'traefik.http.routers.grow.rule=Host(`${HOST}`) && Path(`${ROUTE_PREFIX}`)'
|
||||
|
||||
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.34",
|
||||
"version": "0.0.37",
|
||||
"author": "mifi (Mike Fitzpatrick)",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user