Download the PHP package ekreative/oauth2-symfony-bundle without Composer

On this page you can find all versions of the php package ekreative/oauth2-symfony-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package oauth2-symfony-bundle

OAuth2Bundle

Build Status Latest Stable Version License

The primary goal of OAuth2Bundle is to develop a standards compliant RFC6749 OAuth2.0 library

This library bundle with a Symfony based Bundle for unit test and demo purpose. Installation and usage can refer as below.

Installation

Simply add a dependency on ekreative/oauth2-symfony-bundle to your project's composer.json file if you use Composer to manage the dependencies of your project.

Here is a minimal example of a composer.json:

{
    "require": {
        "ekreative/oauth2-symfony-bundle": "^6.0"
    }
}

Parameters

This bundle come with following parameters:

Services

This bundle come with following services controller which simplify the OAuth2.0 controller implementation overhead:

Registering

You have to add AuthBucketOAuth2Bundle to your AppKernel.php:

# app/AppKernel.php

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = [
            new AuthBucket\Bundle\OAuth2Bundle\AuthBucketOAuth2Bundle(),
        ];

        return $bundles;
    }
}

Moreover, enable following bundles if that's not already the case:

$bundles = [
    new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
    new Symfony\Bundle\SecurityBundle\SecurityBundle(),
    new Symfony\Bundle\MonologBundle\MonologBundle(),
];

Usage

This library seperate the endpoint logic in frontend firewall and backend controller point of view, so you will need to setup both for functioning.

To enable the built-in controller with corresponding routing, add the following into your routing.yml, all above controllers will be enabled accordingly with routing prefix /api/oauth2:

# app/config/routing.yml

authbucketoauth2bundle:
    prefix:     /api/oauth2
    resource:   "@AuthBucketOAuth2Bundle/Resources/config/routing.yml"

Below is a list of recipes that cover some common use cases.

Authorization Endpoint

We don't provide custom firewall for this endpoint, which you should protect it by yourself, authenticate and capture the user credential, e.g. by SecurityBundle:

# app/config/security.yml

security:
    encoders:
        Symfony\Component\Security\Core\User\User: plaintext

    providers:
        default:
            memory:
                users:
                    demousername1:  { roles: 'ROLE_USER', password: demopassword1 }
                    demousername2:  { roles: 'ROLE_USER', password: demopassword2 }
                    demousername3:  { roles: 'ROLE_USER', password: demopassword3 }

    firewalls:
        api_oauth2_authorize:
            pattern:                ^/api/oauth2/authorize$
            http_basic:             ~
            provider:               default

Token Endpoint

Similar as authorization endpoint, we need to protect this endpoint with our custom firewall oauth2_token:

# app/config/security.yml

security:
    firewalls:
        api_oauth2_token:
            pattern:                ^/api/oauth2/token$
            oauth2_token:           ~

Debug Endpoint

We should protect this endpoint with our custom firewall oauth2_resource:

# app/config/security.yml

security:
    firewalls:
        api_oauth2_debug:
            pattern:                ^/api/oauth2/debug$
            oauth2_resource:        ~

Resource Endpoint

We don't provide other else resource endpoint controller implementation besides above debug endpoint. You should consider implement your own endpoint with custom logic, e.g. fetching user email address or profile image.

On the other hand, you can protect your resource server endpoint with our custom firewall oauth2_resource. Shorthand version (default assume resource server bundled with authorization server, query local model manager, without scope protection):

# app/config/security.yml

security:
    firewalls:
        api_resource:
            pattern:                ^/api/resource
            oauth2_resource:        ~

Longhand version (assume resource server bundled with authorization server, query local model manager, protect with scope demoscope1):

# app/config/security.yml

security:
    firewalls:
        api_resource:
            pattern:                ^/api/resource
            oauth2_resource:
                resource_type:      model
                scope:              [ demoscope1 ]

If authorization server is hosting somewhere else, you can protect your local resource endpoint by query remote authorization server debug endpoint:

# app/config/security.yml

security:
    firewalls:
        api_resource:
            pattern:                ^/api/resource
            oauth2_resource:
                resource_type:      debug_endpoint
                scope:              [ demoscope1 ]
                options:
                    debug_endpoint: http://example.com/api/oauth2/debug
                    cache:          true

Demo

The demo is based on Symfony and AuthBucketOAuth2Bundle. Read though Demo for more information.

You may run the demo locally. Open a console and execute the following command to install the latest version in the oauth2-symfony-bundle directory:

$ composer create-project ekreative/oauth2-symfony-bundle ekreative/oauth2-symfony-bundle "^6.0"

Then use the PHP built-in web server to run the demo application:

$ cd ekreative/oauth2-symfony-bundle
$ ./bin/console server:run

Open your browser and access the http://127.0.0.1:8000 URL to see the Welcome page of demo application.

Also access http://127.0.0.1:8000/admin/refresh_database to initialize the bundled SQLite database with user account admin:secrete.

Tests

This project is coverage with PHPUnit test cases; CI result can be found from Travis CI;

To run the test suite locally, execute the following command:

$ ./vendor/bin/phpunit

References

License


All versions of oauth2-symfony-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2
lib-openssl Version *
symfony/framework-bundle Version ^3.4|^4.1
guzzlehttp/guzzle Version ^6
psr/log Version ^1
symfony/security Version ^3.4|^4.1
symfony/validator Version ^3.4|^4.1
symfony/yaml Version ^3.4|^4.1
symfony/templating Version ^3.4|^4.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package ekreative/oauth2-symfony-bundle contains the following files

Loading the files please wait ....