Commit 121a8cce authored by FORESTIER Fabien's avatar FORESTIER Fabien
Browse files

Update CI/CD related files in order to be able to build release image on master branch tag push

parent 8bb14ad0
......@@ -2,40 +2,67 @@ stages:
- build
- deploy
variables:
LEGACY_AUTH_SERVICE_URL: https://download.recette.data.grandlyon.com/auth
ADMIN_USERNAME: nouveau-portail-data
USER_SUPPORT_MAILBOX: alpha-test@erasme.org
build_development:
stage: build
only:
- master
- development
script:
- export NODE_ENV=DEV
- export TAG=dev
- export MIDDLEWARE_LEGACY_SERVICE_BIND_PORT=3004
- docker-compose build
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker-compose push
build_release:
stage: build
only:
- tags
except:
- /^(?!master).+@/
script:
- export TAG=$(echo $CI_COMMIT_TAG | sed 's/v//g')
- export MIDDLEWARE_LEGACY_SERVICE_BIND_PORT=3004
- docker-compose build
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker-compose push
deploy_development:
stage: deploy
only:
- master
- development
script:
- export NODE_ENV=DEV
- export TAG=dev
- export MIDDLEWARE_LEGACY_SERVICE_BIND_PORT=3004
- export SERVICE_EMAIL_URL=http://vm-refonte-data-2:9000/email
- export FRONT_END_URL=https://data-reloaded-dev.alpha.grandlyon.com/fr
- export API_KEY=$DEV_API_KEY
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker-compose pull
- docker-compose --project-name middleware-legacy-auth-${TAG} up -d
- docker-compose --project-name middleware-legacy-auth-${TAG} up -d --force-recreate
environment:
name: development
deploy_staging:
stage: deploy
only:
- master
- development
when: manual
script:
- export TAG=staging
- export NODE_ENV=REC
- sed -i 's/DEV_/REC_/g' docker-compose.yml
- export MIDDLEWARE_LEGACY_SERVICE_BIND_PORT=3104
- export SERVICE_EMAIL_URL=http://vm-refonte-data-2:9100/email
- export FRONT_END_URL=https://data-reloaded-rec.alpha.grandlyon.com/fr
- export API_KEY=$REC_API_KEY
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- TAG=dev docker-compose pull
- docker tag $CI_REGISTRY/refonte-data/middleware-legacy-auth:dev $CI_REGISTRY/refonte-data/middleware-legacy-auth:${TAG}
- docker push $CI_REGISTRY/refonte-data/middleware-legacy-auth:${TAG}
- docker-compose --project-name middleware-legacy-auth-${TAG} up -d
- docker-compose --project-name middleware-legacy-auth-${TAG} up -d --force-recreate
environment:
name: staging
......@@ -2,20 +2,18 @@ version: '3.1'
services:
middleware-legacy-auth:
container_name: middleware-legacy-auth-${TAG}
build: .
image: registry.alpha.grandlyon.com/refonte-data/middleware-legacy-auth:${TAG}
ports:
- ${DEV_SERVICE_PORT}:3000
- ${MIDDLEWARE_LEGACY_SERVICE_BIND_PORT}:3000
environment:
- NODE_ENV=${NODE_ENV}
- AUTH_URL=${DEV_AUTH_URL}
- ADMIN_PASSWORD=${DEV_ADMIN_PASSWORD}
- ADMIN_USERNAME=${DEV_ADMIN_USERNAME}
- SERVICE_EMAIL_URL=${DEV_SERVICE_EMAIL_URL}
- PLATEFORM_DATA_ADMIN_EMAIL=${DEV_PLATEFORM_DATA_ADMIN_EMAIL}
- FRONT_END_URL=${DEV_FRONT_END_URL}
- API_KEY=${DEV_API_KEY}
- LEGACY_AUTH_SERVICE_URL=${LEGACY_AUTH_SERVICE_URL}
- ADMIN_PASSWORD=${ADMIN_PASSWORD}
- ADMIN_USERNAME=${ADMIN_USERNAME}
- SERVICE_EMAIL_URL=${SERVICE_EMAIL_URL}
- USER_SUPPORT_MAILBOX=${USER_SUPPORT_MAILBOX}
- FRONT_END_URL=${FRONT_END_URL}
- API_KEY=${API_KEY}
restart: unless-stopped
depends_on:
- redis
......
......@@ -18,11 +18,11 @@ export class ConfigService {
}
}
this._config.authUrl = process.env.AUTH_URL;
this._config.legacyAuthServiceUrl = process.env.LEGACY_AUTH_SERVICE_URL;
this._config.adminPassword = process.env.ADMIN_PASSWORD;
this._config.adminUsername = process.env.ADMIN_USERNAME;
this._config.serviceEmailUrl = process.env.SERVICE_EMAIL_URL;
this._config.plateformeDataAdminEmail = process.env.PLATEFORM_DATA_ADMIN_EMAIL;
this._config.userSupportMailbox = process.env.USER_SUPPORT_MAILBOX;
this._config.frontEnd.url = process.env.FRONT_END_URL;
this._config.apiKey = process.env.API_KEY;
......
export const Config = {
authUrl: '',
legacyAuthServiceUrl: '',
adminUsername: '',
adminPassword: '',
serviceEmailUrl: '',
plateformeDataAdminEmail: '',
userSupportMailbox: '',
publicKey: '',
privateKey: '',
accountCreationTokenTTL: 86400, // Time to live of the token used to validate the cration of an account in second (24h)
......
AUTH_URL=
LEGACY_AUTH_SERVICE_URL=
ADMIN_PASSWORD=
ADMIN_USERNAME=
SERVICE_EMAIL_URL=
PLATEFORM_DATA_ADMIN_EMAIL=
USER_SUPPORT_MAILBOX=
......@@ -36,7 +36,7 @@ export class LegacyService {
Logger.log(`[-] Get User method`);
try {
const decryptedPassword = decrypt(loginForm.password, this.conf.privateKey);
let res = await request.post(`${this.conf.authUrl}/get_user/`).form({ username: loginForm.username, password: decryptedPassword });
let res = await request.post(`${this.conf.legacyAuthServiceUrl}/get_user/`).form({ username: loginForm.username, password: decryptedPassword });
res = JSON.parse(res);
if (res.server_response && res.server_response === 'Success') {
const userInfo = new UserInfoWithEcryptedPassword(res.user, loginForm.password);
......@@ -59,7 +59,7 @@ export class LegacyService {
Logger.log(`[-] Get User method`);
try {
const password = decrypt(encryptedPassword, this.conf.privateKey);
let res = await request.post(`${this.conf.authUrl}/get_user/`).form({ username, password });
let res = await request.post(`${this.conf.legacyAuthServiceUrl}/get_user/`).form({ username, password });
res = JSON.parse(res);
if (res.server_response && res.server_response === 'Success') {
const userInfo = new UserInfo(res.user);
......@@ -82,11 +82,11 @@ export class LegacyService {
Logger.log(`[-] Update User method`);
try {
const decryptedOldPassword = decrypt(updatePasswordForm.oldPassword, this.conf.privateKey);
let res = await request.post(`${this.conf.authUrl}/get_user/`).form({ username, password: decryptedOldPassword });
let res = await request.post(`${this.conf.legacyAuthServiceUrl}/get_user/`).form({ username, password: decryptedOldPassword });
res = JSON.parse(res);
if (res.server_response && res.server_response === 'Success') {
const decryptedNewPassword = decrypt(updatePasswordForm.newPassword, this.conf.privateKey);
res = await request.post(`${this.conf.authUrl}/update_user_password/`).form({
res = await request.post(`${this.conf.legacyAuthServiceUrl}/update_user_password/`).form({
username,
password: decryptedNewPassword,
admin_username: this.conf.adminUsername,
......@@ -169,7 +169,7 @@ export class LegacyService {
if (userInfo) {
Logger.log(`User account validation for : ${userInfo.email}`);
let res = await request.post(`${this.conf.authUrl}/add_user/`).form(userInfo);
let res = await request.post(`${this.conf.legacyAuthServiceUrl}/add_user/`).form(userInfo);
res = JSON.parse(res);
if (res.server_response && res.server_response === 'Success') {
Logger.log(res);
......@@ -204,7 +204,7 @@ export class LegacyService {
Logger.log(`[-] update User method`);
try {
const legacyForm = new LegacyUserUpdateForm(form, token.username, decrypt(token.authzKey, this.conf.privateKey));
let res = await request.post(`${this.conf.authUrl}/update_user/`).form(legacyForm);
let res = await request.post(`${this.conf.legacyAuthServiceUrl}/update_user/`).form(legacyForm);
res = JSON.parse(res);
if (res.server_response && res.server_response === 'Success') {
return;
......@@ -239,7 +239,7 @@ export class LegacyService {
const decryptedPassword = decrypt(form.password, this.conf.privateKey);
let res = await request.post(`${this.conf.authUrl}/update_user_password/`).form({
let res = await request.post(`${this.conf.legacyAuthServiceUrl}/update_user_password/`).form({
username,
password: decryptedPassword,
admin_username: this.conf.adminUsername,
......@@ -317,7 +317,7 @@ export class LegacyService {
async getServices(): Promise<Service[]> {
Logger.log(`[-] Get services method`);
try {
let res = await request.get(`${this.conf.authUrl}/get_modes/`);
let res = await request.get(`${this.conf.legacyAuthServiceUrl}/get_modes/`);
res = JSON.parse(res);
if (res.services) {
const modes: Service[] = [];
......@@ -350,7 +350,7 @@ export class LegacyService {
}
// Get the list of the accessible services by the user
let res = await request.post(`${this.conf.authUrl}/get_user_service/`).form({ username, password });
let res = await request.post(`${this.conf.legacyAuthServiceUrl}/get_user_service/`).form({ username, password });
res = JSON.parse(res);
......@@ -381,7 +381,7 @@ export class LegacyService {
async getRestrictedAccessDatasets(): Promise<RestrictedAccessDataset[]> {
Logger.log(`[-] Get Restricted Access dataset method`);
try {
let rawRestrictedService = await request.get(`${this.conf.authUrl}/get_services/`);
let rawRestrictedService = await request.get(`${this.conf.legacyAuthServiceUrl}/get_services/`);
rawRestrictedService = JSON.parse(rawRestrictedService);
const restrictedServices = [];
......@@ -427,7 +427,7 @@ export class LegacyService {
for (const accessRequest of accessRequests) {
// Request access the the specified service and the specified modes
let res = await request.post(`${this.conf.authUrl}/add_user_service/`).form(
let res = await request.post(`${this.conf.legacyAuthServiceUrl}/add_user_service/`).form(
{
password,
username: token.username,
......@@ -484,7 +484,7 @@ export class LegacyService {
await Promise.all([
this.sendEmail({
html: adminEmail,
to: [this.conf.plateformeDataAdminEmail],
to: [this.conf.userSupportMailbox],
subject: 'Demande d’accès aux données',
}),
this.sendEmail({
......@@ -581,7 +581,7 @@ export class LegacyService {
await Promise.all([
this.sendEmail({
html: adminEmail,
to: [this.conf.plateformeDataAdminEmail],
to: [this.conf.userSupportMailbox],
subject: 'Demande de renouvellement d’accès aux données',
}),
this.sendEmail({
......@@ -626,7 +626,7 @@ export class LegacyService {
for (const accessRequest of accessRequests) {
// Delete access to the specified service and the specified modes
let res = await request.post(`${this.conf.authUrl}/del_user_service/`).form(
let res = await request.post(`${this.conf.legacyAuthServiceUrl}/del_user_service/`).form(
{
password,
username: token.username,
......@@ -682,7 +682,7 @@ export class LegacyService {
await Promise.all([
this.sendEmail({
html: adminEmail,
to: [this.conf.plateformeDataAdminEmail],
to: [this.conf.userSupportMailbox],
subject: 'Demande de suppression d’accès aux données',
}),
this.sendEmail({
......@@ -713,7 +713,7 @@ export class LegacyService {
}
// Delete access to the specified service and the specified modes
let res = await request.post(`${this.conf.authUrl}/delete_user/`).form(
let res = await request.post(`${this.conf.legacyAuthServiceUrl}/delete_user/`).form(
{
password,
username: token.username,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment