Skip to content

Commit

Permalink
Secrets de connexion pour le deploiement sur la demo et docker
Browse files Browse the repository at this point in the history
  • Loading branch information
lowzonenose committed Dec 8, 2024
1 parent cba7630 commit 1110277
Show file tree
Hide file tree
Showing 10 changed files with 101 additions and 81 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
run: npm install

- name: Build
run: npm run build-only -- --mode=demo
run: IAM_CLIENT_ID=${{ secrets.IAM_CLIENT_ID }} IAM_CLIENT_SECRET=${{ secrets.IAM_CLIENT_SECRET }} npm run build-only -- --mode=demo

- name: Upload Binary artifacts
uses: actions/upload-artifact@v4
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/docker-build-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ jobs:
context: .
file: .docker/Dockerfile
build-args: MODE_ENV=production
secrets: |
"IAM_CLIENT_ID=${{ secrets.IAM_CLIENT_ID }}"
"IAM_CLIENT_SECRET=${{ secrets.IAM_CLIENT_SECRET }}"
pull: true
push: true
tags: ${{ steps.meta.outputs.tags }}
Expand Down
3 changes: 3 additions & 0 deletions DRAFT_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Version 1.0.1 de l'entrée cartographique de la Géoplateforme.

#### [Ajout]

* Ajout d'un module de connexion à la GeoPlateforme [#361](https://github.com/IGNF/cartes.gouv.fr-entree-carto/pull/361)

* Ajout du widget d'import de données [#324](https://github.com/IGNF/cartes.gouv.fr-entree-carto/pull/324)

