Download the PHP package frobou/frobou-system-permission without Composer

On this page you can find all versions of the php package frobou/frobou-system-permission. 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 frobou-system-permission

Frobou System Permission

SensioLabsInsight

Sistema de verificação de permissões de uso.

Como funciona: As permissões são verificadas onde são necessárias, como mostra o exemplo:

$config = new FrobouDbConfig(json_decode(file_get_contents(__DIR__ . './../database.json')));
$connection = new FrobouDbConnection($config);
$perms = new FrobouSystemPermission($connection);
$user = $this->perms->login('test', 'pass', true);
$exp = $user->getPermission('admin');
var_dump($exp);
object(stdClass)#140 (4) {
  ["can_select"]=>
  bool(true)
  ["can_insert"]=>
  bool(false)
  ["can_update"]=>
  bool(true)
  ["can_delete"]=>
  bool(false)
}
if ($exp->can_select){
    echo "I can";
}

A ideia é ter permissões com níveis hierárquicos, admin.teste diz que o usuário tem permissão X no recurso teste da tela admin

Usamos o pacote frobou-db-connect para a conexão com banco de dados. Ao instanciar FrobouSystemPermission, todos os recursos necessários ficam disponíveis.

e a instância de SystemUser recebida no métido login fornece, além dos dados do usuário:

Tipos de permissões:

Usando:

Algumas constantes podem ser usada como uma forma de configuração do sistema.

Testando login

public function testLoginOk()
{
    $user = $this->perms->login('test', 'pass', true);
    $this->assertInstanceOf(SystemUser::class, $user);
}

Testando permissões

public function testPermissionForResourceAdminDotTeste()
{
    $user = $this->perms->login('test', 'pass', true);
    $exp = new \stdClass();
    $exp->can_select = true;
    $exp->can_insert = true;
    $exp->can_update = true;
    $exp->can_delete = true;
    $this->assertEquals($user->getPermission('admin.teste'), $exp);
}

Criando um grupo

public function testInsertGroup()
{
    $this->assertTrue($this->perms->createGroup('grp_' . rand(0, 15988)));
}

Criando uma permissão

public function testInsertResource()
{
    $this->assertTrue($this->perms->createResource('admin.test', 0));
}

Criando um usuário

public function testInsertUser()
{
    $user = new SystemUser();
    $user->setActive(1)->setCanEdit(1)->setCanLogin(1)->setCanUseApi(1)
        ->setCanUseWeb(1)->setCreateDate()->setEmail('[email protected]')->setName('Novo Usuario')
        ->setPassword('senhanha')->setSystemGroup(1)->setUsername('username_' . rand(0, 12345))->setUserType('T');
    $this->assertTrue($this->perms->createUser($user));
}

Vinculando grupo X permissão

public function testRegisterGroupResource()
{
    $this->perms->createResource('admin.com', 3);
    $this->assertTrue($this->perms->registerGroupResource('user', 'admin.com'));
}

Desvinculando grupo X permissão

public function testUnRegisterGroupResource()
{
    $this->perms->createResource('admin.com', 3);
    $this->assertTrue($this->perms->unregisterGroupResource('user', 'admin.com'));
}

Vinculando user X permissão

public function testRegisterUserResource()
{
    $this->perms->createResource('admin.com', 7);
    $this->assertTrue($this->perms->registerUserResource('ispti', 'admin.com'));
}

Desvinculando user X permissão

public function testRegisterUserResource()
{
    $this->perms->createResource('admin.com', 7);
    $this->assertTrue($this->perms->unregisterUserResource('ispti', 'admin.com'));
}

Testando Remover usuário (desativar)

public function testDeleteUser(){
    $username = 'username_' . rand(0, 12345);
    $user = new SystemUser();
    $user->setActive(1)->setCanEdit(1)->setCanLogin(1)->setCanUseApi(1)
        ->setCanUseWeb(1)->setCreateDate()->setEmail('[email protected]')->setName('Novo Usuario')
        ->setPassword('senhanha')->setSystemGroup(1)->setUsername($username)->setUserType('T');
    $this->perms->createUser($user);
    $this->perms->createResource('admin.com', 3);
    $this->perms->registerGroupResource($username, 'admin.com');
    $this->perms->registerUserResource($username, 'admin.com');
    $this->assertTrue($this->perms->deleteUser($username));
}

Testando reativar usuário

public function testUndeleteUser(){
    $username = 'fabio';
    $user = new SystemUser();
    $user->setActive(1)->setCanEdit(1)->setCanLogin(1)->setCanUseApi(1)
        ->setCanUseWeb(1)->setCreateDate()->setEmail('[email protected]')->setName('Novo Usuario')
        ->setPassword('senhanha')->setSystemGroup(1)->setUsername($username)->setUserType('T');
    $this->perms->createUser($user);
    $this->perms->deleteUser($username);
    $this->assertTrue($this->perms->undeleteUser($username));
}

Testando remover usuário (realmente)

public function testDeleteUserReal(){
    define('TRUE_DELETE', true);
    $username = 'username_' . rand(0, 12345);
    $user = new SystemUser();
    $user->setActive(1)->setCanEdit(1)->setCanLogin(1)->setCanUseApi(1)
        ->setCanUseWeb(1)->setCreateDate()->setEmail('[email protected]')->setName('Novo Usuario')
        ->setPassword('senhanha')->setSystemGroup(1)->setUsername($username)->setUserType('T');
    $this->perms->createUser($user);
    $this->assertTrue($this->perms->deleteUser($username));
}

All versions of frobou-system-permission with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
frobou/frobou-db-connect Version *
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 frobou/frobou-system-permission contains the following files

Loading the files please wait ....