Compare commits
5 Commits
feat/ajout
...
f2365c08e9
| Author | SHA1 | Date | |
|---|---|---|---|
| f2365c08e9 | |||
|
|
7a9dfa52db | ||
| ba83f4a075 | |||
|
|
a515be554f | ||
| ec4919230b |
57
README.md
57
README.md
@@ -18,7 +18,7 @@ Cette application web permet aux adhérents de l'association KAZ de gérer leur
|
|||||||
Cette base est conçue pour évoluer et intégrer de nouveaux outils et fonctionnalités à l'avenir.
|
Cette base est conçue pour évoluer et intégrer de nouveaux outils et fonctionnalités à l'avenir.
|
||||||
|
|
||||||
## Prérequis
|
## Prérequis
|
||||||
- **PHP** 8.4 ou supérieur
|
- **PHP** 8.4
|
||||||
- **[Composer](https://getcomposer.org/download/)** : (Gestionnaire de dépendances PHP)
|
- **[Composer](https://getcomposer.org/download/)** : (Gestionnaire de dépendances PHP)
|
||||||
- **[Symfony CLI](https://getcomposer.org/download/)** (Interface en ligne de commande Symfony)
|
- **[Symfony CLI](https://getcomposer.org/download/)** (Interface en ligne de commande Symfony)
|
||||||
- **Docker** Permet de lancer les services lié: postgres (base de données), mailpit (serveur de messagerie pour le dev)
|
- **Docker** Permet de lancer les services lié: postgres (base de données), mailpit (serveur de messagerie pour le dev)
|
||||||
@@ -31,34 +31,77 @@ Le projet suit les standards de développement suivants :
|
|||||||
- **[Git Flow](https://git-flow.readthedocs.io/fr/latest/presentation.html)** : Modèle de gestion de branches.
|
- **[Git Flow](https://git-flow.readthedocs.io/fr/latest/presentation.html)** : Modèle de gestion de branches.
|
||||||
- **[Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/)** : Norme pour les messages de commit.
|
- **[Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/)** : Norme pour les messages de commit.
|
||||||
|
|
||||||
|
### Procédure de contribution (Git Flow)
|
||||||
|
|
||||||
|
Toutes les modifications doivent passer par une branche dédiée avant d'être fusionnées dans la branche principal `main` via une Pull Request (Demande d'ajout).
|
||||||
|
|
||||||
|
#### Exemple d'ajout d'une fonctionnalité (feature)
|
||||||
|
1. **Mise à jour de l'environnement local** :
|
||||||
|
```bash
|
||||||
|
git checkout main
|
||||||
|
git pull origin main
|
||||||
|
```
|
||||||
|
2. **Création de la branche de fonctionnalité** (préfixe `feat/`) :
|
||||||
|
```bash
|
||||||
|
git checkout -b feat/nom-de-ma-feature
|
||||||
|
```
|
||||||
|
3. **Développement et commit** (respectant les Conventional Commits) :
|
||||||
|
```bash
|
||||||
|
git add .
|
||||||
|
git commit -m "feat: ajout de la nouvelle fonctionnalité"
|
||||||
|
```
|
||||||
|
4. **Publication de la branche** :
|
||||||
|
```bash
|
||||||
|
git push origin feat/nom-de-ma-feature
|
||||||
|
```
|
||||||
|
5. **Création de la Pull Request** : Rendez-vous sur Gitea pour ouvrir une PR de `feat/nom-de-ma-feature` vers `main`. Une fois revue et validée, elle sera fusionnée via l'interface.
|
||||||
|
|
||||||
|
#### Exemple de correction de bug (fix)
|
||||||
|
La procédure est identique, mais utilisez le préfixe `fix/` :
|
||||||
|
```bash
|
||||||
|
git checkout -b fix/nom-du-bug
|
||||||
|
# ... corrections ...
|
||||||
|
git commit -m "fix: résolution du problème"
|
||||||
|
git push origin fix/nom-du-bug
|
||||||
|
```
|
||||||
|
|
||||||
|
Pour les tâches de maintenance ou documentation, utilisez respectivement les préfixes `chore/` ou `docs/`.
|
||||||
|
|
||||||
## Quick start
|
## Quick start
|
||||||
|
|
||||||
### 1. Installation des dépendances
|
### 1. Clonage du projet
|
||||||
Clonez le projet et installez les dépendances avec Composer :
|
Clonez le projet en utilisant SSH :
|
||||||
|
```bash
|
||||||
|
git clone ssh://git@git.kaz.bzh:2202/melvin-leveque/interface-kaznautes.git
|
||||||
|
cd interface-kaznautes
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. Installation des dépendances
|
||||||
|
Installez les dépendances avec Composer :
|
||||||
```bash
|
```bash
|
||||||
composer install
|
composer install
|
||||||
```
|
```
|
||||||
|
|
||||||
### 2. Configuration de l'environnement
|
### 3. Configuration de l'environnement
|
||||||
Copiez le fichier `.env` en `.env.local` et configurez vos accès à la base de données et à l'API :
|
Copiez le fichier `.env` en `.env.local` et configurez vos accès à la base de données et à l'API :
|
||||||
```bash
|
```bash
|
||||||
cp .env .env.local
|
cp .env .env.local
|
||||||
```
|
```
|
||||||
|
|
||||||
### 3. Base de données
|
### 4. Base de données
|
||||||
Créez la base de données et exécutez les migrations :
|
Créez la base de données et exécutez les migrations :
|
||||||
```bash
|
```bash
|
||||||
php bin/console doctrine:database:create
|
php bin/console doctrine:database:create
|
||||||
php bin/console doctrine:migrations:migrate
|
php bin/console doctrine:migrations:migrate
|
||||||
```
|
```
|
||||||
|
|
||||||
### 4. Installation des assets
|
### 5. Installation des assets
|
||||||
Le projet utilise AssetMapper. Installez les dépendances JS :
|
Le projet utilise AssetMapper. Installez les dépendances JS :
|
||||||
```bash
|
```bash
|
||||||
php bin/console importmap:install
|
php bin/console importmap:install
|
||||||
```
|
```
|
||||||
|
|
||||||
### 5. Lancement du serveur
|
### 6. Lancement du serveur
|
||||||
Utilisez le serveur Symfony pour lancer le projet localement :
|
Utilisez le serveur Symfony pour lancer le projet localement :
|
||||||
```bash
|
```bash
|
||||||
symfony serve -d
|
symfony serve -d
|
||||||
|
|||||||
@@ -1,81 +0,0 @@
|
|||||||
const nameCheck = /^[-_a-zA-Z0-9]{4,22}$/;
|
|
||||||
const tokenCheck = /^[-_/+a-zA-Z0-9]{24,}$/;
|
|
||||||
|
|
||||||
// Generate and double-submit a CSRF token in a form field and a cookie, as defined by Symfony's SameOriginCsrfTokenManager
|
|
||||||
// Use `form.requestSubmit()` to ensure that the submit event is triggered. Using `form.submit()` will not trigger the event
|
|
||||||
// and thus this event-listener will not be executed.
|
|
||||||
document.addEventListener('submit', function (event) {
|
|
||||||
generateCsrfToken(event.target);
|
|
||||||
}, true);
|
|
||||||
|
|
||||||
// When @hotwired/turbo handles form submissions, send the CSRF token in a header in addition to a cookie
|
|
||||||
// The `framework.csrf_protection.check_header` config option needs to be enabled for the header to be checked
|
|
||||||
document.addEventListener('turbo:submit-start', function (event) {
|
|
||||||
const h = generateCsrfHeaders(event.detail.formSubmission.formElement);
|
|
||||||
Object.keys(h).map(function (k) {
|
|
||||||
event.detail.formSubmission.fetchRequest.headers[k] = h[k];
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// When @hotwired/turbo handles form submissions, remove the CSRF cookie once a form has been submitted
|
|
||||||
document.addEventListener('turbo:submit-end', function (event) {
|
|
||||||
removeCsrfToken(event.detail.formSubmission.formElement);
|
|
||||||
});
|
|
||||||
|
|
||||||
export function generateCsrfToken (formElement) {
|
|
||||||
const csrfField = formElement.querySelector('input[data-controller="csrf-protection"], input[name="_csrf_token"]');
|
|
||||||
|
|
||||||
if (!csrfField) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let csrfCookie = csrfField.getAttribute('data-csrf-protection-cookie-value');
|
|
||||||
let csrfToken = csrfField.value;
|
|
||||||
|
|
||||||
if (!csrfCookie && nameCheck.test(csrfToken)) {
|
|
||||||
csrfField.setAttribute('data-csrf-protection-cookie-value', csrfCookie = csrfToken);
|
|
||||||
csrfField.defaultValue = csrfToken = btoa(String.fromCharCode.apply(null, (window.crypto || window.msCrypto).getRandomValues(new Uint8Array(18))));
|
|
||||||
}
|
|
||||||
csrfField.dispatchEvent(new Event('change', { bubbles: true }));
|
|
||||||
|
|
||||||
if (csrfCookie && tokenCheck.test(csrfToken)) {
|
|
||||||
const cookie = csrfCookie + '_' + csrfToken + '=' + csrfCookie + '; path=/; samesite=strict';
|
|
||||||
document.cookie = window.location.protocol === 'https:' ? '__Host-' + cookie + '; secure' : cookie;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function generateCsrfHeaders (formElement) {
|
|
||||||
const headers = {};
|
|
||||||
const csrfField = formElement.querySelector('input[data-controller="csrf-protection"], input[name="_csrf_token"]');
|
|
||||||
|
|
||||||
if (!csrfField) {
|
|
||||||
return headers;
|
|
||||||
}
|
|
||||||
|
|
||||||
const csrfCookie = csrfField.getAttribute('data-csrf-protection-cookie-value');
|
|
||||||
|
|
||||||
if (tokenCheck.test(csrfField.value) && nameCheck.test(csrfCookie)) {
|
|
||||||
headers[csrfCookie] = csrfField.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
return headers;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function removeCsrfToken (formElement) {
|
|
||||||
const csrfField = formElement.querySelector('input[data-controller="csrf-protection"], input[name="_csrf_token"]');
|
|
||||||
|
|
||||||
if (!csrfField) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const csrfCookie = csrfField.getAttribute('data-csrf-protection-cookie-value');
|
|
||||||
|
|
||||||
if (tokenCheck.test(csrfField.value) && nameCheck.test(csrfCookie)) {
|
|
||||||
const cookie = csrfCookie + '_' + csrfField.value + '=0; path=/; samesite=strict; max-age=0';
|
|
||||||
|
|
||||||
document.cookie = window.location.protocol === 'https:' ? '__Host-' + cookie + '; secure' : cookie;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* stimulusFetch: 'lazy' */
|
|
||||||
export default 'csrf-protection-controller';
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
import { Controller } from '@hotwired/stimulus';
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This is an example Stimulus controller!
|
|
||||||
*
|
|
||||||
* Any element with a data-controller="hello" attribute will cause
|
|
||||||
* this controller to be executed. The name "hello" comes from the filename:
|
|
||||||
* hello_controller.js -> "hello"
|
|
||||||
*
|
|
||||||
* Delete this file or adapt it for your use!
|
|
||||||
*/
|
|
||||||
export default class extends Controller {
|
|
||||||
connect() {
|
|
||||||
this.element.textContent = 'Hello Stimulus! Edit me in assets/controllers/hello_controller.js';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
|
|
||||||
services:
|
|
||||||
###> doctrine/doctrine-bundle ###
|
|
||||||
database:
|
|
||||||
ports:
|
|
||||||
- "5432"
|
|
||||||
###< doctrine/doctrine-bundle ###
|
|
||||||
|
|
||||||
###> symfony/mailer ###
|
|
||||||
mailer:
|
|
||||||
image: axllent/mailpit
|
|
||||||
ports:
|
|
||||||
- "1025"
|
|
||||||
- "8025"
|
|
||||||
environment:
|
|
||||||
MP_SMTP_AUTH_ACCEPT_ANY: 1
|
|
||||||
MP_SMTP_AUTH_ALLOW_INSECURE: 1
|
|
||||||
###< symfony/mailer ###
|
|
||||||
@@ -11,7 +11,7 @@ class HomeController extends AbstractController
|
|||||||
#[Route('/hello')]
|
#[Route('/hello')]
|
||||||
public function hello(): Response
|
public function hello(): Response
|
||||||
{
|
{
|
||||||
return $this->render('hello.html.twig', [
|
return $this->render('home/hello.html.twig', [
|
||||||
'name' => 'Melvin'
|
'name' => 'Melvin'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
error404.html.twig
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
{# templates/hellp.html.twig #}
|
|
||||||
<h1>Hello ! {{ name }}</h1>
|
|
||||||
0
templates/home/hello.html.twig
Normal file
0
templates/home/hello.html.twig
Normal file
Reference in New Issue
Block a user