Update Roles
parent
03b2f18e6e
commit
5569b8c8d9
241
Roles.md
241
Roles.md
|
@ -1,4 +1,4 @@
|
||||||
# Documentation / Documentación - API Platform with Symfony 3
|
# Documentation / Documentación - API ogCore
|
||||||
|
|
||||||
## Select Language / Seleccionar Idioma
|
## Select Language / Seleccionar Idioma
|
||||||
|
|
||||||
|
@ -12,78 +12,21 @@
|
||||||
### Table of Contents
|
### Table of Contents
|
||||||
|
|
||||||
1. [Introduction](#introduction)
|
1. [Introduction](#introduction)
|
||||||
2. [Installation](#installation)
|
2. [Configuration](#configuration)
|
||||||
3. [Configuration](#configuration)
|
3. [Resource Definition](#resource-definition)
|
||||||
4. [Resource Definition](#resource-definition)
|
4. [API Operations](#api-operations)
|
||||||
5. [API Operations](#api-operations)
|
5. [Entity Properties](#entity-properties)
|
||||||
6. [Entity Properties](#entity-properties)
|
6. [User Group Input DTO](#user-group-input-dto)
|
||||||
7. [User Group Input DTO](#user-group-input-dto)
|
|
||||||
|
|
||||||
### Introduction
|
### Introduction
|
||||||
|
|
||||||
This documentation describes the configuration of API Platform in a Symfony 3 project. It details the resources, operations, and entity properties exposed through the API.
|
This documentation describes the configuration of API Platform in a Symfony project. It details the resources, operations, and entity properties exposed through the API.
|
||||||
|
|
||||||
### Installation
|
|
||||||
|
|
||||||
1. **Prerequisites**:
|
|
||||||
- Symfony 3.x installed.
|
|
||||||
- Composer installed.
|
|
||||||
|
|
||||||
2. **Installing API Platform**:
|
|
||||||
```bash
|
|
||||||
composer require api-platform/core
|
|
||||||
```
|
|
||||||
|
|
||||||
### Configuration
|
### Configuration
|
||||||
|
|
||||||
API configuration is done in Symfony configuration files, usually in `config/packages/api_platform.yaml` or a similar file.
|
API configuration is done in Symfony configuration files, usually in `config/packages/api_platform.yaml` file.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
resources:
|
|
||||||
App\Entity\User:
|
|
||||||
input: App\Dto\Input\UserInput
|
|
||||||
output: App\Dto\Output\UserOutput
|
|
||||||
processor: App\State\Processor\UserProcessor
|
|
||||||
normalization_context:
|
|
||||||
groups: ['default', 'user:read']
|
|
||||||
denormalization_context:
|
|
||||||
groups: ['user:write']
|
|
||||||
operations:
|
|
||||||
ApiPlatform\Metadata\GetCollection:
|
|
||||||
provider: App\State\Provider\UserProvider
|
|
||||||
filters:
|
|
||||||
- 'api_platform.filter.user.order'
|
|
||||||
- 'api_platform.filter.user.search'
|
|
||||||
- 'api_platform.filter.user.boolean'
|
|
||||||
ApiPlatform\Metadata\Get:
|
|
||||||
provider: App\State\Provider\UserProvider
|
|
||||||
ApiPlatform\Metadata\Put:
|
|
||||||
provider: App\State\Provider\UserProvider
|
|
||||||
ApiPlatform\Metadata\Patch:
|
|
||||||
provider: App\State\Provider\UserProvider
|
|
||||||
ApiPlatform\Metadata\Post:
|
|
||||||
security: 'is_granted("ROLE_SUPER_ADMIN")'
|
|
||||||
validationContext:
|
|
||||||
groups: [ 'default', 'user:post' ]
|
|
||||||
ApiPlatform\Metadata\Delete:
|
|
||||||
security: 'is_granted("ROLE_SUPER_ADMIN")'
|
|
||||||
reset_password:
|
|
||||||
provider: App\State\Provider\UserProvider
|
|
||||||
class: ApiPlatform\Metadata\Put
|
|
||||||
method: PUT
|
|
||||||
input: App\Dto\Input\UserInput
|
|
||||||
uriTemplate: /users/{uuid}/reset-password
|
|
||||||
controller: App\Controller\ResetPasswordAction
|
|
||||||
validationContext:
|
|
||||||
groups: [ 'user:reset-password' ]
|
|
||||||
|
|
||||||
properties:
|
|
||||||
App\Entity\User:
|
|
||||||
id:
|
|
||||||
identifier: false
|
|
||||||
uuid:
|
|
||||||
identifier: true
|
|
||||||
|
|
||||||
resources:
|
resources:
|
||||||
App\Entity\UserGroup:
|
App\Entity\UserGroup:
|
||||||
security: 'is_granted("ROLE_SUPER_ADMIN")'
|
security: 'is_granted("ROLE_SUPER_ADMIN")'
|
||||||
|
@ -120,14 +63,6 @@ properties:
|
||||||
|
|
||||||
### Resource Definition
|
### Resource Definition
|
||||||
|
|
||||||
#### App\Entity\User
|
|
||||||
|
|
||||||
- **Input**: `App\Dto\Input\UserInput`
|
|
||||||
- **Output**: `App\Dto\Output\UserOutput`
|
|
||||||
- **Processor**: `App\State\Processor\UserProcessor`
|
|
||||||
- **Normalization Context**: `['default', 'user:read']`
|
|
||||||
- **Denormalization Context**: `['user:write']`
|
|
||||||
|
|
||||||
#### App\Entity\UserGroup
|
#### App\Entity\UserGroup
|
||||||
|
|
||||||
- **Security**: Only users with the role `ROLE_SUPER_ADMIN` can access.
|
- **Security**: Only users with the role `ROLE_SUPER_ADMIN` can access.
|
||||||
|
@ -139,40 +74,6 @@ properties:
|
||||||
|
|
||||||
### API Operations
|
### API Operations
|
||||||
|
|
||||||
#### User Operations
|
|
||||||
|
|
||||||
##### Get User Collection (GetCollection)
|
|
||||||
- **Provider**: `App\State\Provider\UserProvider`
|
|
||||||
- **Filters**:
|
|
||||||
- Order users: `api_platform.filter.user.order`
|
|
||||||
- Search users: `api_platform.filter.user.search`
|
|
||||||
- Boolean filter: `api_platform.filter.user.boolean`
|
|
||||||
|
|
||||||
##### Get User (Get)
|
|
||||||
- **Provider**: `App\State\Provider\UserProvider`
|
|
||||||
|
|
||||||
##### Update User (Put)
|
|
||||||
- **Provider**: `App\State\Provider\UserProvider`
|
|
||||||
|
|
||||||
##### Partially Update User (Patch)
|
|
||||||
- **Provider**: `App\State\Provider\UserProvider`
|
|
||||||
|
|
||||||
##### Create User (Post)
|
|
||||||
- **Security**: Only users with the role `ROLE_SUPER_ADMIN` can access.
|
|
||||||
- **Validation Context**: `['default', 'user:post']`
|
|
||||||
|
|
||||||
##### Delete User (Delete)
|
|
||||||
- **Security**: Only users with the role `ROLE_SUPER_ADMIN` can access.
|
|
||||||
|
|
||||||
##### Reset Password (reset_password)
|
|
||||||
- **Provider**: `App\State\Provider\UserProvider`
|
|
||||||
- **Class**: `ApiPlatform\Metadata\Put`
|
|
||||||
- **Method**: `PUT`
|
|
||||||
- **Input**: `App\Dto\Input\UserInput`
|
|
||||||
- **URI**: `/users/{uuid}/reset-password`
|
|
||||||
- **Controller**: `App\Controller\ResetPasswordAction`
|
|
||||||
- **Validation Context**: `['user:reset-password']`
|
|
||||||
|
|
||||||
#### User Group Operations
|
#### User Group Operations
|
||||||
|
|
||||||
##### Get User Group Collection (GetCollection)
|
##### Get User Group Collection (GetCollection)
|
||||||
|
@ -242,80 +143,21 @@ properties:
|
||||||
### Índice
|
### Índice
|
||||||
|
|
||||||
1. [Introducción](#introducción)
|
1. [Introducción](#introducción)
|
||||||
2. [Instalación](#instalación)
|
2. [Configuración](#configuración)
|
||||||
3. [Configuración](#configuración)
|
3. [Definición de Recursos](#definición-de-recursos)
|
||||||
4. [Definición de Recursos](#definición-de-recursos)
|
4. [Operaciones de API](#operaciones-de-api)
|
||||||
5. [Operaciones de API](#operaciones-de-api)
|
5. [Propiedades de la Entidad](#propiedades-de-la-entidad)
|
||||||
6. [Propiedades de la Entidad](#propiedades-de-la-entidad)
|
6. [DTO de Entrada de Grupo de Usuarios](#dto-de-entrada-de-grupo-de-usuarios)
|
||||||
7. [DTO de Entrada de Grupo de Usuarios](#dto-de-entrada-de-grupo-de-usuarios)
|
|
||||||
|
|
||||||
### Introducción
|
### Introducción
|
||||||
|
|
||||||
Esta documentación describe la configuración de API Platform en un proyecto Symfony 3. Se detallan los recursos, operaciones y propiedades de las entidades expuestas a través de la API.
|
Esta documentación describe la configuración de API Platform en un proyecto Symfony. Se detallan los recursos, operaciones y propiedades de las entidades expuestas a través de la API.
|
||||||
|
|
||||||
### Instalación
|
|
||||||
|
|
||||||
1. **Requisitos previos**:
|
|
||||||
- Symfony 3.x instalado.
|
|
||||||
- Composer instalado.
|
|
||||||
|
|
||||||
2. **Instalación de API Platform**:
|
|
||||||
```bash
|
|
||||||
composer require api-platform/core
|
|
||||||
```
|
|
||||||
|
|
||||||
### Configuración
|
### Configuración
|
||||||
|
|
||||||
La configuración de la API se realiza en los archivos de configuración de Symfony, generalmente en `config/packages/api_platform.yaml` o un archivo similar.
|
La configuración de la API se realiza en los archivos de configuración de Symfony, generalmente en `config/packages/api_platform.yaml`.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
resources:
|
|
||||||
App\Entity\User:
|
|
||||||
input: App\Dto\Input\UserInput
|
|
||||||
output: App\Dto\Output\UserOutput
|
|
||||||
processor: App\State\Processor\UserProcessor
|
|
||||||
normalization_context:
|
|
||||||
groups: ['default', 'user:read']
|
|
||||||
denormalization_context:
|
|
||||||
groups: ['user:write']
|
|
||||||
operations:
|
|
||||||
ApiPlatform\Metadata\GetCollection:
|
|
||||||
provider: App\State\Provider\UserProvider
|
|
||||||
filters:
|
|
||||||
- 'api_platform.filter.user.order'
|
|
||||||
- 'api_platform.filter.user.search'
|
|
||||||
- 'api_platform.filter.user.boolean'
|
|
||||||
ApiPlatform\Metadata\Get:
|
|
||||||
provider: App\State\Provider\UserProvider
|
|
||||||
ApiPlatform\Metadata
|
|
||||||
|
|
||||||
\Put:
|
|
||||||
provider: App\State\Provider\UserProvider
|
|
||||||
ApiPlatform\Metadata\Patch:
|
|
||||||
provider: App\State\Provider\UserProvider
|
|
||||||
ApiPlatform\Metadata\Post:
|
|
||||||
security: 'is_granted("ROLE_SUPER_ADMIN")'
|
|
||||||
validationContext:
|
|
||||||
groups: [ 'default', 'user:post' ]
|
|
||||||
ApiPlatform\Metadata\Delete:
|
|
||||||
security: 'is_granted("ROLE_SUPER_ADMIN")'
|
|
||||||
reset_password:
|
|
||||||
provider: App\State\Provider\UserProvider
|
|
||||||
class: ApiPlatform\Metadata\Put
|
|
||||||
method: PUT
|
|
||||||
input: App\Dto\Input\UserInput
|
|
||||||
uriTemplate: /users/{uuid}/reset-password
|
|
||||||
controller: App\Controller\ResetPasswordAction
|
|
||||||
validationContext:
|
|
||||||
groups: [ 'user:reset-password' ]
|
|
||||||
|
|
||||||
properties:
|
|
||||||
App\Entity\User:
|
|
||||||
id:
|
|
||||||
identifier: false
|
|
||||||
uuid:
|
|
||||||
identifier: true
|
|
||||||
|
|
||||||
resources:
|
resources:
|
||||||
App\Entity\UserGroup:
|
App\Entity\UserGroup:
|
||||||
security: 'is_granted("ROLE_SUPER_ADMIN")'
|
security: 'is_granted("ROLE_SUPER_ADMIN")'
|
||||||
|
@ -352,59 +194,6 @@ properties:
|
||||||
|
|
||||||
### Definición de Recursos
|
### Definición de Recursos
|
||||||
|
|
||||||
#### App\Entity\User
|
|
||||||
|
|
||||||
- **Input**: `App\Dto\Input\UserInput`
|
|
||||||
- **Output**: `App\Dto\Output\UserOutput`
|
|
||||||
- **Processor**: `App\State\Processor\UserProcessor`
|
|
||||||
- **Normalization Context**: `['default', 'user:read']`
|
|
||||||
- **Denormalization Context**: `['user:write']`
|
|
||||||
|
|
||||||
#### App\Entity\UserGroup
|
|
||||||
|
|
||||||
- **Security**: Solo los usuarios con el rol `ROLE_SUPER_ADMIN` pueden acceder.
|
|
||||||
- **Processor**: `App\State\Processor\UserGroupProcessor`
|
|
||||||
- **Input**: `App\Dto\Input\UserGroupInput`
|
|
||||||
- **Output**: `App\Dto\Output\UserGroupOutput`
|
|
||||||
- **Normalization Context**: `['default', 'user-group:read']`
|
|
||||||
- **Denormalization Context**: `['user-group:write']`
|
|
||||||
|
|
||||||
### Operaciones de API
|
|
||||||
|
|
||||||
#### Operaciones de Usuario
|
|
||||||
|
|
||||||
##### Obtener Colección de Usuarios (GetCollection)
|
|
||||||
- **Provider**: `App\State\Provider\UserProvider`
|
|
||||||
- **Filtros**:
|
|
||||||
- Ordenar usuarios: `api_platform.filter.user.order`
|
|
||||||
- Buscar usuarios: `api_platform.filter.user.search`
|
|
||||||
- Filtro booleano: `api_platform.filter.user.boolean`
|
|
||||||
|
|
||||||
##### Obtener Usuario (Get)
|
|
||||||
- **Provider**: `App\State\Provider\UserProvider`
|
|
||||||
|
|
||||||
##### Actualizar Usuario (Put)
|
|
||||||
- **Provider**: `App\State\Provider\UserProvider`
|
|
||||||
|
|
||||||
##### Actualización Parcial de Usuario (Patch)
|
|
||||||
- **Provider**: `App\State\Provider\UserProvider`
|
|
||||||
|
|
||||||
##### Crear Usuario (Post)
|
|
||||||
- **Security**: Solo los usuarios con el rol `ROLE_SUPER_ADMIN` pueden acceder.
|
|
||||||
- **Validation Context**: `['default', 'user:post']`
|
|
||||||
|
|
||||||
##### Eliminar Usuario (Delete)
|
|
||||||
- **Security**: Solo los usuarios con el rol `ROLE_SUPER_ADMIN` pueden acceder.
|
|
||||||
|
|
||||||
##### Restablecer Contraseña (reset_password)
|
|
||||||
- **Provider**: `App\State\Provider\UserProvider`
|
|
||||||
- **Class**: `ApiPlatform\Metadata\Put`
|
|
||||||
- **Method**: `PUT`
|
|
||||||
- **Input**: `App\Dto\Input\UserInput`
|
|
||||||
- **URI**: `/users/{uuid}/reset-password`
|
|
||||||
- **Controller**: `App\Controller\ResetPasswordAction`
|
|
||||||
- **Validation Context**: `['user:reset-password']`
|
|
||||||
|
|
||||||
#### Operaciones de Grupo de Usuarios
|
#### Operaciones de Grupo de Usuarios
|
||||||
|
|
||||||
##### Obtener Colección de Grupos de Usuarios (GetCollection)
|
##### Obtener Colección de Grupos de Usuarios (GetCollection)
|
||||||
|
|
Loading…
Reference in New Issue