PHPackages                             bildvitta/iss-sdk - 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. bildvitta/iss-sdk

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

bildvitta/iss-sdk
=================

This package is used to communicate with the permission and authentication microservice.

v0.1.27(6mo ago)123.4k↓22.7%[2 PRs](https://github.com/bildvitta/iss-sdk/pulls)3MITPHPPHP ^7.4|^8.0|^8.1|^8.2|^8.3

Since May 3Pushed 2mo ago16 watchersCompare

[ Source](https://github.com/bildvitta/iss-sdk)[ Packagist](https://packagist.org/packages/bildvitta/iss-sdk)[ Docs](https://github.com/bildvitta/iss-sdk)[ RSS](/packages/bildvitta-iss-sdk/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (148)Used By (3)

[![Latest Version on Packagist](https://camo.githubusercontent.com/40bc4bed7bb4d08cabee44279fee09a2d07472355ad88a51b409a5ff477b2f64/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f62696c6476697474612f6973732d73646b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bildvitta/iss-sdk)[![Total Downloads](https://camo.githubusercontent.com/c9e8789b30fa9a7a501143312b15df8d80f6bc4ba92a79cd8c7c8ab72b20db86/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f62696c6476697474612f6973732d73646b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bildvitta/iss-sdk)

Introduction
============

[](#introduction)

The ISS (International Space Station) aims to be a space station (`client`) of connection between the microservices of its ecosystem and the authentication and permissions microservice of the user that here is called in the script as Hub.permissions modules / microservices (Hub)

Installation
============

[](#installation)

You can install the package via composer:

```
composer require bildvitta/iss-sdk:dev-develop
```

For everything to work perfectly in addition to having the settings file published in your application, run the command below:

```
php artisan hub:install
```

Configuration
=============

[](#configuration)

This is the contents of the published config file:

```
return [
    'base_uri' => env('MS_HUB_BASE_URI', 'https://api-dev-hub.nave.dev'),

    'front_uri' => env('MS_HUB_FRONT_URI', 'https://develop.hub.nave.dev'),

    'prefix' => env('MS_HUB_API_PREFIX', '/api'),

    'model_user' => '\App\Entities\User',

    'model_company' => '\BildVitta\Hub\Entities\HubCompany::class',

    'programatic_access' => [
        'client_id' => env('HUB_PROGRAMMATIC_CLIENT'),
        'client_secret' => env('HUB_PROGRAMMATIC_SECRET')
    ],

    'oauth' => [
        'client_id' => env('HUB_CLIENT_ID', ''),
        'client_secret' => env('HUB_CLIENT_SECRET', ''),
        'redirect' => env('HUB_REDIRECT_URI', ''),
        'scopes' => env('HUB_SCOPE', 'profile'),

        'authorize_uri' => '/auth/authorize',
        'token_uri' => '/oauth/token',
        'userinfo_uri' => '/users/me'
    ]
];
```

With the configuration file ` hub.php` published in your configuration folder it is necessary to create environment variables in your ` .env` file:

```
MS_HUB_BASE_URI="https://api-dev-hub.nave.dev"

MS_HUB_PREFIX="/api"
```

Change permission and role model from spatie/laravel-permissions
----------------------------------------------------------------

[](#change-permission-and-role-model-from-spatielaravel-permissions)

You should change the default spatie/laravel-permissions models to ours, as we have some substantial changes to the use of Role and Permission.

```
// config/permission.php

return [
    'models' = [
        'permission' => \BildVitta\Hub\Entities\HubPermission::class,
        'role' => \BildVitta\Hub\Entities\HubRole::class,
    ]
];
```

If you already have a change to these models, just extend our classes to have the correct functionalities.

Add Trait on User Model
-----------------------

[](#add-trait-on-user-model)

And remember to add the `BildVitta\Hub\Traits\User\HasCompanyLinks` Trait in the Users model.

```
// \App\Models\User

use BildVitta\Hub\Traits\User\HasCompanyLinks;

class User extends Authenticatable
{
    use HasCompanyLinks;
    ...
}
```

Remembering that this trait already has `Spatie\Permission\Traits\HasRoles` by default, so you can remove the `Spatie\Permission\Traits\HasRoles` trait from your user model.

Usage
=====

[](#usage)

All requests made to the ISS Service will return an instance of [`\Illuminate\Http\Client\Response`](https://laravel.com/api/8.x/Illuminate/Http/Client/Response.html), which implements the PHP ` ArrayAccess` interface, allowing you to access JSON response data directly in the response

This also means that a variety of methods that can be used to inspect the response, follow some below:

```
$response = Hub::setToken('jwt')->auth()->permissions();

$response->body(); // string;
$response->json(); // array|mixed;
$response->collect(); // Illuminate\Support\Collection;
$response->status(); // int;
$response->ok(); // bool;
$response->successful(); // bool;
$response->failed(); // bool;
$response->serverError(); // bool;
$response->clientError(); // bool;
$response->header('content-type'); // string;
$response->headers(); // array;
```

Initialize ISS Service.
-----------------------

[](#initialize-iss-service)

As there are several ways to program, there are also several ways to start the ISS Service.

Below are some ways to start the Service.

```
$token = 'jwt';

$hub = app('hub', [$token]); // instance 2
$hub = app('hub')->setToken($token); // instance 1
$hub = new \BildVitta\Hub\Hub($token); // instance 3
$hub = (new \BildVitta\Hub\Hub())->setToken($token); // instance 4
$hub = BildVitta\Hub\Facades\Hub::setToken($token); // instance 1
```

Authenticating User
-------------------

[](#authenticating-user)

To authenticate the Hub user in your module, it is necessary to use the middleware `hub.auth = \ BildVitta \ Hub \ Middleware \ AuthenticateHubMiddleware`.

It will validate the token and create, if it does not exist, the user of the token in its user table.

```
Route::middleware('hub.auth')->get('/users/me', function () {
    return auth()->user()->toArray();
});
```

When we installed the package, we created the `hub_uuid` column in your user table.

Tf it is not possible to authenticate, the middleware will return 401.

User Authenticated
------------------

[](#user-authenticated)

To access the token's user data directly, there is the `\BildVitta\Hub\Contracts\Resources\AuthResourceContract`interface

### Check Token

[](#check-token)

It is verified whether the token passed by parameter or previously loaded in the ISS Service is valid.

Example of use:

```
try {
    Hub::auth()->check('jwt');
} catch (RequestException $requestException) {
    throw new Exception('invalid token');
}
```

### Get Permissions

[](#get-permissions)

It is possible to obtain ALL the permissions of the token uploaded to the ISS Service.

Example of use:

```
try {
    $permissions = Hub::setToken('jwt')->auth()->permissions()['results']; // Implements `ArrayAccess`

    foreach ($permissions as $permission) {
        #TODO
    }
} catch (RequestException $requestException) {
    #TODO
}
```

### Adding permission scope to entity listing.

[](#adding-permission-scope-to-entity-listing)

Now we have added a scope that filters by the permission level of the logged in user. To use it is very simple, just add in the global scopes the PermissionScope class passing the permission that the user has to have, and then the magic happens ;D

Code example:

```
use BildVitta\Hub\Scopes\PermissionScope;

$query = RealEstateDevelopment::query();
$query->withGlobalScope('permission', new PermissionScope('real_estate_developments.show'));

$count = $query->count();
$query->pagination();

return (new RealEstateDevelopmentResource('index', $query->get()))->count($count);
```

Remembering that the scope name has to be permission, if not, it doesn't work &lt;3

### Notifications

[](#notifications)

> Make sure the BroadcastServiceProvider is enabled in `config/app.php`

Add the `ABLY_KEY` key as an environment variable (ask your coordinator for this key)

```
ABLY_KEY=your-ably-key
```

Then, set the BROADCAST\_CONNECTION environment variable to ably in your application's .env file:

```
BROADCAST_CONNECTION=ably
```

Check the `routes/channels.php` file if the private channel authentication route is correct.

```
use Illuminate\Support\Facades\Broadcast;

Broadcast::channel('notifications.{uuid}', function ($user, $uuid) {
    return (string) $user->uuid === (string) $uuid;
});
```

Ensure that the $user-&gt;uuid is the same as that used in the hub, otherwise it may result in a 403 in this private channel authentication api.

To finish, go to the BroadcastServiceProvider file and change it to this code.

```
Broadcast::routes([
    'middleware' => ['hub.check'],
    'prefix' => 'api',
]);
```

Ensure that the $user-&gt;uuid is the same as that used in the hub, otherwise it may result in a 403 in this private channel authentication api.

To finish, go to the BroadcastServiceProvider file and change it to this code.

```
Broadcast::routes([
    'middleware' => ['hub.check'],
    'prefix' => 'api',
]);
```

New Per-Company Permissioning (v2)
----------------------------------

[](#new-per-company-permissioning-v2)

To use the new permissioning method, you must follow these steps and make the necessary changes for the reality of each project.

First, in the `config/permissions.php` file you must change the `register_permission_check_method` attribute from true to false, as we will control the permissioning method manually.

Example:

```
// config/permission.php
return [
    ...
    'register_permission_check_method' => false
    ...
];
```

After leaving it as false, in requests or policies the following change must be made (if applicable) to the `->can` method that exists within the user (or the model that extends `HasRoles` or `HasPermissions`)

If the permission for the screen in question needs to be per company, you must pass the company's `uuid` as the second parameter of the `can()` method. Example:

```
$user->can('users.show', 'company-uuid');
```

The code above will check if the 'users.show' permission exists within the company passed as a parameter. If it does, it returns true, otherwise false.

If you have screens that do not require permission per company, but cases where, if the person has permission regardless of the link, just leave the `can()` method as it is, for example:

```
$user->can('users.show');
```

In the code above, it will search for this permission in any of the user's existing links, if found it returns true otherwise false.

Testing
-------

[](#testing)

coming soon...

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [Jean C. Garcia](https://github.com/SOSTheBlack)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

55

—

FairBetter than 98% of packages

Maintenance78

Regular maintenance activity

Popularity28

Limited adoption so far

Community28

Small or concentrated contributor base

Maturity75

Established project with proven stability

 Bus Factor1

Top contributor holds 54.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~12 days

Recently: every ~35 days

Total

140

Last Release

115d ago

PHP version history (4 changes)v0.0.1PHP ^7.4|^8.0

v0.0.21PHP ^8.0

v0.0.63PHP ^7.4|^8.0|^8.1

v0.1.11-beta.1PHP ^7.4|^8.0|^8.1|^8.2|^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/57ede45a8ce528ade98fadbb32397afb6c0234f9d05caae7ac207d3b4d026af1?d=identicon)[hynzhw](/maintainers/hynzhw)

![](https://www.gravatar.com/avatar/e32e39fb848943b1a94bb2c167a2bda11eb45814ba34d539e6b1685a5de6e272?d=identicon)[michaelnakamura](/maintainers/michaelnakamura)

![](https://www.gravatar.com/avatar/ab5f117bbac50e0314758bcc25c9052dc4546568082eff672b65b128be0e2d98?d=identicon)[fabiomartins](/maintainers/fabiomartins)

![](https://www.gravatar.com/avatar/3ce1635f07565fb1531991b47d86c407b9b30955eb1871dad4ed33810aaffe88?d=identicon)[leandrohago](/maintainers/leandrohago)

---

Top Contributors

[![zerossB](https://avatars.githubusercontent.com/u/8009480?v=4)](https://github.com/zerossB "zerossB (221 commits)")[![dklbueno](https://avatars.githubusercontent.com/u/8246721?v=4)](https://github.com/dklbueno "dklbueno (48 commits)")[![michaelnakamura](https://avatars.githubusercontent.com/u/10209108?v=4)](https://github.com/michaelnakamura "michaelnakamura (39 commits)")[![leandrohago](https://avatars.githubusercontent.com/u/64143489?v=4)](https://github.com/leandrohago "leandrohago (29 commits)")[![SOSTheBlack](https://avatars.githubusercontent.com/u/5401143?v=4)](https://github.com/SOSTheBlack "SOSTheBlack (21 commits)")[![estevao-simoes](https://avatars.githubusercontent.com/u/25695293?v=4)](https://github.com/estevao-simoes "estevao-simoes (18 commits)")[![paulodavanco](https://avatars.githubusercontent.com/u/11135122?v=4)](https://github.com/paulodavanco "paulodavanco (13 commits)")[![nathanmacsantos](https://avatars.githubusercontent.com/u/93023735?v=4)](https://github.com/nathanmacsantos "nathanmacsantos (11 commits)")[![pauloimon](https://avatars.githubusercontent.com/u/3463932?v=4)](https://github.com/pauloimon "pauloimon (2 commits)")[![natemacs](https://avatars.githubusercontent.com/u/5554604?v=4)](https://github.com/natemacs "natemacs (1 commits)")

---

Tags

laravelbildvittahubiss-sdk

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/bildvitta-iss-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/bildvitta-iss-sdk/health.svg)](https://phpackages.com/packages/bildvitta-iss-sdk)
```

###  Alternatives

[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[spatie/laravel-login-link

Quickly login to your local environment

4381.2M1](/packages/spatie-laravel-login-link)[ryangjchandler/laravel-cloudflare-turnstile

A simple package to help integrate Cloudflare Turnstile.

438896.6k2](/packages/ryangjchandler-laravel-cloudflare-turnstile)[spatie/laravel-passkeys

Use passkeys in your Laravel app

444494.4k16](/packages/spatie-laravel-passkeys)[binary-cats/laravel-rbac

Laravel enum-backed RBAC extension of spatie/laravel-permission

7730.4k](/packages/binary-cats-laravel-rbac)[chiiya/filament-access-control

Admin user, role and permission management for Laravel Filament

21847.2k](/packages/chiiya-filament-access-control)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