* Ajout du widget de getFeatureInfo pour récupérer les informations attributaires des couches au clic [#354](https://github.com/IGNF/cartes.gouv.fr-entree-carto/pull/354)
Expand Down Expand Up @@ -53,4 +55,5 @@ Version 1.0.1 de l'entrée cartographique de la Géoplateforme.
* Ouverture responsive des panels des widgets sur petits écrans [#360](https://github.com/IGNF/cartes.gouv.fr-entree-carto/pull/360)

#### 🔒 [Sécurité]

---
5 changes: 3 additions & 2 deletions env/.env.demo
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ VITE_GPF_CONF_EDITO_URL="data/edito.json"
VITE_GPF_BASE_URL_EXTERNAL="https://cartes.gouv.fr"

VITE_HTTP_MOCK_REQUEST=0
VITE_HTTP_MOCK_REQUEST_SCENARIO=error # success|error

IAM_URL="https://sso.geopf.fr"
IAM_REALM="geoplateforme"
IAM_CLIENT_ID="cartes-gouv-dev"
IAM_CLIENT_SECRET=""
IAM_CLIENT_ID=
IAM_CLIENT_SECRET=

# variable non lu nativement par vitejs
# uniquement pour information par nodejs lors du build
Expand Down
5 changes: 3 additions & 2 deletions env/.env.development
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ VITE_GPF_CONF_EDITO_URL="data/edito.json"
VITE_GPF_BASE_URL_EXTERNAL=

VITE_HTTP_MOCK_REQUEST=0
VITE_HTTP_MOCK_REQUEST_SCENARIO=error # success|error

IAM_URL="https://sso.geopf.fr"
IAM_REALM="geoplateforme"
IAM_CLIENT_ID="cartes-gouv-dev"
IAM_CLIENT_SECRET=""
IAM_CLIENT_ID=
IAM_CLIENT_SECRET=

# variable non lu nativement par vitejs
# uniquement pour information par nodejs lors du build
Expand Down
5 changes: 3 additions & 2 deletions env/.env.production
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ VITE_GPF_CONF_EDITO_URL="https://data.geopf.fr/annexes/cartes.gouv.fr-config/pub
VITE_GPF_BASE_URL_EXTERNAL=

VITE_HTTP_MOCK_REQUEST=0
VITE_HTTP_MOCK_REQUEST_SCENARIO=error # success|error

IAM_URL="https://sso.geopf.fr"
IAM_REALM="geoplateforme"
IAM_CLIENT_ID="cartes-gouv-dev"
IAM_CLIENT_SECRET=""
IAM_CLIENT_ID=
IAM_CLIENT_SECRET=

# variable non lu nativement par vitejs
# uniquement pour information par nodejs lors du build
Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const logger = createLogger({
const pinia = createPinia()

// INFO
// on enregistre les informations de connexion dans la session
// on enregistre les informations de connexion dans le localStorage
const store = storePlugin({
stores: ['service'],
storage: localStorage,
Expand Down
9 changes: 6 additions & 3 deletions src/mocks/browser.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { setupWorker } from 'msw/browser'
import { handlers } from './handlers'
import { setupWorker } from 'msw/browser';
import { handlers } from './handlers';

export const worker = setupWorker(...handlers)
const scenarioName = import.meta.env.VITE_HTTP_MOCK_REQUEST_SCENARIO;
const runtimeHandlers = handlers[scenarioName] || [];

export const worker = setupWorker(...runtimeHandlers);
138 changes: 71 additions & 67 deletions src/mocks/handlers.js
Original file line number Diff line number Diff line change
@@ -1,71 +1,75 @@
import { http, HttpResponse } from 'msw'
// https://mswjs.io/docs/
export const handlers = [
/**
* obtenir le token
*/
http.post('https://sso.geopf.fr/realms/geoplateforme/protocol/openid-connect/token', async ({ request }) => {
return HttpResponse.json({
"access_token": 'eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJuQTM1bFJNeWVEMnU3WGJDTk9UbTRORjE0eTNoYlBMcGw4TXQtVzR3STJnIn0.eyJleHAiOjE3MzE2MTkwMDksImlhdCI6MTczMTU3NTgwOSwianRpIjoiZWFkOTNjMTAtNTRlMi00NmJkLTkwYjQtNzg5ZDFhYWFlZDJmIiwiaXNzIjoiaHR0cHM6Ly9zc28uZ2VvcGYuZnIvcmVhbG1zL2dlb3BsYXRlZm9ybWUiLCJhdWQiOiJhY2NvdW50Iiwic3ViIjoiMzE3MGViOGYtMWIzNS00ZWZhLWEwZjktY2E0Mjk0OTMzNGY0IiwidHlwIjoiQmVhcmVyIiwiYXpwIjoiY2FydGVzLWdvdXYtZGV2IiwiYWNyIjoiMSIsInJlYWxtX2FjY2VzcyI6eyJyb2xlcyI6WyJkZWZhdWx0LXJvbGVzLWdlb3BsYXRlZm9ybWUiLCJvZmZsaW5lX2FjY2VzcyIsInVtYV9hdXRob3JpemF0aW9uIl19LCJyZXNvdXJjZV9hY2Nlc3MiOnsiYWNjb3VudCI6eyJyb2xlcyI6WyJtYW5hZ2UtYWNjb3VudCIsIm1hbmFnZS1hY2NvdW50LWxpbmtzIiwiZGVsZXRlLWFjY291bnQiLCJ2aWV3LXByb2ZpbGUiXX19LCJzY29wZSI6InByb2ZpbGUgZW1haWwiLCJjbGllbnRJZCI6ImNhcnRlcy1nb3V2LWRldiIsImVtYWlsX3ZlcmlmaWVkIjp0cnVlLCJjbGllbnRIb3N0IjoiODIuMTQyLjIzLjQzIiwicHJlZmVycmVkX3VzZXJuYW1lIjoic2VydmljZS1hY2NvdW50LWNhcnRlcy1nb3V2LWRldiIsImdpdmVuX25hbWUiOiIiLCJjbGllbnRBZGRyZXNzIjoiODIuMTQyLjIzLjQzIiwiZmFtaWx5X25hbWUiOiIiLCJlbWFpbCI6InNlcnZpY2UtYWNjb3VudC1jYXJ0ZXMtZ291di1kZXZAbm8tcmVwbHkuZnIifQ.bVsPFTWz0dY2YmEVjUyJY3wcXXUNF4vR48Z03s4pps8zQg-93dR8c_xjfrSVvLKwW8M-ynZAoAzgrjJydlaoA26wgZlfkxJu8zVKwfnQk_TFeYg-liXiv8YoES8JPL5vRPo-Yaz4JSy-vojJfdFTGx9Sw9UI2ZEfPEgxwuUL3OBuCTqVPG4N_imElCbAFYG6y1fgoGmO8FxGpamfOk16ev9-G8hy1J1heVSzeLWzQtQRuL0bMYWFmLaa0cjrvm8Hemp7Rwe5EHQ9McyQ2_Buu6IsWEYRoaqhqHUrn5MyIKnuAJZ3cZmp8bb_Gu0wFPjzrzh0J8rSy3D60ySai7RS2g',
"expires_in": 43200,
"refresh_expires_in": 0,
"token_type": 'Bearer',
"not-before-policy": 0,
"scope": 'profile email'

/**
* les scenarios : error ou success
* le type de scenario est configuré dans le fichier d'environnement
*/
export const handlers = {
success : [
/**
* obtenir le token
*/
http.post('https://sso.geopf.fr/realms/geoplateforme/protocol/openid-connect/token', async ({ request }) => {
return HttpResponse.json({
"access_token": 'eyJhbGciOiJSUzI1NiIsInR5cCIgOiiSldUIiwia2lkIiA6ICJuQTM1bFJNeWVEMnU3WGJDTk9UbTRORjE0eTNoYlBMcGw4TXQtVzR3STJnIn0.eyJleHAiOjE3MzE2MTkwMDksImlhdCI6MTczMTU3NTgwOSwianRpIjoiZWFkOTNjMTAtNTRlMi00NmJkLTkwYjQtNzg5ZDFhYWFlZDJmIiwiaXNzIjoiaHR0cHM6Ly9zc28uZ2VvcGYuZnIvcmVhbG1zL2dlb3BsYXRlZm9ybWUiLCJhdWQiOiJhY2NvdW50Iiwic3ViIjoiMzE3MGViOGYtMWIzNS00ZWZhLWEwZjktY2E0Mjk0OTMzNGY0IiwidHlwIjoiQmVhcmVyIiwiYXpwIjoiY2FydGVzLWdvdXYtZGV2IiwiYWNyIjoiMSIsInJlYWxtX2FjY2VzcyI6eyJyb2xlcyI6WyJkZWZhdWx0LXJvbGVzLWdlb3BsYXRlZm9ybWUiLCJvZmZsaW5lX2FjY2VzcyIsInVtYV9hdXRob3JpemF0aW9uIl19LCJyZXNvdXJjZV9hY2Nlc3MiOnsiYWNjb3VudCI6eyJyb2xlcyI6WyJtYW5hZ2UtYWNjb3VudCIsIm1hbmFnZS1hY2NvdW50LWxpbmtzIiwiZGVsZXRlLWFjY291bnQiLCJ2aWV3LXByb2ZpbGUiXX19LCJzY29wZSI6InByb2ZpbGUgZW1haWwiLCJjbGllbnRJZCI6ImNhcnRlcy1nb3V2LWRldiIsImVtYWlsX3ZlcmlmaWVkIjp0cnVlLCJjbGllbnRIb3N0IjoiODIuMTQyLjIzLjQzIiwicHJlZmVycmVkX3VzZXJuYW1lIjoic2VydmljZS1hY2NvdW50LWNhcnRlcy1nb3V2LWRldiIsImdpdmVuX25hbWUiOiIiLCJjbGllbnRBZGRyZXNzIjoiODIuMTQyLjIzLjQzIiwiZmFtaWx5X25hbWUiOiIiLCJlbWFpbCI6InNlcnZpY2UtYWNjb3VudC1jYXJ0ZXMtZ291di1kZXZAbm8tcmVwbHkuZnIifQ.bVsPFTWz0dY2YmEVjUyJY3wcXXUNF4vR48Z03s4pps8zQg-93dR8c_xjfrSVvLKwW8M-ynZAoAzgrjJydlaoA26wgZlfkxJu8zVKwfnQk_TFeYg-liXiv8YoES8JPL5vRPo-Yaz4JSy-vojJfdFTGx9Sw9UI2ZEfPEgxwuUL3OBuCTqVPG4N_imElCbAFYG6y1fgoGmO8FxGpamfOk16ev9-G8hy1J1heVSzeLWzQtQRuL0bMYWFmLaa0cjrvm8Hemp7Rwe5EHQ9McyQ2_Buu6IsWEYRoaqhqHUrn5MyIKnuAJZ3cZmp8bb_Gu0wFPjzrzh0J8rSy3D60ySai7RS2g',
"expires_in": 43200,
"refresh_expires_in": 0,
"token_type": 'Bearer',
"not-before-policy": 0,
"scope": 'profile email'
})
}),
/**
* obtenir les informations de l'utilisateur
*/
http.get('https://data.geopf.fr/api/users/me', async ({ request }) => {
return HttpResponse.json({
"email": "[email protected]",
"creation": "2024-01-10T11:21:28.618783Z",
"last_call": "2024-11-05T13:43:56.168033Z",
"communities_member": [
{
"rights": [
"UPLOAD",
"ANNEX",
"BROADCAST",
"PROCESSING"
],
"community": {
"name": "Découverte",
"technical_name": "sandbox",
"datastore": "122b878c-aad7-4507-87b2-465e664467d3",
"supervisor": "e175d6c4-a03e-4ade-a769-86e8dd2bed58",
"public": false,
"_id": "78068951-cebc-4aec-869e-81677d211d0e"
}
}
],
"documents_quota": 500000000,
"documents_use": 8610,
"keys_quota": 10,
"keys_use": 0,
"technical": false,
"administrator": false,
"_id": "09e091dc-51d5-4c04-963d-3045df5ce477",
"last_name": "dupont",
"first_name": "antoine"
})
})
}),
/**
* obtenir les informations de l'utilisateur
*/
http.get('https://data.geopf.fr/api/users/me', async ({ request }) => {
return HttpResponse.json({
"email": "[email protected]",
"creation": "2024-01-10T11:21:28.618783Z",
"last_call": "2024-11-05T13:43:56.168033Z",
"communities_member": [
{
"rights": [
"UPLOAD",
"ANNEX",
"BROADCAST",
"PROCESSING"
],
"community": {
"name": "Découverte",
"technical_name": "sandbox",
"datastore": "122b878c-aad8-4507-87b2-465e664467d3",
"supervisor": "e175d6c4-a03d-4ade-a769-86e8dd2bed58",
"public": false,
"_id": "78068951-cebc-4aec-869c-81677d211d0e"
}
},
{
"rights": [
"UPLOAD",
"PROCESSING",
"COMMUNITY",
"BROADCAST",
"ANNEX"
],
"community": {
"name": "cartes.gouv.fr-config",
"technical_name": "cartes.gouv.fr-config",
"datastore": "5cb4fdb0-6f6c-4422-893d-e04564bfcc10",
"supervisor": "09e091dc-51d5-4c04-9637-3045df5ce477",
"public": false,
"_id": "f7d7279b-043f-413f-a3a3-317f1c6b5b07"
}
}
],
"documents_quota": 500000000,
"documents_use": 8610,
"keys_quota": 10,
"keys_use": 0,
"technical": false,
"administrator": false,
"_id": "09e091dc-51d5-4c04-9637-3045df5ce477",
"last_name": "bazonnais",
"first_name": "jean-philippe"
],
error : [
/**
* echec sur l'obtention du token
*/
http.post('https://sso.geopf.fr/realms/geoplateforme/protocol/openid-connect/token', async ({ request }) => {
return new HttpResponse(null, { status: 404 })
}),
/**
* echec sur l'obtention des informations de l'utilisateur
*/
http.get('https://data.geopf.fr/api/users/me', async ({ request }) => {
return new HttpResponse(null, { status: 401 })
})
})
]
]
}
10 changes: 7 additions & 3 deletions src/views/Main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,22 @@ service.isAccessValided()
});
})
.catch((e:any) => {
throw new Error("[getUserMe]" + e.message);
console.error(e);
serviceMessageError.value = 'Error to get user info : ' + e.message;
serviceMessageClosed.value = false;
})
}
})
.catch((e:any) => {
throw new Error("[getAccessToken]" + e.message);
console.error(e);
serviceMessageError.value = 'Error to get token : ' + e.message;
serviceMessageClosed.value = false;
})
}
})
.catch((e:any) => {
console.error(e);
serviceMessageError.value = e.message;
serviceMessageError.value = 'Error during authentication : ' + e.message;
serviceMessageClosed.value = false;
});
Expand Down

0 comments on commit 1110277

Please sign in to comment.