Diferencia entre revisiones de «Usando servicios web»

De MoodleDocs
m (tidy up)
(traducción de los primeros párrafos.)
 
(No se muestran 3 ediciones intermedias de otro usuario)
Línea 1: Línea 1:
{{Pendiente de traducir}}
{{Pendiente de traducir}}
{{Servicios web}}
{{Servicios web}}
This document explains how an administrator can set up a web service for users to access a service. Each user will have a specific and unique security key (also known as a "token") to access the service.
Este documento explica como un administrador puede configurar un Servicio web (''Web Service'') para que los usuarios puedan acceder a un servicio. Cada usuario tendrá una clave de seguridad (también conocida como ''Token)'' única y específica para acceder a un servicio.
== Habilitar servicios web==
[[Image:Enable_web_service.jpg|thumb|Habilitando los servicios web]]
# Administración del sitio ''> Opciones avanzadas''
# Marque la casilla de verificación 'Habilitar servicios' y luego haga clic en el botón 'Guardar cambios'.


== Enabling web services==
[[Image:Enable_web_service.jpg|thumb|Enabling web services]]
# Access ''Settings > Site administration > Advanced features''
# Check 'Enable web services' then click 'Save Changes'


Note: For security reasons, web services should only be enabled if you intend to make use of it.
'''Note''': por razones de seguridad los Servicio Web solo deben estar habilitados si se los protende utilizar, de o contrario recomendamos mantenerlos deshabilitados.
 
== Habilitar protocolos ==
== Enabling protocols ==
[[Image:Enable_protocol.jpg|thumb|left|Enabling protocols]]
[[Image:Enable_protocol.jpg|thumb|left|Enabling protocols]]
Usually external applications that users wish to use dictate which protocols should be enabled.  
Usualmente las aplicación externas que los usuarios desean utilizar definen cuales protolocos se deben habilitar.  
 
#''Administración dle sitio > Extensiones > Servicios Web > Administrar protocolos''
# Access ''Settings > Site administration > Plugins > Web services > Manage protocols''
# Activar los protocolos que se requieran (SOAP, REST, XMLRPC, AMF, ...).
# Enable the protocols (SOAP, REST, XMLRPC, AMF, ...) as required
== Auto-generación de documentación ==
 
== Enabling web service function documentation ==
[[Image:Security keys and documentation.jpg|thumb|Security keys page with documentation link]]
[[Image:Security keys and documentation.jpg|thumb|Security keys page with documentation link]]
Enabling web service function documentation (also on the Manage protocols page) results in user-specific web service documentation being available for each user on their [[Security keys]] page. This option is mainly useful to web service client developers. If nobody is creating a web service client, there is no need to enable this feature.
Enabling web service function documentation (also on the Manage protocols page) results in user-specific web service documentation being available for each user on their [[Claves de seguridad]] page. This option is mainly useful to web service client developers. If nobody is creating a web service client, there is no need to enable this feature.
 
== Crear un servicio ==
== Creating a service ==
If none of the pre-build web services match your needs, you can create a custom service i.e. select which of the standard web service functions are available via that service.
If none of the pre-build web services match your needs, you can create a custom service i.e. select which of the standard web service functions are available via that service.


Línea 32: Línea 28:
# Enter a name and check Enabled
# Enter a name and check Enabled
# Click the button 'Add service'
# Click the button 'Add service'
==Adding functions to the service==
==Adding functions to the service==
[[Image:Select a web service function.jpg|thumb|Adding functions to the service]]Your service is currently empty and doesn't do anything. Web service functions need to be added. Your choice will be dictated by what you allow the external application to do. For this example, select 'Create group'.
[[Image:Select a web service function.jpg|thumb|Adding functions to the service]]Your service is currently empty and doesn't do anything. Web service functions need to be added. Your choice will be dictated by what you allow the external application to do. For this example, select 'Create group'.
# Click 'Add functions' link
# Click 'Add functions' link
# Select 'create group' function and click the 'Add functions' button
# Select 'create group' function and click the 'Add functions' button
You should be back to the service functions list. 'Required capabilities' are indicated for each function. Users need the required capabilities to run a function. The function descriptions in the API Documentation can also give you more information about the required capabilities (''Settings > Site administration > Plugins > Web services > API Documentation'').
You should be back to the service functions list. 'Required capabilities' are indicated for each function. Users need the required capabilities to run a function. The function descriptions in the API Documentation can also give you more information about the required capabilities (''Settings > Site administration > Plugins > Web services > API Documentation'').
 
