From cf55087b3410b4f861aa8856dd6136bc6a82bf5e Mon Sep 17 00:00:00 2001 From: Andrei Dekterev Date: Wed, 23 Nov 2022 11:00:57 +0300 Subject: [PATCH] Revert Revert "fix(#169): autoscalling auth" This reverts commit 3ce2ab1cb8ea79e8799415219eb97b6e88c90bd7. --- .drone.yml | 40 +++++++++++++++++++ Makefile | 7 ++++ src/config/routes.tsx | 2 +- .../AuthServiceApp/components/Oauth/index.tsx | 4 +- src/features/AuthServiceApp/config/routes.tsx | 14 ++++--- src/features/AuthStore/helpers.tsx | 4 +- src/react-app-env.d.ts | 2 +- 7 files changed, 63 insertions(+), 10 deletions(-) diff --git a/.drone.yml b/.drone.yml index c9f8dd62..6397fe22 100644 --- a/.drone.yml +++ b/.drone.yml @@ -454,6 +454,46 @@ steps: - aws cloudfront create-invalidation --distribution-id EJYRP4WNVMWD1 --paths "/*" +--- +kind: pipeline +type: docker +name: deploy test-j + +concurrency: + limit: 1 + +platform: + os: linux + arch: amd64 + +trigger: + ref: + - refs/heads/test-j + +steps: + - name: deploy script + image: node:16-alpine + + environment: + AWS_ACCESS_KEY_ID: + from_secret: AWS_ACCESS_KEY_ID + AWS_SECRET_ACCESS_KEY: + from_secret: AWS_SECRET_ACCESS_KEY + AWS_DEFAULT_REGION: + from_secret: AWS_DEFAULT_REGION + REACT_APP_STRIPE_PK: + from_secret: REACT_APP_STRIPE_PK_TEST + SSH_KEY_AUTH: + from_secret: SSH_KEY_AUTH + + commands: + - apk add --no-cache aws-cli bash git openssh-client make rsync + - npm install --legacy-peer-deps + - make build-j + - aws s3 sync build s3://instat-frontend-test-j --delete + - aws cloudfront create-invalidation --distribution-id EC35D25OP7FSL --paths "/*" + + --- kind: pipeline type: docker diff --git a/Makefile b/Makefile index 8345e806..293df69c 100644 --- a/Makefile +++ b/Makefile @@ -85,6 +85,13 @@ build-i: clean REACT_APP_STAGE=test-i \ npm run build +build-j: clean + REACT_APP_TYPE=ott \ + REACT_APP_ENV=staging \ + REACT_APP_CLIENT=insports \ + REACT_APP_STAGE=test-j \ + npm run build + auth-build: rm -rf build_auth diff --git a/src/config/routes.tsx b/src/config/routes.tsx index b307e805..8c769dfa 100644 --- a/src/config/routes.tsx +++ b/src/config/routes.tsx @@ -13,7 +13,7 @@ export const APIS = { }, staging: { api: 'https://api.test.insports.tv', - auth: 'https://auth.test.insports.tv', + auth: 'https://www.auth.test.insports.tv', }, } diff --git a/src/features/AuthServiceApp/components/Oauth/index.tsx b/src/features/AuthServiceApp/components/Oauth/index.tsx index da5feca2..d408c8fe 100644 --- a/src/features/AuthServiceApp/components/Oauth/index.tsx +++ b/src/features/AuthServiceApp/components/Oauth/index.tsx @@ -10,7 +10,7 @@ import type { Settings } from 'features/AuthStore/helpers' import { getClientSettings } from 'features/AuthStore/helpers' import { T9n } from 'features/T9n' -import { API_ROOT } from '../../config/routes' +import { getApiUrl } from 'features/AuthServiceApp/config/routes' import { PAGES } from '../../config/pages' import { useOauth } from './hooks' import { @@ -29,7 +29,7 @@ import { } from './styled' import { ErrorPopup } from '../../../../components/ErrorPopup' -const url = `${API_ROOT}/oauth` +const url = getApiUrl('/oauth') const Oauth = () => { const { diff --git a/src/features/AuthServiceApp/config/routes.tsx b/src/features/AuthServiceApp/config/routes.tsx index 9aa8df43..30ba0ea8 100644 --- a/src/features/AuthServiceApp/config/routes.tsx +++ b/src/features/AuthServiceApp/config/routes.tsx @@ -1,12 +1,16 @@ -import { ENV } from 'config/env' +import { ENV, isProduction } from 'config/env' + +import { readSelectedApi } from 'helpers/selectedApi' const APIS = { - preproduction: 'https://auth.insports.tv', - production: 'https://auth.insports.tv', - staging: 'https://auth.test.insports.tv', + preproduction: 'https://api.auth.insports.tv', + production: 'https://api.auth.insports.tv', + staging: 'https://api.auth.test.insports.tv', } -export const API_ROOT = APIS[ENV] +const env = isProduction ? ENV : readSelectedApi() ?? ENV + +export const API_ROOT = APIS[env] export const getApiUrl = (path: string) => ( `${API_ROOT}${path}${window.location.search}` diff --git a/src/features/AuthStore/helpers.tsx b/src/features/AuthStore/helpers.tsx index 4edfec33..7f8662a1 100644 --- a/src/features/AuthStore/helpers.tsx +++ b/src/features/AuthStore/helpers.tsx @@ -6,6 +6,8 @@ import { AUTH_SERVICE } from 'config/routes' import { ClientIds, ClientNames } from 'config/clients/types' import { ENV, stageENV } from 'config/env' +import { API_ROOT } from 'features/AuthServiceApp/config/routes' + export interface Settings extends UserManagerSettings { client_id: ClientIds, lang?: string, @@ -48,7 +50,7 @@ export const getClientSettings = (): Settings => ({ client_id: client.auth.clientId, filterProtocolClaims: false, loadUserInfo: false, - metadataUrl: `${AUTH_SERVICE}/.well-known/openid-configuration${client.auth.metaDataUrlParams || ''}`, + metadataUrl: `${API_ROOT}/.well-known/openid-configuration${client.auth.metaDataUrlParams || ''}`, redirect_uri: redirectUrl(), response_mode: 'query', response_type: 'id_token token', diff --git a/src/react-app-env.d.ts b/src/react-app-env.d.ts index 9c206a49..65952d05 100644 --- a/src/react-app-env.d.ts +++ b/src/react-app-env.d.ts @@ -5,7 +5,7 @@ declare namespace NodeJS { export interface ProcessEnv { REACT_APP_CLIENT: 'instat' | 'facr' | 'lff' | 'insports', REACT_APP_ENV: 'production' | 'preproduction' | 'staging', - REACT_APP_STAGE: 'staging' | 'test-a' | 'test-b' | 'test-c' | 'test-d' | 'test-e' | 'test-f' | 'test-g' | 'test-h' | 'test-i' | 'test', + REACT_APP_STAGE: 'staging' | 'test-a' | 'test-b' | 'test-c' | 'test-d' | 'test-e' | 'test-f' | 'test-g' | 'test-h' | 'test-i' | 'test-j' | 'test', REACT_APP_TYPE: 'auth-service' | 'ott', } }