drupal 8 as a mobile backend

18
Drupal 8 as a mobile backend RESTful web services Credits: Lin Clark, Klaus Purer Gabriel Dragomir

Upload: alkuvoima

Post on 08-May-2015

397 views

Category:

Technology


4 download

TRANSCRIPT

Page 1: Drupal 8 as a mobile backend

Drupal 8 as a mobile backend

RESTful web services

Credits: Lin Clark, Klaus Purer

Gabriel Dragomir

Page 2: Drupal 8 as a mobile backend

Overview

1. RESTful Drupal: the building blocks

2. Setting up a Drupal REST web server

3. Verbalizing REST

4. Resource plugins

Page 3: Drupal 8 as a mobile backend

1. RESTful Drupal

• Drupal 8 REST out of the box:

• RESTful web services module

• Serialization

• HAL module: Hypertext Application Language

• HTTP basic authentication

Page 4: Drupal 8 as a mobile backend

1. RESTful Drupal

Page 5: Drupal 8 as a mobile backend

1. RESTful Drupal

Page 6: Drupal 8 as a mobile backend

1. RESTful Drupal

Page 7: Drupal 8 as a mobile backend

2. Setting up a Drupal REST WS

• Enable modules

• Configuration: generatedsites/default/files/config_XXXX/active/rest.settings.yml

• Set permissions

• Helper module: REST UIhttps://drupal.org/project/restui

Page 8: Drupal 8 as a mobile backend

3. Verbalizing REST

• Resources and operations

• Authentication and access control

• Example requests

Page 9: Drupal 8 as a mobile backend

3.1 Resources and operations

• Resource: the data structure that the service is acting on (e.g. an entity)

• Operation: the specific action (HTTP method)

Page 10: Drupal 8 as a mobile backend

3.1 Resources and operations

Page 11: Drupal 8 as a mobile backend

3.1 Plug and use

• Entity API with field metadata

• All properties and fields of an entity are described

• Any available entity can have REST API support enabled

• Each entity plugin has its own plugin

• Access control enforced:

• on the entity level

• on the field level

Page 12: Drupal 8 as a mobile backend

3.2 Authentication and access control

• Handler by HTTP Basic Auth module

• AuthenticationProviderInterface in Drupal core

• Pluggable authentication providers:

• Standard Drupal session cookie (Drupal core)

• Basic HTTP Authentication (Drupal core)

• OAuth (Contrib)

• Provides user permissions to authorize web service operations

• Each resource plugin provides own supplementary access control (example: entity and field access in the entity plugin)

Page 13: Drupal 8 as a mobile backend

3.3 Example requests

• GET entity/node/1

• CSRF tokens: GET rest/session/token

• POST entity/node

• PATCH entity/node

Page 14: Drupal 8 as a mobile backend

4. Resource plugins

• Based on Drupal 8 plugin API

• Default plugin exposes all entities

• Contributed modules can override/extend/provide plugins

• Example: dblog plugin

Page 15: Drupal 8 as a mobile backend

4. Resource plugins

Page 16: Drupal 8 as a mobile backend

Questions?

Page 17: Drupal 8 as a mobile backend

Contact me

[email protected]

• twitter: gabidrg

Page 18: Drupal 8 as a mobile backend

Thank you!