spomky-labs/oauth2-server-exception-manager-bundle

This package is abandoned and no longer maintained. The author suggests using the spomky-labs/oauth2-server-bundle package instead.

Symfony2 OAuth2 Server Exception Manager Bundle

v5.0.1 2015-06-15 20:34 UTC

This package is not auto-updated.

Last update: 2015-08-17 10:39:37 UTC


README

Scrutinizer Code Quality Build Status HHVM Status PHP 7 ready

SensioLabsInsight

Latest Stable Version Total Downloads Latest Unstable Version License

This bundle adds an exception manager to your OAuth2 Server.

It relies on the OAuth2 Interfaces Project.

The Release Process

The release process is described here.

Prerequisites

This library needs at least PHP 5.4 and Symfony v2.3.

It has been successfully tested using:

  • PHP: PHP 5.4 to PHP 5.6, PHP 7 and HHVM.
  • Symfony: v2.3.x to v2.7.x.

Installation

The preferred way to install this library is to rely on Composer:

composer require "spomky-labs/oauth2-server-exception-manager-bundle" "~5.0.0"

Enable the bundle

Enable the bundle in the kernel:

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
    ...
    new SpomkyLabs\OAuth2ServerExceptionManagerBundle\SpomkyLabsOAuth2ServerExceptionManagerBundle(),
    );
}

Configuration

This bundle does not need to be configured, all options have a default value.

Full configuration:

sl_oauth2_exception_manager:
    realm: 'OAuth2 Server'
    manager: sl_oauth2_exception_manager.exception_manager.default

How to use

This bundle adds a new service sl_oauth2_exception_manager.manager.

You do not have anything to do. Let your component do the magic!

If you really want to throw your own exceptions (for example in a custom grant type):

$exception = $this->container->get("sl_oauth2_exception_manager.manager")->getException(ExceptionManagerInterface::BAD_REQUEST, ExceptionManagerInterface::INVALID_GRANT, "Parameter 'foo' is missing", array("bar"=>"baz"));
throw $exception;

The first argument of the method getException indicate the type of exception.

Supported types are:

  • ExceptionManagerInterface::AUTHENTICATE
  • ExceptionManagerInterface::BAD_REQUEST
  • ExceptionManagerInterface::NOT_IMPLEMENTED
  • ExceptionManagerInterface::REDIRECT
  • ExceptionManagerInterface::INTERNAL_SERVER_ERROR

Supported messages are:

  • ExceptionManagerInterface::INVALID_REQUEST
  • ExceptionManagerInterface::INVALID_CLIENT
  • ExceptionManagerInterface::INVALID_GRANT
  • ExceptionManagerInterface::INVALID_SCOPE
  • ExceptionManagerInterface::UNAUTHORIZED_CLIENT
  • ExceptionManagerInterface::UNSUPPORTED_GRANT_TYPE
  • ExceptionManagerInterface::ACCESS_DENIED
  • ExceptionManagerInterface::UNSUPPORTED_RESPONSE_TYPE
  • ExceptionManagerInterface::SERVER_ERROR
  • ExceptionManagerInterface::TEMPORARILY_UNAVAILABLE

You also can define your own messages.

Contributing

Requests for new features, bug fixed and all other ideas to make this library awesome are welcome. Please follow these best practices.

Licence

This library is release under MIT licence.