==Habilitar capacidades==
==Enabling capabilities==
 
The final step is to grant appropriate permissions. The following capabilities should be allowed:
The final step is to grant appropriate permissions. The following capabilities should be allowed:
* [[Capabilities/moodle/webservice:createtoken|moodle/webservice:createtoken]] - for allowing users to generate a security key
* [[Capabilities/moodle/webservice:createtoken|moodle/webservice:createtoken]] - for allowing users to generate a security key
* [[Capabilities/webservice/rest:use | webservice/rest:use]], [[Capabilities/webservice/soap:use | webservice/soap:use]], [[Capabilities/webservice/xmlrpc:use | webservice/xmlrpc:use]], [[Capabilities/webservice/amf:use | webservice/amf:use]] which match the enabled protocols.
* [[Capabilities/webservice/rest:use | webservice/rest:use]], [[Capabilities/webservice/soap:use | webservice/soap:use]], [[Capabilities/webservice/xmlrpc:use | webservice/xmlrpc:use]], [[Capabilities/webservice/amf:use | webservice/amf:use]] which match the enabled protocols.
* The service ''Required capability'' if set (''Settings > Site administration > Plugins > Web services > Manage services >'''Edit''' link'').
* The service ''Required capability'' if set (''Settings > Site administration > Plugins > Web services > Manage services >'''Edit''' link'').
* The required capabilities for the web service functions. These required capabilities are listed when you add a function to the service. For more information about roles and capabilities, read the [[Gestionar roles]] documentation.
* The required capabilities for the web service functions. These required capabilities are listed when you add a function to the service. For more information about roles and capabilities, read the [[Gestionar roles]] documentation.
Once done, the web service should be set up. Users should be able to [[Claves de seguridad|obtener una clave de seguridad personal]].
Once done, the web service should be set up. Users should be able to [[Claves de seguridad|obtener una clave de seguridad personal]].
 
= Configuraciones alternativas =
= Alternative settings =  
 
== Authorise only specific users==
== Authorise only specific users==
[[Image:Authorised users link.jpg|thumb]] [[Image:Authorised user selection page.jpg|thumb]]
[[Image:Authorised users link.jpg|thumb]] [[Image:Authorised user selection page.jpg|thumb]]
Línea 59: Línea 46:
# Select '''Authorised users''' link (the service must have been set as '''Authorised users only''' in the '''Edit''' link)
# Select '''Authorised users''' link (the service must have been set as '''Authorised users only''' in the '''Edit''' link)
# Select some users and click '''Add'''
# Select some users and click '''Add'''
Moodle indicates if some capabilities need to be assigned to an authorised user. Moreover if you click on the authorised user fullname, you can set up some specific options: ''IP restriction'' and ''Valid until''.
Moodle indicates if some capabilities need to be assigned to an authorised user. Moreover if you click on the authorised user fullname, you can set up some specific options: ''IP restriction'' and ''Valid until''.
 
