2017 © Pedro Peláez
 

symfony-bundle proxy-bundle

Authenticated symfony bundle: provides an authentication layer on top of a PHP proxy.

image

fsb/proxy-bundle

Authenticated symfony bundle: provides an authentication layer on top of a PHP proxy.

  • Friday, July 3, 2015
  • by flosch
  • Repository
  • 1 Watchers
  • 0 Stars
  • 15 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Symfony FsbProxyBundle

Authenticated symfony bundle: provides an authentication layer on top of a PHP proxy., (*1)

This bundle provides a User model and a UserProvider, to authenticate users based on a yml file. It also provides a Symfony command to add users with encrypted passwords., (*2)

Once the user is connected, it provides a PHP proxy thanks to 8p/Guzzle-Bundle and the Guzzle PHP library, currently v6., (*3)

Why?

This bundle is usefull if you want to proxy an HTTP application, with an authentication layer stronger than http standards such as HTTP_BASIC., (*4)

Requirements

  • Symfony 2.7 or above
  • 8p/GuzzleBundle (included by composer)

Installation

To install this bundle, run the command below and you will get the latest version by Packagist., (*5)

``` bash composer require fsb/proxy-bundle, (*6)


### Usage Load required bundles in AppKernel.php: ``` php // app/AppKernel.php public function registerBundles() { $bundles = array( // [...] new EightPoints\Bundle\GuzzleBundle\GuzzleBundle() new Fsb\Bundle\ProxyBundle\FsbProxyBundle() ); }

Set up configuration, (*7)

``` yaml, (*8)

app/config/config.yml

twig: # [...] globals: proxy_title: Your Proxy HTML title, (*9)

FsbProxyBundle uses assetic, and for the login page,

Both CSS, SASS and JS resources.

However, you can override the templates and manage it yourself.

assetic: # [...] bundles: [ FsbProxyBundle ] filters: # [...] scss: # Requires ruby-sass apply_to: ".scss$" # OPTIONALLY, you can install uglifyjs and uglifycss to minify the assets uglifyjs2: bin: "path/of/your/node_modules/.bin/uglifyjs" uglifycss: bin: "path/of/your/node_modules/.bin/uglifycss", (*10)

guzzle: base_url: http://localhost:8888/, (*11)

fsb_proxy: users_provider_file_path: "path/of/users.yml", (*12)


Set up routing # app/config/routing.yml or any other routing file ``` yaml fsb_proxy: resource: "@FsbProxyBundle/Resources/config/routing.yml" prefix: /

Set up security ``` yaml, (*13)

app/config/security.yml

security: encoders: # The FsbProxyBundle User model class, you can choose your favorite encoder Fsb\Bundle\ProxyBundle\Model\User: algorithm: pbkdf2 hash_algorithm: sha512 iterations: 1000000 encode_as_base64: true, (*14)

providers: # [...] proxy_users: id: fsb_proxy.provider.yaml_user_provider, (*15)

firewalls: # [...] fsb_proxy_app_login: pattern: ^/login$ security: false, (*16)

fsb_proxy_app:
  pattern:  ^/
  provider: proxy_users
  form_login:
    check_path: fsb_proxy_login_check_page
    login_path: fsb_proxy_login_page
    always_use_default_target_path: true
    default_target_path: /
  logout:
    path:   fsb_proxy_logout_page
    target: /

access_control: - { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY } - { path: ^/, roles: ROLE_USER }, (*17)


### Authentication and users management Here we are! This bundle comes with a service called YamlUserProvider, providing users from a yaml file. To add an access, add a new yaml array of this user's informations : ``` yml # /path/of/your/users.yml username: salt: # the salt used to encrypt the password password: # the encrypted password

You also have two commands to manage users from the console :, (*18)

To create a new user :, (*19)

``` bash php app/console fsb-proxy:users:create [username] [password] [--all], (*20)


Both username and password arguments are optionnal, the command will ask for it if you do not provide it. The ````--override```` (or ````-o`````) option allow to replace an existing user's password (if the user does not exists, he will be created). To remove an existing user : ``` bash php app/console fsb-proxy:users:remove [username] [--all]

Username argument is optionnal, the command will ask for it if you do not provide it. The --all option allow to remove every existing users from the file., (*21)

Extend the bundle

The Bundle itself provides the security layer, with login and logout routes ; And a default login page, before "proxying" routes through the Guzzle client., (*22)

As a symfony bundle, you can extend it, to benefits of Symfony inheritance, Then override resources and / or controllers:, (*23)

Controller/
  RestController.php --> Manage PHP proxy once authenticated
  Security/
    AuthenticationController.php --> Manage authentication
Resources/
  views/
    layout.html.twig --> Base template with HTML doctype
    Security/
      login.html.twig --> Login page template

All you need to do is setting up your own bundle as child of FsbProxyBundle:, (*24)

``` php // src/You/YourBundleName/YouYourBundleName.php namespace You\YourBundleName;, (*25)

use Symfony\Component\HttpKernel\Bundle\Bundle;, (*26)

class YouYourBundleName extends Bundle { public function getParent() { return 'FsbProxyBundle'; } } ```, (*27)

Authors

  • Florent Schildknecht ([Portfolio][5])

License

This bundle is released under the MIT license, (*28)

The Versions

03/07 2015

dev-master

9999999-dev https://github.com/Flo-Schield-Bobby/FsbProxyBundle

Authenticated symfony bundle: provides an authentication layer on top of a PHP proxy.

  Sources   Download

MIT

The Requires

 

authentication curl rest security bundle symfony client proxy http client

03/07 2015

v0.1.1

0.1.1.0 https://github.com/Flo-Schield-Bobby/FsbProxyBundle

Authenticated symfony bundle: provides an authentication layer on top of a PHP proxy.

  Sources   Download

MIT

The Requires

 

authentication curl rest security bundle symfony client proxy http client

03/07 2015

v0.1.0

0.1.0.0 https://github.com/Flo-Schield-Bobby/FsbProxyBundle

Authenticated symfony bundle: provides an authentication layer on top of a PHP proxy.

  Sources   Download

MIT

The Requires

 

authentication curl rest security bundle symfony client proxy http client