61 Commits

Author SHA1 Message Date
0d2ffe0f54 Merge pull request 'Probably not...' (#2) from feature/updated_compose into main
Reviewed-on: #2
2023-05-10 00:07:49 +00:00
991dc32ce4 Some extra changes
All checks were successful
continuous-integration/drone/pr Build is passing
2023-05-09 20:04:11 -04:00
d6a72ace83 Probably not...
All checks were successful
continuous-integration/drone/pr Build is passing
2023-05-09 19:43:58 -04:00
7a0d5dc48c Merge branch 'release/0.0.37'
# Conflicts:
#	package.json
2023-05-09 19:36:14 -04:00
4ed4b6e5f4 update version
Some checks failed
continuous-integration/drone/pr Build is failing
2023-05-09 19:33:02 -04:00
4499e20e77 - Check that update route is authenticated 2023-05-09 19:28:27 -04:00
fbc1e55e5c Merge branch 'main' of ssh://git.mifi.dev:12022/mifi/auth 2023-05-09 19:15:25 -04:00
653fc7d52f promnotions 2023-05-09 19:15:01 -04:00
84881edb61 promnotions 2023-05-09 19:14:04 -04:00
c8b1b72694 New pipeline eventing 2023-05-09 19:08:17 -04:00
73cd1d794a Finalized drone pipeline (mostly)
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-09 18:52:31 -04:00
28ac23d8f2 Or one more...
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-09 18:30:26 -04:00
71b7519a53 Last try then go with what works
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-09 18:28:53 -04:00
28ee1a9d1e One works... but the other...
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-09 18:27:49 -04:00
f327c6e06e revert
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-09 18:18:14 -04:00
799ff00f9c Update pipeline. Again. Day 900 and something.
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-09 09:17:36 -04:00
369e3f4b5c !! 2023-05-08 19:26:53 -04:00
3788de2609 ??
Some checks failed
continuous-integration/drone/push Build encountered an error
2023-05-08 19:24:42 -04:00
0f9aafe418 ........
Some checks failed
continuous-integration/drone/push Build encountered an error
2023-05-08 19:15:07 -04:00
13b90e9ee6 .....
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-08 19:13:44 -04:00
6e19a6217d Go!
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-08 19:08:55 -04:00
34fd4e7304 ...
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-08 19:05:41 -04:00
5e04012aa4 Zoom!
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-08 18:59:13 -04:00
e8f2928543 Go!
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-08 18:53:26 -04:00
91a3b2fabf Do just one thing...
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-08 18:40:38 -04:00
964b9a03ef New pipeline...
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-08 18:31:24 -04:00
bf693645d4 Lordy...
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-08 18:22:37 -04:00
082b4826c2 image_pull_secrets
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-08 16:59:12 -04:00
e68c3002d8 And again...
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-08 16:37:43 -04:00
30d2f4a644 Go!
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-08 16:32:52 -04:00
875a45f2b8 Perchance to dream...
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-08 16:18:00 -04:00
6bf7afbe09 Fix for deploy...
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-08 16:01:07 -04:00
5c94dbbff5 Maybe? Maybe not... 2023-05-08 15:59:56 -04:00
cb44eb1fab Hmmm. More trouble with secrets
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-08 15:53:27 -04:00
df63d7947f better secret file
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-08 15:47:20 -04:00
01a5ff907c Perhaps a big duh.
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-08 15:37:18 -04:00
e22e3d8bc3 Muahahahaha 2023-05-08 15:33:48 -04:00
efecd78355 Publishing FTW
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-08 15:15:50 -04:00
ed4246ba0e testing secrets...
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-08 15:08:49 -04:00
4acc228fe3 This one seems to be valid
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-08 14:57:15 -04:00
42279b0592 This. 2023-05-08 14:52:26 -04:00
e417ab64d8 Ah ha! Finally.
Some checks failed
continuous-integration/drone/push Build is failing
2023-05-08 14:22:19 -04:00
93b11c3a35 Fallback to old working
Some checks failed
continuous-integration/drone/push Build encountered an error
2023-05-08 14:07:40 -04:00
1ef2c4919e Maybe these odd changes?
Some checks failed
continuous-integration/drone/push Build encountered an error
2023-05-07 00:57:46 -04:00
6ff8f74317 Or this?
Some checks failed
continuous-integration/drone/push Build encountered an error
2023-05-07 00:55:59 -04:00
bf70ca98f3 Or this...
Some checks failed
continuous-integration/drone/push Build encountered an error
2023-05-07 00:54:41 -04:00
52e5befd93 Doubtful...
Some checks failed
continuous-integration/drone/push Build encountered an error
2023-05-07 00:53:29 -04:00
a047b49073 Last try, then pack 2023-05-06 10:18:39 -04:00
59b20578bb Maybe
Some checks failed
continuous-integration/drone/push Build encountered an error
2023-05-06 10:15:03 -04:00
cdd6c6a72a Dammit
Some checks failed
continuous-integration/drone/push Build encountered an error
2023-05-06 10:12:30 -04:00
1d16473d2d Ah ha!
Some checks failed
continuous-integration/drone/push Build encountered an error
2023-05-06 10:10:02 -04:00
cd2bef9811 So broken...
Some checks failed
continuous-integration/drone/push Build encountered an error
2023-05-06 10:00:17 -04:00
62118b6d64 ERGGGGG
Some checks failed
continuous-integration/drone/push Build encountered an error
2023-05-06 09:57:46 -04:00
8290b332fb Ugh
Some checks failed
continuous-integration/drone/push Build encountered an error
2023-05-06 09:56:00 -04:00
61236719f4 Or this...
Some checks failed
continuous-integration/drone/push Build encountered an error
2023-05-06 09:55:09 -04:00
aa699d5009 Testing this... 2023-05-06 09:48:31 -04:00
9a4f9cdf4c Hmmm 2023-05-06 09:48:00 -04:00
5532fc51a9 Unbroken? 2023-05-06 09:45:05 -04:00
99db648a36 - Endlessly fighting the ENV - I should be loading from the package... 2023-05-06 09:40:25 -04:00
adcab6afcb Double dollar
Some checks failed
continuous-integration/drone/push Build encountered an error
2023-05-06 09:28:24 -04:00
8e40c0a06c Tweaking the ENV
Some checks failed
continuous-integration/drone/push Build encountered an error
2023-05-06 09:19:31 -04:00
8 changed files with 87 additions and 65 deletions

View File

@@ -61,14 +61,12 @@ trigger:
branch: branch:
- main - main
event: event:
# - pull_request - pull_request
- push
--- ---
kind: pipeline kind: pipeline
type: docker type: docker
name: Publish Pipeline name: Publish Pipeline
group: publish
workspace: workspace:
path: /drone/grow path: /drone/grow
@@ -80,16 +78,10 @@ steps:
- yarn install - yarn install
- yarn build - yarn build
- name: Publish NPM - name: Publish NPM
image: plugins/npm image: node:20-alpine
failure: ignore failure: ignore
settings: commands:
username: - yarn publish -t ${DRONE_TAG}
from_secret: registry_username
password:
from_secret: registry_password
registry: https://git.mifi.dev/api/packages/mifi/npm
token:
- from_secret: gitea_token
volumes: volumes:
- name: npmrc - name: npmrc
path: /drone/grow/.npmrc path: /drone/grow/.npmrc
@@ -109,34 +101,18 @@ steps:
- success - success
- failure - failure
- name: Publish Image - name: Publish Image
image: docker image: plugins/docker
commands: settings:
- docker build -t git.mifi.dev/mifi/mifi/auth:latest -t git.mifi.dev/mifi/mifi/auth:${DRONE_TAG} . auto_tag: true
- docker push git.mifi.dev/mifi/mifi/auth:latest repo: git.mifi.dev/mifi/mifi/auth
volumes: registry: git.mifi.dev
- name: dockersock debug: true
path: /var/run/docker.sock ssh-agent-key:
- name: dockerconfig from_secret: reg_token
path: /drone/grow/.docker/config.json username: <token>
# - name: Publish Image password:
# image: plugins/docker from_secret: reg_token
# settings: secrets: [reg_token]
# 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
- name: Report Image Publish Status - name: Report Image Publish Status
image: plugins/webhook image: plugins/webhook
settings: settings:
@@ -168,10 +144,7 @@ depends_on:
- Test Pipeline - Test Pipeline
trigger: trigger:
# branch:
# - main
event: event:
# - push
- tag - tag
--- ---
@@ -186,6 +159,11 @@ steps:
- name: Deploy Container - name: Deploy Container
image: docker image: docker
privileged: true privileged: true
environment:
CONTAINER_PREFIX: staging
HOST: area51.mifi.dev
ROUTE_PREFIX: /auth
PORT: 9001
commands: commands:
- docker compose -f docker-compose.staging.yml pull - 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 build --no-cache
@@ -224,14 +202,13 @@ volumes:
path: /var/run/docker.sock path: /var/run/docker.sock
- name: env-secrets - name: env-secrets
host: host:
path: /volume1/docker/beethoven/labs-auth/staging.secrets.env path: /volume1/docker/beethoven/labs-auth/staging.env
depends_on: depends_on:
- Test Pipeline - Test Pipeline
trigger: trigger:
# branch:
# - main
event: event:
# - push - promote
- tag target:
- production

View File

@@ -1,6 +0,0 @@
HOST=area51.mifi.dev
PORT=9001
ROUTE_PREFIX=/auth
CONTAINER_PREFIX=mifi

View File

@@ -5,14 +5,14 @@ COPY tsconfig.json ./
COPY lib ./lib COPY lib ./lib
RUN ls -a RUN ls -a
RUN yarn install RUN yarn install
RUN yarn build:production RUN yarn build
## this is stage two , where the app actually runs ## this is stage two , where the app actually runs
FROM node:20-alpine AS containerize FROM node:20-alpine AS containerize
ENV NODE_ENV ${ENV:-production}
WORKDIR /home/node/app WORKDIR /home/node/app
COPY package*.json ./ COPY package*.json ./
RUN yarn install --frozen-lockfile --production RUN yarn install --frozen-lockfile --production
COPY --from=0 /home/node/app/dist . COPY --from=0 /home/node/app/dist .
EXPOSE 9001 EXPOSE ${PORT}
EXPOSE 27017
CMD ["node","server/index.js"] CMD ["node","server/index.js"]

View File

@@ -3,6 +3,9 @@ version: '3.8'
services: services:
auth-service_mongo: auth-service_mongo:
env_file: .env.dev env_file: .env.dev
build:
args:
- CONTAINER_PREFIX=${CONTAINER_PREFIX}
container_name: ${CONTAINER_PREFIX:-dev}-auth-service_mongo container_name: ${CONTAINER_PREFIX:-dev}-auth-service_mongo
ports: ports:
- 27017:27017 - 27017:27017
@@ -15,7 +18,13 @@ services:
image: mongo:latest image: mongo:latest
auth-service: auth-service:
env_file: .env.dev env_file: .env.dev
build: . build:
context: .
args:
- HOST=${HOST}
- PORT=${PORT}
- ROUTE_PREFIX=${ROUTE_PREFIX}
- CONTAINER_PREFIX=${CONTAINER_PREFIX}
container_name: ${CONTAINER_PREFIX:-dev}-auth-service container_name: ${CONTAINER_PREFIX:-dev}-auth-service
ports: ports:
- 9001:9001 - 9001:9001

View File

@@ -2,24 +2,23 @@ version: '3.8'
services: services:
auth-service_mongo: auth-service_mongo:
container_name: ${CONTAINER_PREFIX:-mifi}-auth-service_mongo container_name: ${CONTAINER_PREFIX}-auth-service_mongo
env_file: env_file:
- .env.staging
- staging.env - staging.env
networks: networks:
- docknet - docknet
volumes: volumes:
- '/volume1/docker/labs/auth/mongo:/data/db' - '/volume1/docker/labs/auth/mongo:/data/db'
# - ./mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro
restart: unless-stopped restart: unless-stopped
image: mongo:latest image: mongo:latest
auth-service: auth-service:
env_file: env_file:
- .env.staging
- staging.env - staging.env
build: . build: .
container_name: ${CONTAINER_PREFIX:-mifi}-auth-service container_name: ${CONTAINER_PREFIX}-auth-service
environment: environment:
- DB_HOST=${CONTAINER_PREFIX:-mifi}-auth-service_mongo - DB_HOST=${CONTAINER_PREFIX}-auth-service_mongo
labels: labels:
- 'traefik.enable=true' - 'traefik.enable=true'
- 'traefik.http.routers.grow.rule=Host(`${HOST}`) && Path(`${ROUTE_PREFIX}`)' - 'traefik.http.routers.grow.rule=Host(`${HOST}`) && Path(`${ROUTE_PREFIX}`)'

View 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

View File

@@ -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);

View File

@@ -1,6 +1,6 @@
{ {
"name": "@mifi/auth", "name": "@mifi/auth",
"version": "0.0.31", "version": "0.0.37",
"author": "mifi (Mike Fitzpatrick)", "author": "mifi (Mike Fitzpatrick)",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {