PHPackages                             gwsn/bizhost-auth-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. gwsn/bizhost-auth-bundle

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

gwsn/bizhost-auth-bundle
========================

Authenticate user against Bizhost Auth API

1.0.4(2y ago)040MITPHPPHP ^8.2

Since May 7Pushed 2y ago1 watchersCompare

[ Source](https://github.com/gwsn/bizhost-auth-bundle)[ Packagist](https://packagist.org/packages/gwsn/bizhost-auth-bundle)[ Docs](https://github.com/gwsn/bizhost-auth-bundle)[ RSS](/packages/gwsn-bizhost-auth-bundle/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (7)Versions (7)Used By (0)

Bizhost Authentication Bundle
=============================

[](#bizhost-authentication-bundle)

For the Symfony Bundle see the package: [gwsn/bizhost-auth-bundle](https://github.com/gwsn/bizhost-auth-bundle)

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require gwsn/bizhost-auth-bundle
```

First configuration to start usage
----------------------------------

[](#first-configuration-to-start-usage)

You need to request a new clientId and clientSecret for the application

1. Go to `bizhost auth portal`
2. Go to `Applications`
3. Go to `Register new application` and follow the wizard.
    (give it a name like mine is 'example-app-authentication')
4. When created the application is created write down the following details
5. 'Application Identifier', this will be your `$clientId`
6. 'Application Secret', this will be your `$clientSecret`(Make sure you write this one down as it will be only shown once)

    Example:

    - Auth meta url: `https://auth.bizhost.nl/.well-known/oauth-authorization-server`

Basic setup for the Bizhost Authentication Bundle
-------------------------------------------------

[](#basic-setup-for-the-bizhost-authentication-bundle)

### Enable the bundle

[](#enable-the-bundle)

Add the bundle to your `config/bundles.php` file:

```
...
Bizhost\Authentication\Bundle\AuthenticateBundle::class => ['all' => true],
...
```

### Setup Security.yaml

[](#setup-securityyaml)

In case you want full authentication where the application is redirected to bizhost auth with code flow.

Add Providers, custom\_authenticators and access\_control to your `config/packages/security.yaml` file:

```
security:
    enable_authenticator_manager: true

    providers:
        authenticated_account_provider:
            id: Bizhost\Authentication\Bundle\Authenticate\AuthenticatedAccountProvider

    firewalls:
        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false
        main:
            pattern: ^/(account|auth)
            stateless: false
            custom_authenticators:
              - Bizhost\Authentication\Bundle\Authenticate\BizhostAuthAuthenticator
            entry_point: Bizhost\Authentication\Bundle\Authenticate\BizhostAuthAuthenticator
            logout:
                path: app_logout

    access_control:
         - { path: ^/account, roles: ROLE_USER }
         - { path: ^/profile, roles: ROLE_USER }
```

In case you want full authentication where the application is redirected to bizhost auth with code flow.

Add Providers, custom\_authenticators and access\_control to your `config/packages/security.yaml` file:

```
security:
    enable_authenticator_manager: true

    firewalls:
      api:
         pattern: ^/api
         stateless: true
         access_token:
           token_handler: Bizhost\Authentication\Bundle\Authenticate\BizhostAuthAccessTokenAuthenticator

    access_control:
         - { path: ^/api, roles: ROLE_USER }
```

### Routes

[](#routes)

To start authentication the entry\_point is used to redirect the user to the bizhost auth server. So every route behind access\_control should trigger the redirect.

When authentication is successful it will redirect the user to /auth/success, you should add route to handle this in your `config/routes.yaml` or in one of `config/routes/*.yaml` files:

It is also good practice to add a logout route to handle the logout of the user.

```
auth.callback:
    path: /auth/callback
    controller: App\Authentication\Controller\AuthController::handleCallback
    methods: [ GET ]

auth.login.success:
    path: /auth/success
    controller: App\Authentication\Controller\AuthController::handleSuccess
    methods: [ GET ]
```

### Controller

[](#controller)

Create a controller that will handle the callback and success route.

```
