2017 © Pedro Peláez
 

silverstripe-vendormodule silverstripe-apikey

API Key management for SilverStripe

image

sminnee/silverstripe-apikey

API Key management for SilverStripe

  • Wednesday, July 25, 2018
  • by sminnee
  • Repository
  • 2 Watchers
  • 3 Stars
  • 65 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 4 Forks
  • 0 Open issues
  • 4 Versions
  • 30 % Grown

The README.md

SilverStripe API Key

Build Status codecov, (*1)

This module provides a way of creating an managing API keys within SilverStripe. This can be useful for building RESTful and other APIs., (*2)

Requirements

  • SilverStripe ^4.0
  • PHP 5.5+

Installation

composer require sminnee/silverstripe-apikey

How it works

  • Extensions the the SecurityAdmin provide interfaces for seeing API keys, and generating new ones. API keys are allocated member-by-member.
  • A RequestMiddleware will look for an API key header (default: X-API-Key) and if it is present, authenticate the user so that Member::currentUser() will return the corresponding member. This should be configured by non-GraphQL requests.
  • A ApiKeyAuthenticator should be configured for GraphQL request and will return the authenticated member for GraphQL contexts to use, while not applying it to the CMS session.

Regular use

For regular module usage, use the RequestMiddleware class. The configuration to apply it is in this module's apikey.yml, but is commented out., (*3)

Copy the configuration and add it to your mysite/_config/apikey.yml file., (*4)

This will protect all of your frontend routes., (*5)

GraphQL

The GraphQL authenticator will work separately from the RequestMiddleware. If using this module for GraphQL, you will probably want to disable the RequestMiddleware. If you run both at the same time you will find that:, (*6)

  • Authentication exceptions are thrown outside of the GraphQL context (i.e. not wrapped in JSON output)
  • Successful requests will register two "times used" each, since it's authenticated in two places

Limitations

  • You can't limit the rights that the API key has to be more granular than "all rights of the given user".
  • Keys can't be disabled, only deleted
  • No support for storing encrypted ("read-once") keys

Status

This should be considered experimental for now, and used with care. It has not received a security audit., (*7)

The Versions

25/07 2018

dev-master

9999999-dev

API Key management for SilverStripe

  Sources   Download

BSD-3-Clause

The Requires

 

04/12 2015

0.1.x-dev

0.1.9999999.9999999-dev

API Key management for SilverStripe

  Sources   Download

BSD-3-Clause

The Requires

 

04/12 2015

0.0.2

0.0.2.0

API Key management for SilverStripe

  Sources   Download

BSD-3-Clause

The Requires

 

03/12 2015

0.0.1

0.0.1.0

API Key management for SilverStripe

  Sources   Download

BSD-3-Clause

The Requires