From 237a2a54df646e3e6e1df876f18faf3eff292d5f Mon Sep 17 00:00:00 2001 From: Guillaume Chervet Date: Thu, 22 Jun 2023 11:04:34 +0200 Subject: [PATCH 1/3] refactor(oidc): update oid --- src/Ecotag/ClientApp/package-lock.json | 14 +++++++------- src/Ecotag/ClientApp/package.json | 2 +- .../ClientApp/public/OidcTrustedDomains.azure.js | 5 ++++- .../ClientApp/public/OidcTrustedDomains.docker.js | 5 ++++- src/Ecotag/ClientApp/public/OidcTrustedDomains.js | 3 ++- .../public/OidcTrustedDomains.production.js | 5 ++++- src/Ecotag/ClientApp/src/Server/AccessToken.js | 12 +----------- 7 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/Ecotag/ClientApp/package-lock.json b/src/Ecotag/ClientApp/package-lock.json index 87389bb2..d0ec2110 100644 --- a/src/Ecotag/ClientApp/package-lock.json +++ b/src/Ecotag/ClientApp/package-lock.json @@ -9,7 +9,7 @@ "version": "1.0.0", "hasInstallScript": true, "dependencies": { - "@axa-fr/react-oidc": "6.15.9", + "@axa-fr/react-oidc": "6.20.0", "@axa-fr/react-toolkit-all": "1.4.1", "@microsoft/applicationinsights-web": "2.8.6", "@monaco-editor/react": "4.2.1", @@ -92,9 +92,9 @@ } }, "node_modules/@axa-fr/react-oidc": { - "version": "6.15.9", - "resolved": "https://registry.npmjs.org/@axa-fr/react-oidc/-/react-oidc-6.15.9.tgz", - "integrity": "sha512-Nz3Z8+gvBdfOtjjnY6wI7rGAwSnTzVMGveqSFAkCL3aE/E55PA7TBfuVHcXPHLg4eU/U5nTq07FIMdUspKv3uA==", + "version": "6.20.0", + "resolved": "https://registry.npmjs.org/@axa-fr/react-oidc/-/react-oidc-6.20.0.tgz", + "integrity": "sha512-6NH+JNi2Gr9iTBNuj/fwOpKfCFcO8jf5lyKydrM9SPc4ox4NABMaParBtfByaTttxsPuSxVe8Bo60YkFZAKajg==", "hasInstallScript": true, "dependencies": { "base64-js": "1.5.1" @@ -38280,9 +38280,9 @@ } }, "@axa-fr/react-oidc": { - "version": "6.15.9", - "resolved": "https://registry.npmjs.org/@axa-fr/react-oidc/-/react-oidc-6.15.9.tgz", - "integrity": "sha512-Nz3Z8+gvBdfOtjjnY6wI7rGAwSnTzVMGveqSFAkCL3aE/E55PA7TBfuVHcXPHLg4eU/U5nTq07FIMdUspKv3uA==", + "version": "6.20.0", + "resolved": "https://registry.npmjs.org/@axa-fr/react-oidc/-/react-oidc-6.20.0.tgz", + "integrity": "sha512-6NH+JNi2Gr9iTBNuj/fwOpKfCFcO8jf5lyKydrM9SPc4ox4NABMaParBtfByaTttxsPuSxVe8Bo60YkFZAKajg==", "requires": { "base64-js": "1.5.1" } diff --git a/src/Ecotag/ClientApp/package.json b/src/Ecotag/ClientApp/package.json index f7667152..a6e27993 100644 --- a/src/Ecotag/ClientApp/package.json +++ b/src/Ecotag/ClientApp/package.json @@ -3,7 +3,7 @@ "version": "1.0.0", "private": true, "dependencies": { - "@axa-fr/react-oidc": "6.15.9", + "@axa-fr/react-oidc": "6.20.0", "@axa-fr/react-toolkit-all": "1.4.1", "@microsoft/applicationinsights-web": "2.8.6", "@monaco-editor/react": "4.2.1", diff --git a/src/Ecotag/ClientApp/public/OidcTrustedDomains.azure.js b/src/Ecotag/ClientApp/public/OidcTrustedDomains.azure.js index 19a6ae28..23225d05 100644 --- a/src/Ecotag/ClientApp/public/OidcTrustedDomains.azure.js +++ b/src/Ecotag/ClientApp/public/OidcTrustedDomains.azure.js @@ -1,2 +1,5 @@ // Add here trusted domains, access tokens will be send to -const trustedDomains = {default: ["https://axaguildev-ecotag.azurewebsites.net", "https://demo.duendesoftware.com"]}; \ No newline at end of file +const trustedDomains = { + default: ["https://axaguildev-ecotag.azurewebsites.net", "https://demo.duendesoftware.com"], + access_token: { domains : ["https://axaguildev-ecotag.azurewebsites.net", "https://demo.duendesoftware.com"], showAccessToken: true } +}; \ No newline at end of file diff --git a/src/Ecotag/ClientApp/public/OidcTrustedDomains.docker.js b/src/Ecotag/ClientApp/public/OidcTrustedDomains.docker.js index 55f15f04..a6260b4b 100644 --- a/src/Ecotag/ClientApp/public/OidcTrustedDomains.docker.js +++ b/src/Ecotag/ClientApp/public/OidcTrustedDomains.docker.js @@ -1,2 +1,5 @@ // Add here trusted domains, access tokens will be send to -const trustedDomains = {default: ["http://localhost:5010", "https://demo.duendesoftware.com"]}; \ No newline at end of file +const trustedDomains = { + default: ["http://localhost:5010", "https://demo.duendesoftware.com"], + access_token: { domains : ["http://localhost:5010", "https://demo.duendesoftware.com"], showAccessToken: true } +}; \ No newline at end of file diff --git a/src/Ecotag/ClientApp/public/OidcTrustedDomains.js b/src/Ecotag/ClientApp/public/OidcTrustedDomains.js index fc73c67f..5eab6685 100644 --- a/src/Ecotag/ClientApp/public/OidcTrustedDomains.js +++ b/src/Ecotag/ClientApp/public/OidcTrustedDomains.js @@ -1,5 +1,6 @@ // Add here trusted domains, access tokens will be send to const trustedDomains = { - default: ["https://localhost:5001", "https://demo.duendesoftware.com"] + default: ["https://localhost:5001", "https://demo.duendesoftware.com"], + access_token: { domains : ["https://localhost:5001", "https://demo.duendesoftware.com"], showAccessToken: true } }; diff --git a/src/Ecotag/ClientApp/public/OidcTrustedDomains.production.js b/src/Ecotag/ClientApp/public/OidcTrustedDomains.production.js index 9e905294..44417936 100644 --- a/src/Ecotag/ClientApp/public/OidcTrustedDomains.production.js +++ b/src/Ecotag/ClientApp/public/OidcTrustedDomains.production.js @@ -1,2 +1,5 @@ // Add here trusted domains, access tokens will be send to -const trustedDomains = {default: [#{Spa:Oidc:ServiceWorkerTrustedDomain}#]} \ No newline at end of file +const trustedDomains = { + default: [#{Spa:Oidc:ServiceWorkerTrustedDomain}#], + access_token: { domains : [#{Spa:Oidc:ServiceWorkerTrustedDomain}#], showAccessToken: true } +} \ No newline at end of file diff --git a/src/Ecotag/ClientApp/src/Server/AccessToken.js b/src/Ecotag/ClientApp/src/Server/AccessToken.js index 0ddf0643..b428dfdd 100644 --- a/src/Ecotag/ClientApp/src/Server/AccessToken.js +++ b/src/Ecotag/ClientApp/src/Server/AccessToken.js @@ -1,5 +1,5 @@ import {OidcProvider, OidcSecure, useOidcAccessToken} from "@axa-fr/react-oidc"; -import React, {useEffect} from "react"; +import React from "react"; import {withEnvironment} from "./EnvironmentProvider"; import Loading from "./shared/Oidc/Loading.component"; import AuthenticatingError from "./shared/Oidc/AuthenticateError.component"; @@ -15,14 +15,6 @@ const AccessTokenWithProvider = withEnvironment(({environment}) => { let history = useHistory(); - useEffect(() => { - navigator.serviceWorker.getRegistrations().then(function (registrations) { - for (let registration of registrations) { - registration.unregister(); - } - }) - }, []); - const withCustomHistory = () => { return { replaceState: (url, stateHistory) => { @@ -37,8 +29,6 @@ const AccessTokenWithProvider = withEnvironment(({environment}) => { const configuration = { ...config, scope: config.scope.replace("offline_access", ""), - service_worker_relative_url: null, - service_worker_only: false, redirect_uri: window.location.origin + '/access-token/authentication/callback' }; From 6e03f8f8acaca2b57069803d46f979f348add8b9 Mon Sep 17 00:00:00 2001 From: Guillaume Chervet Date: Thu, 22 Jun 2023 22:20:58 +0200 Subject: [PATCH 2/3] refactor(ecotag): repair sonar --- .github/workflows/ecotag-ci.yml | 70 ++++++++++++++++++++++++--------- 1 file changed, 51 insertions(+), 19 deletions(-) diff --git a/.github/workflows/ecotag-ci.yml b/.github/workflows/ecotag-ci.yml index c099dfb1..dadab81b 100644 --- a/.github/workflows/ecotag-ci.yml +++ b/.github/workflows/ecotag-ci.yml @@ -11,22 +11,66 @@ on: jobs: - build-windows: - environment: ml-cli + build_windows: + name: Build and analyze runs-on: windows-latest steps: - - uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v3 with: - fetch-depth: 0 - + java-version: 11 + distribution: 'zulu' # Alternative distribution options are available. + - uses: actions/checkout@v3 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + + - name: npm install + run: npm install + working-directory: src/Ecotag/ClientApp + + - name: npm test + run: npm test -- --runInBand --coverage --watchAll=false + working-directory: src/Ecotag/ClientApp + + - name: npm run build-storybook + run: npm run build-storybook + working-directory: src/Ecotag/ClientApp + + - name: Cache SonarCloud packages + uses: actions/cache@v3 + with: + path: ~\sonar\cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + - name: Cache SonarCloud scanner + id: cache-sonar-scanner + uses: actions/cache@v3 + with: + path: .\.sonar\scanner + key: ${{ runner.os }}-sonar-scanner + restore-keys: ${{ runner.os }}-sonar-scanner + - name: Install SonarCloud scanner + if: steps.cache-sonar-scanner.outputs.cache-hit != 'true' + shell: powershell + run: | + New-Item -Path .\.sonar\scanner -ItemType Directory + dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner - uses: actions/setup-dotnet@v1 - - run: dotnet test + - name: Build and analyze + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + shell: powershell + run: | + .\.sonar\scanner\dotnet-sonarscanner begin /k:"AxaGuilDEv_ml-cli" /o:"axaguildev" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.opencover.reportsPaths=**/coverage.opencover.xml + dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=opencover + .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}" build-linux: environment: ml-cli runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: fetch-depth: 0 - uses: actions/setup-node@v2 @@ -46,21 +90,9 @@ jobs: working-directory: src/Ecotag/ClientApp - uses: actions/setup-dotnet@v1 - - #- name: Sonarqube Begin - # if: ${{ github.actor != 'dependabot[bot]' }} - # run: | - # dotnet tool install --global dotnet-sonarscanner - # dotnet test -p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput=./coverage/opencover.xml - # dotnet sonarscanner begin /d:sonar.login=${{ secrets.SONAR_TOKEN }} /o:AxaGuilDev /k:AxaGuilDev_ml-cli /s:$GITHUB_WORKSPACE/SonarQube.Analysis.xml - run: dotnet test /p:CollectCoverage=true - #- name: Sonarqube end - # if: ${{ github.actor != 'dependabot[bot]' }} - # run: dotnet sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}" - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} tags: runs-on: ubuntu-latest From 539038b0152e530e14d3195ccdfdecac28737e86 Mon Sep 17 00:00:00 2001 From: Guillaume Chervet Date: Thu, 22 Jun 2023 22:32:39 +0200 Subject: [PATCH 3/3] sss --- .github/workflows/ecotag-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ecotag-ci.yml b/.github/workflows/ecotag-ci.yml index dadab81b..022aca04 100644 --- a/.github/workflows/ecotag-ci.yml +++ b/.github/workflows/ecotag-ci.yml @@ -12,8 +12,8 @@ on: jobs: build_windows: - name: Build and analyze runs-on: windows-latest + environment: ml-cli steps: - name: Set up JDK 11 uses: actions/setup-java@v3