PHP code example of piges / security

1. Go to this page and download the library: Download piges/security 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/ */

    

piges / security example snippets

 php


use Piges\Auth\AuthFilter;
use Piges\Auth\AuthenticationHolder;

try {
	AuthFilter::filter();

	$user = Array(
		'id' => AuthenticationHolder::getAuthentication()->getId(),
		'authorities' => AuthenticationHolder::getAuthentication()->getAuthorities()
	);
} catch (\Throwable $th) {
	echo "Error in authentication: " + $th->getMessage();
}

 php


use Piges\Auth\AuthFilter;
use Piges\Ucp\UcpFilter;
use Piges\Ucp\UcpHolder;

try {
	AuthFilter::filter();

	UcpFilter::filter();

	$user = Array(
		'tenant' => UcpHolder::getUcp()->getTenant()->getName(),
		'eopoos' => UcpHolder::getUcp()->getEopoos(),
		'permissions' => UcpHolder::getUcp()->getPermissions()
	);
} catch (\Throwable $th) {
	echo "Error in authentication or in ucp: " + $th->getMessage();
}