== Crar un [https://en.wikipedia.org/wiki/Token token==
== Create a token ==
[[Image:Create_token.jpg|thumb]]
[[Image:Create_token.jpg|thumb]]
This feature allows you to create a token for specific user. It can be useful if a user doesn't have the moodle/create:token capability. This is also the only way to create a token for an administrator. For security reason, tokens are not automatically generated in the administrator security keys page.
Esta característica le permite crear un [https://en.wikipedia.org/wiki/Token token] para un usuario específico. It can be useful if a user doesn't have the moodle/create:token capability. This is also the only way to create a [https://en.wikipedia.org/wiki/Token token] for an administrator. For security reason, tokens are not automatically generated in the administrator security keys page.
 
# ''Settings > Site Administration > Plugins > Web services > Manage tokens''
# ''Settings > Site Administration > Plugins > Web services > Manage tokens''
# Click on '''Add'''
# Click on '''Add'''
# Select the created user and service
# Select the created user and service
# Click on '''Saves changes'''
# Click on '''Saves changes'''
As you created a token for this user, you do not need to assign "''moodle/webservice:createtoken''" to him/her.
As you created a token for this user, you do not need to assign "''moodle/webservice:createtoken''" to him/her.
Finally, note that, as for authorised users, you can also set ''IP restriction'' and ''Valid until'' on a token.
Finally, note that, as for authorised users, you can also set ''IP restriction'' and ''Valid until'' on a token.
 
== Vea también ==
== See also ==
*[http://www.joomdle.com/wiki/Preparing_Moodle_20#Setting_up_Moodle_Web_services Joomdle documentation about setting Moodle web services]
*[http://www.joomdle.com/wiki/Preparing_Moodle_20#Setting_up_Moodle_Web_services Joomdle documentation about setting Moodle web services]
[[en:Using web services]]
[[en:Using web services]]

Revisión actual - 15:00 9 sep 2021

Nota: Pendiente de Traducir. ¡Anímese a traducir esta página!.     ( y otras páginas pendientes)

Este documento explica como un administrador puede configurar un Servicio web (Web Service) para que los usuarios puedan acceder a un servicio. Cada usuario tendrá una clave de seguridad (también conocida como Token) única y específica para acceder a un servicio.

Habilitar servicios web

Habilitando los servicios web
  1. Administración del sitio > Opciones avanzadas
  2. Marque la casilla de verificación 'Habilitar servicios' y luego haga clic en el botón 'Guardar cambios'.


Note: por razones de seguridad los Servicio Web solo deben estar habilitados si se los protende utilizar, de o contrario recomendamos mantenerlos deshabilitados.

Habilitar protocolos

Enabling protocols

Usualmente las aplicación externas que los usuarios desean utilizar definen cuales protolocos se deben habilitar.

  1. Administración dle sitio > Extensiones > Servicios Web > Administrar protocolos
  2. Activar los protocolos que se requieran (SOAP, REST, XMLRPC, AMF, ...).

Auto-generación de documentación

Security keys page with documentation link

Enabling web service function documentation (also on the Manage protocols page) results in user-specific web service documentation being available for each user on their Claves de seguridad page. This option is mainly useful to web service client developers. If nobody is creating a web service client, there is no need to enable this feature.

Crear un servicio

If none of the pre-build web services match your needs, you can create a custom service i.e. select which of the standard web service functions are available via that service.

You can enable only the specific functions that you need to expose, so not compromising on security.

Creating a service
  1. Access Settings > Site administration > Plugins > Web services > External services
  2. Click Add new custom service
    • 'Authorised users only' - If enabled, you will need to select the authorised users manually. Otherwise all users with appropriate permissions are allowed
    • 'Required capability' - If enabled, any user accessing the web service will be checked against this selected capability. (This is just an additional optional security layer.)
  3. Enter a name and check Enabled
  4. Click the button 'Add service'

Adding functions to the service

Adding functions to the service

Your service is currently empty and doesn't do anything. Web service functions need to be added. Your choice will be dictated by what you allow the external application to do. For this example, select 'Create group'.

  1. Click 'Add functions' link
  2. Select 'create group' function and click the 'Add functions' button

You should be back to the service functions list. 'Required capabilities' are indicated for each function. Users need the required capabilities to run a function. The function descriptions in the API Documentation can also give you more information about the required capabilities (Settings > Site administration > Plugins > Web services > API Documentation).

Habilitar capacidades

The final step is to grant appropriate permissions. The following capabilities should be allowed:

Once done, the web service should be set up. Users should be able to obtener una clave de seguridad personal.

Configuraciones alternativas

Authorise only specific users

Authorised users link.jpg
Authorised user selection page.jpg
  1. Settings > Site Administration > Plugins > Web services > External Services
  2. Select Authorised users link (the service must have been set as Authorised users only in the Edit link)
  3. Select some users and click Add

Moodle indicates if some capabilities need to be assigned to an authorised user. Moreover if you click on the authorised user fullname, you can set up some specific options: IP restriction and Valid until.

Crar un token

Create token.jpg

Esta característica le permite crear un token para un usuario específico. It can be useful if a user doesn't have the moodle/create:token capability. This is also the only way to create a token for an administrator. For security reason, tokens are not automatically generated in the administrator security keys page.

  1. Settings > Site Administration > Plugins > Web services > Manage tokens
  2. Click on Add
  3. Select the created user and service
  4. Click on Saves changes

As you created a token for this user, you do not need to assign "moodle/webservice:createtoken" to him/her. Finally, note that, as for authorised users, you can also set IP restriction and Valid until on a token.

Vea también