Specification - create a public web service server

Jump to: navigation, search

Goal

We want a fast REST server that anybody can request.

similar to the Hub implementation

We extend the Moodle REST server and overwrite the protected function authenticate_user().

local/plugins/db/services.php

install the web service functions + the pre-build service

local/plugins/db/install.php

  1. create a user (password + username could be set into the plugin admin by the admin)
  2. create a role with required capabilities by the web service function
  3. also set the webservice/user:rest for this role
  4. assign the role to the user on system context
  5. create a token for the service/user

PS: if install script is run before services.php script then you'll have to run it in the server when a public token is not found.

local/plugins/server.php:authenticate_user()

Extend the Moodle rest server.

  1. ignore any token parameter
  2. load the public token
  3. call the normal parent::authenticate_user();