Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • web-et-numerique/factory/llle_project/self-data-technical-doc
1 result
Select Git revision
Show changes
![pilote](../../img/mps.png){: .center}
# Pilote
Pilote aims to help people in various administrative processes, allowing them to share their personal information with a social worker to build the best possible claim for every needs.
![pilote](../img/mps.png){: .center}
Pilote aims to help people in various administrative processes, allowing them to share their personal information with a social worker to build the best possible claim for every needs.
!!! danger "Reminder"
If you're a new developer tasked to work on this project, please get acquainted with the team [processes](https://forge.grandlyon.com/web-et-numerique/wiki_web_num) and read the advised [dev environment](https://forge.grandlyon.com/web-et-numerique/wiki_web_num) documentation and the self-data [prerequisites](../index.md#installing-prerequisites).
## ![gitlab](../img/gitlab-logo.svg) Repositories
[MPS group](https://forge.grandlyon.com/solidarite/monparcourssocial) contains the following repositories:
* [pilote usager](https://forge.grandlyon.com/solidarite/monparcourssocial/mps-usager)
* travailleur social
* [backend](https://forge.grandlyon.com/solidarite/monparcourssocial/mps-travailleursocial-back)
* [frontend](https://forge.grandlyon.com/solidarite/monparcourssocial/mps-travailleursocial)
- [pilote usager](https://forge.grandlyon.com/solidarite/monparcourssocial/mps-usager)
- travailleur social
- [backend](https://forge.grandlyon.com/solidarite/monparcourssocial/mps-travailleursocial-back)
- [frontend](https://forge.grandlyon.com/solidarite/monparcourssocial/mps-travailleursocial)
## Requirements
Node **16**
Node **16**
## Acces to the application deployed
......
# Description
This section of documentation refers to the Oauth protocols working hand in hand with our custom proxy and the cozy-stack.
To fully understand its whereabouts, you should also look at the [enedis konnector](/konnectors/enedis/) and [grdf konnector](/konnectors/grdf/) documentation.
![gitlab](../img/gitlab-logo.svg) [proxy](https://forge.grandlyon.com/pocs/cozy/cozy-oauth-proxy)
## Oauth Dance
To access customer data, one must first obtain customer authorization. This authorization is materialized by an access token and it must be obtained by the APIs exposed by each energy providers.
......@@ -11,9 +12,10 @@ To access customer data, one must first obtain customer authorization. This auth
These APIs implement Oauth 2.0 protocol, it requires authentication from the customer along with its given consent.
See both **[Enedis](./use_cases/enedis.md)** and **[Grdf](./use_cases/grdfadict.md)** use cases before going further.
### Cozy Oauth Protocol
!!! info "cozy oauth flow documentation"
!!! info "cozy oauth flow documentation"
[https://docs.cozy.io/en/cozy-stack/konnectors-workflow/#reminder-oauth-flow](https://docs.cozy.io/en/cozy-stack/konnectors-workflow/#reminder-oauth-flow)
#### CouchDB
......@@ -87,7 +89,7 @@ Example:
xyz.cozygrandlyon.cloud/account/redirect -> redirect to xyz
toto.cozygrandlyon.cloud/account/redirect -> redirect to toto
- If the provider (Enedis for instance) is not accepting wildcards, then we put a proxy as a middleware to provide a generic endpoint to cater for all Oauth2 redirection.
- If the provider (Enedis for instance) is not accepting wildcards, then we put a proxy as a middleware to provide a generic endpoint to cater for all Oauth2 redirection.
#### Result
......@@ -112,7 +114,6 @@ With that in mind, the proxy is now the one calling the auth and token provider
Stack <-- Proxy: token
```
## Proxy Code Explained
!!! info "reminder"
......@@ -122,7 +123,7 @@ The proxy is coded in golang.
It is composed of six endpoints as seen above. The first endpoint to be called is **/auth**.
#### auth
### auth
Originally called from a cozy-stack trying to setup its konnector. The proxy gets these information from the query:
......@@ -138,18 +139,18 @@ The state will be merged with the instance name, then decomposed again when reac
With all these information, the proxy can contact the provider **/auth** endpoint to start the oauth dance.
##### Enedis
#### Enedis
!!! warning "note"
See that a new composed state is sent to enedis, it is made of the former state conceived by the cozy-stack + the original instance name. This will be useful when enedis is leading the oauth dance to the next step and we will need the name of the cozy to answer.
Once the call is sent, enedis will point to the **/redirect** endpoint.
##### Grdf
#### Grdf
> To be redacted
#### redirect
### redirect
Retrieve the *code*, *usage_point_id*, and *state* answered by Enedis.
......@@ -163,9 +164,9 @@ Finally redirect all these parameters in a query to the cozy-stack (the cozy-sta
!!! warning "state / instance"
The state must be recovered without the instance name, otherwise the cozy-stack won't recognized it and the handshake will fail.
#### token
### token
Gathering from query or parameters all params.
Sends a post request to the provider /token endpoint.
Sends a post request to the provider /token endpoint.
The stack will store the response params in a *accounts* CouchDB database.
# Monitoring
All logs printed by the Proxy are read and translated into statistics on a grafana dashboard.
!!! info "Grafana"
[scaleway monitoring](https://grafana.self-data.alpha.grandlyon.com/)
[production address](https://oauth-logs.cozycloud.cc/d/xSRhz8fMk/cozy-oauth-proxy?orgId=1&refresh=5s)
This monitoring system allow the team to parse more easily the cozy-stack logs when something goes wrong. For instance, test konnector or check from the proxy if an issue was coming from Enedis or Grdf.
Learn more about how it works [here](https://forge.grandlyon.com/web-et-numerique/llle_project/logs-monitoring).
......@@ -18,4 +20,4 @@ To easily plug loki on a specific instance:
- Click on configuration and data sources
- Add data sources
- Find Loki and type the loki url http://loki:3100
- In the query builder select the container "easy-cozy" then add |= "domain=[specific-instance]"
\ No newline at end of file
- In the query builder select the container "easy-cozy" then add |= "domain=[specific-instance]"
### Enedis Data Connect
# Enedis Data Connect
!!! warning "DEPRECATED"
This section of documentation is not relevant anymore, enedis data connect has been replaced with enedis sge
!!! info "enedis documentation"
Create an account on [https://datahub-enedis.fr/](https://datahub-enedis.fr/) to explore all the services exposed by Enedis.
[Authorize API](https://datahub-enedis.fr/data-connect/documentation/authorize-v1/) swagger.
[Api healthcheck](https://datahub-enedis.fr/data-connect/ressources/etat-des-services/).
Regarding Enedis, two endpoints are exposed:
#### Authorize
##### /dataconnect/v1/oauth2/authorize
## Authorize
### /dataconnect/v1/oauth2/authorize
<table>
<colgroup>
......@@ -36,7 +38,7 @@ Regarding Enedis, two endpoints are exposed:
</tr>
<tr>
<td>state</td>
<td>Security parameter allowing to maintain the state between the request and the redirection. ** Maximum length of 100 characters ! **</td>
<td>Security parameter allowing to maintain the state between the request and the redirection. **Maximum length of 100 characters !**</td>
</tr>
<tr>
<td>duration</td>
......@@ -48,8 +50,8 @@ Regarding Enedis, two endpoints are exposed:
!!! important "Important"
The response targets the redirect-uri registered with Enedis (the redirect-uri is our proxy and the response will be explained in details further below when explaining the proxy endpoints mechanics).
#### Token
##### /v1/oauth2/token
## Token
### /v1/oauth2/token
<table>
<colgroup>
......@@ -96,11 +98,11 @@ Regarding Enedis, two endpoints are exposed:
On success, response will contain **access_token** or **refresh_token**, **usage_point_id** among other things. All information will be stored by the cozy-stack in a cozy-accounts database.
#### Consent Handling
## Consent Handling
Consent is replaced every time a new oauth dance is launched (for 6 months, hard coded in **/authorize** request).
User can revoke its consent from the Enedis website, no external endpoints are available for this purpose.
If a consent has been revoked or expired. A 403 error will be thrown saying: *No consent can be found for this customer and this usage point*.
Ecolyo can warn the user that the service is unable to continue and ask to give new consent.
\ No newline at end of file
Ecolyo can warn the user that the service is unable to continue and ask to give new consent.
### Grdf Adict
# Grdf Adict
!!! info "grdf documentation"
Visit [https://sites.grdf.fr/web/portail-api-grdf-adict/documentation-grdf-adict](https://sites.grdf.fr/web/portail-api-grdf-adict/documentation-grdf-adict) to explore all the services exposed by Grdf.
......@@ -9,25 +9,26 @@ Regarding Grdf Adict Oauth connection, two endpoints are exposed:
!!! warning "Oauth connection still in Beta"
Grdf Adict Oauth service is called Client Connect and is still in early beta. It is currently lacking a *state* parameter in the Oauth dance.
#### Authorize
##### /oauth2/realms/externeGrdf/authorize
## Authorize
#### Token
##### /oauth2/realms/externeGrdf/access_token
### /oauth2/realms/externeGrdf/authorize
## Token
The */access_token* endpoint can be called with two different *grant_type* parameter.
### /oauth2/realms/externeGrdf/access_token
- *authorization_code* gives an access token and will also retrieve the consents list given by the user in session.
- *client_credentials* gives only the access token allowing us to request the data service.
The *access_token* endpoint can be called with two different *grant_type* parameter.
The grdf Konnector would only need to call the *client_credentials* to get a refresh token.
- *authorization_code* gives an access token and will also retrieve the consents list given by the user in session.
- *client_credentials* gives only the access token allowing us to request the data service.
#### Consent Handling
The grdf Konnector would only need to call the *client_credentials* to get a refresh token.
## Consent Handling
Consent is represented by an access right. This access holds characteristics specific to the consent of the end customer.
##### Optional: Revoke consent from external applications
It is possible to cancel a consent that was given from the user to our service (for test or development purpose for instance).
### Optional: Revoke consent from external applications
It is possible to cancel a consent that was given from the user to our service (for test or development purpose for instance).
**api.grdf.fr/adict/v1/droit_acces/{id_accreditation}**
This section will allow you to install a proper local environment step by step for Pilote application using VSCode IDE.
# Setup your environment
This section will allow you to install a proper local environment step by step.
## VSCode
### Install VSCode
Installation for VSCode can be found here: [Installation of VSCode](https://code.visualstudio.com/).
Installation for VSCode can be found [here](https://code.visualstudio.com/).
### Extensions
Installation of Extension is explained here: [Installation of Extensions](https://code.visualstudio.com/docs/editor/extension-gallery).
Here are the list of important extensions to install:
Some of our projects might contain a `/.vscode/extensions.json` to recommand specific extesions. But here is a list of general important extensions to install:
- Prettier - Code formatter
- ES7 React/Redux/GraphQL/React-Native snippets
- GitLens - Git supercharged
- Markdown Preview
- [Clipboard Manager](https://marketplace.visualstudio.com/items?itemName=EdgardMessias.clipboard-manager)
- [ES7+ React/Redux/React-Native snippets](https://marketplace.visualstudio.com/items?itemName=dsznajder.es7-react-js-snippets)
- [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
- [GitLens - Git supercharged](https://marketplace.visualstudio.com/items?itemName=eamodio.gitlens)
- [Jest Runner](https://marketplace.visualstudio.com/items?itemName=firsttris.vscode-jest-runner)
- [Jest](https://marketplace.visualstudio.com/items?itemName=Orta.vscode-jest)
- [Markdownlint](https://marketplace.visualstudio.com/items?itemName=DavidAnson.vscode-markdownlint)
- [Prettier - Code formatter](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode)
- [SonarLint](https://marketplace.visualstudio.com/items?itemName=SonarSource.sonarlint-vscode)
- [TabOut](https://marketplace.visualstudio.com/items?itemName=albert.TabOut)
- [Todo Tree](https://marketplace.visualstudio.com/items?itemName=Gruntfuggly.todo-tree)
Optional extensions:
- CSS Peek
- Auto Rename Tag
- indent-rainbow
- TabOut
- Liveshare (pair programming extension)
### User settings
Open the project with VSCode and add the following code into .vscode/settings.json:
Open the project with VSCode and add the following code into `.vscode/settings.json`:
```
```json
{
"workbench.colorCustomizations": {
/* Put anything you like here */
},
"breadcrumbs.enabled": true,
"editor.snippetSuggestions": "top",
"editor.tabSize": 2,
"editor.formatOnSave": true,
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
"diffEditor.ignoreTrimWhitespace": false,
"javascript.updateImportsOnFileMove.enabled": "always",
"window.zoomLevel": 0,
"gitlens.advanced.messages": {
"suppressShowKeyBindingsNotice": true
"suppressShowKeyBindingsNotice": true
},
"breadcrumbs.enabled": true,
"workbench.colorCustomizations": {
/* Put anything you like here */
},
"workbench.settings.editor": "json",
"editor.tabSize": 2,
"editor.formatOnSave": true,
"editor.formatOnPaste": true
}
```
If this file is not empty, you can simply add the following lines to it:
## Install your Linux distribution
If you're using windows, we highly recommand to install WSL. Checkout the official documation for installation or our [installation wiki](wsl.md).
### Setup your distribution
1. Start updating the packages list by typing:
```sh
sudo apt update
```
2. Install nodejs using the apt package manager
```sh
sudo apt install
```
## Installing prerequisites
Name | Required | Details
---------------------------------- | -------- | -------
[Docker-compose](https://docs.docker.com/compose/install/) | Yes
[Docker](https://www.docker.com/get-started) | Yes | See [cozystack](https://docs.cozy.io/en/cozy-stack/) for more information.
Git | Yes |
[Node](https://nodejs.org/en/download/) | Yes | Node 14 and 16 must be installed as it is the version that runs on the official cozystack.
[WSL](index.md#wsl) | No | Required for windows users.
[Yarn](https://classic.yarnpkg.com/en/docs/install) | Yes | Yarn is our projects package manager.
### Git
We are using Gitlab, you will need to [install Git](https://git-scm.com/) to checkout projects. Make sure to configure your informations :
```sh
git config --global user.name "First_name LAST_NAME"
git config --global user.email "email@example.com"
```
"gitlens.advanced.messages": {
"suppressShowKeyBindingsNotice": true
},
"breadcrumbs.enabled": true,
"workbench.settings.editor": "json",
"editor.formatOnSave": true,
"diffEditor.ignoreTrimWhitespace": false,
"window.zoomLevel": 0,
```
## Git
!!! info "Git version"
Check you installed version. You'll probably have to upgrade to 1.22 to make everything work properly.
In order to achieve this, you'll have to launch several commands:
```sh
sudo apt-get remove cmdtest
sudo apt autoremove
sudo apt-get update
sudo apt install curl -y
curl -o- -L https://yarnpkg.com/install.sh | bash
source ~/.bashrc
```
The project is using Gitlab, you will need to install Git to checkout the project.
Installation for Git can be found here: [Installation of Git](https://git-scm.com/).
Now you should be at least in version ==^1.22== and ready to go on.
## Node
Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine.
### Node
!!! warning "Version 14 & 16"
Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine. [Install here](https://nodejs.org/en/download/)
For our projects you will need to have a version manager for node such as [**n**](https://www.npmjs.com/package/n) on linux and [**nvm**](https://github.com/coreybutler/nvm-windows) on windows. Install both 14 and 16 versions.
!!! warning "We need versions 14 & 16 for our projects so we will have to install a node version manager (more on that later)."
## Yarn
### Npm
Npm should come installed with node. Check your version installed with :
```sh
npm --version
```
### Yarn
Yarn is used as package manager for this project. Feel free to use the one you prefer but we advice to install yarn as all the documentation is described with this package manager.
Installation for yarn can be found here: [Installation of Yarn](https://classic.yarnpkg.com/fr/docs/install/).
## Docker
To Download and Setup Yarn :
```sh
sudo apt install yarn
# OR
npm i -g yarn
# Then check the installed version
yarn -v
```
#### NVM
For our projects you will need to have a version manager for node such as [**n**](https://www.npmjs.com/package/n), [**nvm**](https://github.com/nvm-sh/nvm) and [**nvm-windows**](https://github.com/coreybutler/nvm-windows) on windows. Install both **14** and **16** versions.
```sh
yarn global add nvm
```
=== "Install a version"
```sh
nvm install X.X.X
```
=== "See installed node versions"
```sh
nvm list
```
=== "Switch to a specific version"
```sh
nvm use X.X.X
```
You can then check the current version of node used
```sh
node -v
```
### Docker
Docker is a tool designed to make it easier to create, deploy, and run applications by using containers. Containers allow a developer to package up an application with all of the parts it needs, such as libraries and other dependencies, and ship it all out as one package. By doing so, thanks to the container, the developer can rest assured that the application will run on any other Linux machine regardless of any customized settings that machine might have that could differ from the machine used for writing and testing the code.
### Install Docker
#### Install Docker
Installation of Docker can be found here: [Installation of Docker](https://www.docker.com/get-started).
### Install Docker-Compose
#### Install Docker-Compose
Installation of Docker-Compose (according to your OS) is explained here: [Installation of Docker-Compose](https://docs.docker.com/compose/install/).
# WSL
First open Powershell as administrator and launch the following command:
```powershell
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
```
This command will install WSL on your computer. After this, you'll need to ==**reboot**==.
## Upgrade to WSL 2
If you're on WSL 1 and want to upgrade to WSL 2, here is the process:
1. Open an elevated powershell and paste the following command:
```powershell
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
```
2. Then, enable the Virtual Machine Platform optional feature.
```powershell
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
```
3. Now restart your computer to apply these features. Once it's done, open an elevated powershell again and set the default wsl version to 2
```sh
wsl --set-default-version 2
```
!!! warning "You might see this message after running the command above"
WSL 2 requires an update to its kernel component.
For information please visit [wsl2kernel](https://aka.ms/wsl2kernel).
If you install the MSI from [wsl2kernel](https://aka.ms/wsl2kernel). Once you have the kernel installed, please run `wsl --set-default-version 2` again and it should complete successfully without showing the message.
## Start WSL
After reboot, open the microsoft store and install the distribution of your choice, for instance: ==Ubuntu 20.04 lts==. Once it's done, open it and after a few minutes you'll be prompted for the creation of a user account.
To make sure it's correctly installed and working, you can open Powershell and paste the following command :
```powershell
wsl.exe --list --running
```
Now you should see the name of your distribution in the list. And follow [set_up_your_environment](setup_your_environment.md#install-your-linux-distribution)
......@@ -46,8 +46,8 @@ plugins:
nav:
- Home:
- Getting started: index.md
- Additional Ressources: external_doc.md
- Setup your environment: setup_your_environment.md
- WSL: wsl.md
- Easy Cozy:
- Introduction: easycozy/index.md
- Configuration: easycozy/config.md
......@@ -71,7 +71,6 @@ nav:
- Remote Doctypes: ecolyo/project_architecture/remote_doctypes.md
- Application:
- Deploy: ecolyo/application/deploy.md
- Description: ecolyo/application/description.md
- Gitflow: ecolyo/application/gitflow.md
- Mail: ecolyo/application/mail.md
- Redux: ecolyo/application/redux.md
......@@ -100,7 +99,6 @@ nav:
- Ecolyo-Agent:
- Introduction: ecolyo/ecolyo-agent/introduction.md
- Getting started:
- Setup your environment: ecolyo/ecolyo-agent/getting_started/setup_your_environment.md
- Launch the application on local: ecolyo/ecolyo-agent/getting_started/launch_local_application.md
- Libraries: ecolyo/ecolyo-agent/getting_started/libraries.md
- Functionalities:
......@@ -113,39 +111,38 @@ nav:
- Backup: ecolyo/ecolyo-agent/development/backup.md
- Pilote:
- Introduction: pilote/index.md
- Pilote - TS - Back:
- Pilote-Usager:
- Application:
- Deploy: pilote/Pilote - TS - Back/application/deploy.md
- Deploy: pilote/Pilote-Usager/application/deploy.md
- Doctypes: pilote/Pilote-Usager/application/doctypes.md
- Scaffolding: pilote/Pilote-Usager/application/scaffolding.md
- Services: pilote/Pilote-Usager/application/services.md
- Redux: pilote/Pilote-Usager/application/redux.md
- Functionalities:
- Routes: pilote/Pilote - TS - Back/functionalities/routes.md
- Appointments: pilote/Pilote-Usager/functionalities/appointments.md
- Contact: pilote/Pilote-Usager/functionalities/contact.md
- Document: pilote/Pilote-Usager/functionalities/document.md
- Settings: pilote/Pilote-Usager/functionalities/setting.md
- Cozy Registry: pilote/Pilote-Usager/functionalities/cozy-registry.md
- Getting Started:
- Launch the application on local: pilote/Pilote - TS - Back/getting_started/launch_local_application.md
- Project Architecture: pilote/Pilote - TS - Back/project_architecture/architecture.md
- Pilote - TS - Front:
- Launch local application: pilote/Pilote-Usager/getting_started/launch_local_application.md
- Launch local doctypes: pilote/Pilote-Usager/getting_started/launch_local_doctypes.md
- Launch local services: pilote/Pilote-Usager/getting_started/launch_local_services.md
- Pilote-TS - Back:
- Application:
- Deploy: pilote/Pilote - TS - Front/application/deploy.md
- Deploy: pilote/Pilote-TS-Back/application/deploy.md
- Functionalities:
- Routes: pilote/Pilote - TS - Front/functionalities/functions.md
- Routes: pilote/Pilote-TS-Back/functionalities/routes.md
- Getting Started:
- Launch the application on local: pilote/Pilote - TS - Front/getting_started/launch_local_application.md
- Pilote - Usager:
- Launch the application on local: pilote/Pilote-TS-Back/getting_started/launch_local_application.md
- Project Architecture: pilote/Pilote-TS-Back/project_architecture/architecture.md
- Pilote-TS-Front:
- Application:
- Deploy: pilote/Pilote - Usager/application/deploy.md
- Doctypes: pilote/Pilote - Usager/application/doctypes.md
- Gitflow: pilote/Pilote - Usager/application/gitflow.md
- Scaffolding: pilote/Pilote - Usager/application/scaffolding.md
- Services: pilote/Pilote - Usager/application/services.md
- Store: pilote/Pilote - Usager/application/store.md
- Deploy: pilote/Pilote-TS-Front/application/deploy.md
- Functionalities:
- Appointments: pilote/Pilote - Usager/functionalities/appointments.md
- Contact: pilote/Pilote - Usager/functionalities/contact.md
- Document: pilote/Pilote - Usager/functionalities/document.md
- Settings: pilote/Pilote - Usager/functionalities/setting.md
- Cozy Registry: pilote/Pilote - Usager/functionalities/cozy-registry.md
- Routes: pilote/Pilote-TS-Front/functionalities/functions.md
- Getting Started:
- Launch local application: pilote/Pilote - Usager/getting_started/launch_local_application.md
- Launch local doctypes: pilote/Pilote - Usager/getting_started/launch_local_doctypes.md
- Launch local services: pilote/Pilote - Usager/getting_started/launch_local_services.md
- Launch the application on local: pilote/Pilote-TS-Front/getting_started/launch_local_application.md
- Konnectors:
- Introduction: konnectors/index.md
- Enedis [DEPRECATED]: konnectors/enedis.md
......