Download the PHP package pebble-solutions/pebbleauthclient without Composer

On this page you can find all versions of the php package pebble-solutions/pebbleauthclient. 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 pebbleauthclient

Quickstart

Introduction

This library offer a client for authenticate user and licence management written in PHP compatible with many PHP API Resource Server.

Installation

Requirements

The following procedures explains the installation of the following packages :

Install with composer

If your project use composer, simply add the following.

composer require pebble-solutions/pebbleauthclient

Usage

Configuration

Before you can work with the library, you must define a system environment variable with the URI of the public Json Web Key Set (remote JWKS file).

This file will be requested and store temporary on your API Server. Your server should be able to write on ./var/credentials/auth/jwks.json . If the file does not exist, it will be created.

If you start your server directly from a terminal, run this command on your terminal before starting your server :

export PBL_JWKS_REMOTE_URI=https://SERVER_URI/path/jwks.json

If you start your server within a Docker container, you should add this line to your Dockefile :

Dockerfile

ENV PBL_JWKS_REMOTE_URI=https://SERVER_URI/path/jwks.json

Other configurations

You can add more configuration by defining some more environment variables on your system. These configurations have values by default that works for most of the cases.

Environment variableDefaultDescription
PBL_JWKS_REMOTE_URIUnsetMANDATORY URI of the remote jwks.json file. This file contains all active public keys to decode token.
PBL_CERTS_FOLDER./var/credentials/authLocal folder for temporary store authentication credentials. Storing locally the credentials improves server response.
PBL_JWKS_EXP_TIME86400Duration in seconds after which Keys Set (JWKS) is considered as expired. All local copy of the keys must be destroyed and the remote server will be requested to create the new copy.

Test keys pair

JWKS URI (for PBL_JWKS_REMOTE_URI environment variable)

https://storage.googleapis.com/pebble-public-cdn/test_auth/jwks_test.json

Public and private keys used to sign a token

https://storage.googleapis.com/pebble-public-cdn/test_auth/public_test.pem

https://storage.googleapis.com/pebble-public-cdn/test_auth/private_test.pem

Authenticate with token string

try { $pebbleAuthToken = $authService->auth("a.valid.token"); $user = $pebbleAuthToken->getUser(); $licence = $pebbleAuthToken->getAuthenticatedLicence();

var_dump($pebbleAuthToken); var_dump($user); var_dump($licence);

} catch (Exception $e) { echo "Error : ".$e->getMessage(); }

Authenticate with HTTP Authorization header

This example shows one way to serverside authenticate a user with the Authorization header. The important thing is to communicate an array to authFromHttpHeaders() function with a valid Authorization key value.

try { $pebbleAuthToken = $authService->authFromHttpHeaders($request->headers->all()); $user = $pebbleAuthToken->getUser(); $licence = $pebbleAuthToken->getAuthenticatedLicence();

var_dump($pebbleAuthToken); var_dump($user); var_dump($licence);

} catch (Exception $e) { throw $e; }

// implement your own logic to get the user identifier $userIdentifier = /* ... /;

return new SelfValidatingPassport(new UserBadge($userIdentifier));

... */

}

$headers parameter in authFromHttpHeaders() method is compliant with PSR-7 standard recommendation. Theses values must be considered as valid :

..

Key to string relation :

// Check that the provided token has a valid audience for api.pebble.solutions/v5/my-resource

$auth_token = $authService->auth("----my.valid.token----", [ 'audience' => "api.pebble.solutions/v5/my-resource" ]);

// Check that token communicate through authorization header has a valid audience // for api.pebble.solutions/v5/my-resource $auth_token = $authService->authFromHttpHeaders(headers, [ 'audience' => "api.pebble.solutions/v5/my-resource" ]);


All versions of pebbleauthclient with dependencies

PHP Build Version
Package Version
Requires firebase/php-jwt Version ^6.10
guzzlehttp/guzzle Version ^7.0
phpfastcache/phpfastcache Version ^9.2
psr/http-factory Version ^1.0
guzzlehttp/psr7 Version ^2.6
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 pebble-solutions/pebbleauthclient contains the following files

Loading the files please wait ....