Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Kong as a gateway for your Drupal API

Abi
July 14, 2018

Kong as a gateway for your Drupal API

Abi

July 14, 2018
Tweet

Other Decks in Programming

Transcript

  1. Sponsors Organisers Consumer Integration 1 Extends Account Interface 2 Reverse

    Proxy Settings 3 Register Authentication Provider 4 Mapping Kong Group to Drupal Roles 5 Decoupling Drupal Authentication
  2. Sponsors Organisers Consumers Integration The Consumer object represents a consumer

    - or a user - of a Service. You can either rely on Kong as the Primary Datastore, or you can Map the Consumer List with your database to keep consistency between Kong and your existing primary datastore. https://www.drupal.org/project/consumers
  3. Sponsors Organisers Consumer Account - \Drupal::currentUser - AccountInterface - -

    - X-Consumer-ID - X-Consumer-Custom-ID - X-Consumer-Username - X-Anonymous-Consumer
  4. Sponsors Organisers Reverse Proxy Settings /** * Reverse Proxy Configuration:

    */ $settings['reverse_proxy'] = TRUE; /** * Specify every reverse proxy IP address in your environment. */ $settings['reverse_proxy_addresses'] = [ '127.0.0.1', ];
  5. Sponsors Organisers Kong Authentication Provider public function applies(Request $request) {

    return $request->isFromTrustedProxy() && $request->headers->has('X-Consumer-ID'); }
  6. Sponsors Organisers Kong Authentication Provider public function authenticate(Request $request) {

    if ($request->headers->has('X-Consumer-Custom-ID')) { $this->consumerAccount->setRequest($request); return $this->consumerAccount; } return NULL; }
  7. Sponsors Organisers Permission and ACL Restrict access to a Service

    or a Route by whitelisting or blacklisting consumers using arbitrary ACL group names.
  8. Sponsors Organisers Kong Group as Drupal Role public function getRoles($exclude_locked_roles

    = FALSE) { $roles = []; if ($this->request->headers->has('X-Consumer-Groups')) { $roles += preg_split("/,\s?/", $this->request->headers ->get('X-Consumer-Groups')); } if (!$exclude_locked_roles) { $roles[] = RoleInterface::AUTHENTICATED_ID; } return $roles; }
  9. Sponsors Organisers Kong as a gateway for Drupal API -

    Provide underlying APIs with additional functionalities - Replace Drupal authentication - Provide various authentication method - Reduce Drupal load