PHP code example of pebble-solutions / pebbleauthclient

1. Go to this page and download the library: Download pebble-solutions/pebbleauthclient library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

pebble-solutions / pebbleauthclient example snippets



    $authService = new \PebbleAuthClient\Services\auth()


    /**
     * This class is an example of a custom authenticator for symfony.
     */
    class TokenAuthenticator extends AbstractAuthenticator
    {
        /** ... */

        public function authenticate(Request $request): Passport
        {
            $authService = new \PebbleAuthClient\Services\auth()


        [
            "authorization" => "my.valid.token"
        ]

    Key to array of strings relation :

    .. code:: PHP

        [
            "authorization" => [
                "my.valid.token"
            ]
        ]

    However, even if PSR-7 accept multiple values for the same header name, the following will cause an AmbiguousToken
    error. It is not allowed to provide multiple token throw the authorization header.

    .. code:: PHP

        [
            "authorization" => [
                "my.first.token",
                "my.second.token"
            ]
        ]

Check the audience
~~~~~~~~~~~~~~~~~~

Audience identifies the recipients that the token is intended for. Each resource server MUST be identified by its
audience name and the authorization process MUST check that this audience exists in the token.

.. warning::
    By default, audience is not checked by the authentication process. It is the responsibility of the resource server
    to communicate its audience name in order to only accept token that has been generated for the this specific
    resource server.

To check the audience, add an ``$options`` array to the ``auth()`` or ``authFromHttpHeaders()`` functions.

.. code:: PHP

    $authService = new \PebbleAuthClient\Services\auth()