free2er/oauth-server-bundle

OAuth Server Bundle

1.0.0 2019-04-11 22:45 UTC

This package is auto-updated.

Last update: 2024-11-12 11:46:11 UTC


README

Symfony bundle which provides OAuth 2.0 authorization server capabilities. The authorization server implemented using the thephpleague/oauth2-server library.

Installation

This component can be installed with the Composer dependency manager.

  1. Install Composer

  2. Install the component as a dependency of your project

     composer require free2er/oauth-server-bundle
    
  3. Enable the bundle

<?php

// config/bundles.php
return [
    // ...
    Free2er\OAuth\OAuthServerBundle::class => ['all' => true],
    // ...
];
  1. Configure the bundle parameters
# config/packages/oauth_server.yaml
o_auth_server:
    encryption_key: '%env(resolve:APP_SECRET)%'
    private_key: file://%kernel.project_dir%/path/to/private.key
    private_key_password: ~ 
    ttl:
        access_token: PT1H
        authorization_code: PT1H
        refresh_token: P1M
    grants:
        - League\OAuth2\Server\Grant\ClientCredentialsGrant
        - League\OAuth2\Server\Grant\PasswordGrant
        - League\OAuth2\Server\Grant\AuthCodeGrant
        - League\OAuth2\Server\Grant\RefreshTokenGrant
  1. Configure the router
# config/routes.yaml
# ...
oauth:
    resource: '@OAuthServerBundle/Resources/config/routes.yaml'
    prefix: /auth
# ...
  1. Update the project schema and register the client application

     bin/console doctrine:schema:update
     bin/console oauth:client:update my-client -g client_credentials
    
  2. Done!