Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
09aa28f
feat(testbench): add workbench install command
binaryfire Jun 24, 2026
7fe39fe
Add cache memo tests
binaryfire Jun 24, 2026
63c44d0
docs(permission): add fresh port plans
binaryfire Jun 25, 2026
8381a0f
chore(permission): archive legacy implementation
binaryfire Jun 25, 2026
ed0dd07
feat(permission): add fresh package wiring and schema
binaryfire Jun 25, 2026
056cbf4
feat(permission): port contracts and exceptions
binaryfire Jun 25, 2026
d7d95cd
feat(permission): add registrar and runtime helpers
binaryfire Jun 25, 2026
38cb286
feat(permission): port role and permission models
binaryfire Jun 25, 2026
346a262
feat(permission): port permission and role traits
binaryfire Jun 25, 2026
eea53e7
feat(permission): port authorization middleware
binaryfire Jun 25, 2026
d1c17e1
feat(permission): add assignment events
binaryfire Jun 25, 2026
44c19bb
feat(permission): port console commands
binaryfire Jun 25, 2026
2f6341a
feat(permission): wire service provider integration
binaryfire Jun 25, 2026
42deea2
feat(auth): expose default guard on factory contract
binaryfire Jun 25, 2026
632e692
feat(database): expose guardable column cache reset
binaryfire Jun 25, 2026
cb4ad7d
test(permission): reset permission state between tests
binaryfire Jun 25, 2026
23bd196
test(permission): add test harness and fixtures
binaryfire Jun 25, 2026
aa3ca66
test(permission): add command coverage
binaryfire Jun 25, 2026
33d2661
test(permission): add middleware coverage
binaryfire Jun 25, 2026
660b0eb
test(permission): add model and trait coverage
binaryfire Jun 25, 2026
bc6629f
test(permission): add integration coverage
binaryfire Jun 25, 2026
74282c0
test(permission): add Hypervel regression coverage
binaryfire Jun 25, 2026
16f58d7
docs(permission): document fresh permission package
binaryfire Jun 25, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
691 changes: 691 additions & 0 deletions _archive/docs/permission.md

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions _archive/src/permission/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
The MIT License (MIT)

Copyright (c) Spatie bvba info@spatie.be

Copyright (c) Hyperf

Copyright (c) Hypervel

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
6 changes: 6 additions & 0 deletions _archive/src/permission/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Permission for Hypervel
===

Migrated from: https://github.com/spatie/laravel-permission

[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/hypervel/permission)
55 changes: 55 additions & 0 deletions _archive/src/permission/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"name": "hypervel/permission",
"type": "library",
"description": "The permission package for Hypervel.",
"license": "MIT",
"keywords": [
"php",
"swoole",
"permission",
"hypervel"
],
"authors": [
{
"name": "Albert Chen",
"email": "albert@hypervel.org"
},
{
"name": "Raj Siva-Rajah",
"homepage": "https://github.com/binaryfire"
}
],
"support": {
"issues": "https://github.com/hypervel/components/issues",
"source": "https://github.com/hypervel/components"
},
"autoload": {
"psr-4": {
"Hypervel\\Permission\\": "src/"
}
},
"require": {
"php": "^8.4",
"hypervel/auth": "^0.4",
"hypervel/cache": "^0.4",
"hypervel/collections": "^0.4",
"hypervel/console": "^0.4",
"hypervel/contracts": "^0.4",
"hypervel/database": "^0.4",
"hypervel/http": "^0.4",
"hypervel/support": "^0.4"
},
"config": {
"sort-packages": true
},
"extra": {
"branch-alias": {
"dev-main": "0.4-dev"
},
"hypervel": {
"providers": [
"Hypervel\\Permission\\PermissionServiceProvider"
]
}
}
}
194 changes: 194 additions & 0 deletions _archive/src/permission/config/permission.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
<?php

declare(strict_types=1);

return [
/*
|--------------------------------------------------------------------------
| Permission Models
|--------------------------------------------------------------------------
|
| When using the "HasRoles" and "HasPermissions" traits from this package,
| we need to know which Eloquent models should be used to retrieve your
| roles and permissions. You may use whatever models you like.
|
*/

'models' => [
/*
* When using the "HasRoles" trait from this package, we need to know which
* Eloquent model should be used to retrieve your roles. Of course, it
* is often just the "Role" model but you may use whatever you like.
*
* The model you want to use as a Role model needs to implement the
* `Hypervel\Permission\Contracts\Role` contract.
*/

'role' => \Hypervel\Permission\Models\Role::class,

/*
* When using the "HasPermissions" trait from this package, we need to know which
* Eloquent model should be used to retrieve your permissions. Of course, it
* is often just the "Permission" model but you may use whatever you like.
*
* The model you want to use as a Permission model needs to implement the
* `Hypervel\Permission\Contracts\Permission` contract.
*/

'permission' => \Hypervel\Permission\Models\Permission::class,
],

/*
|--------------------------------------------------------------------------
| Permission Storage Configuration
|--------------------------------------------------------------------------
|
| This configuration determines the database connection that will be used
| to store permission-related data. You can specify a different connection
| if you want to store permissions in a separate database.
|
*/

'storage' => [
'database' => [
'connection' => env('DB_CONNECTION', 'mysql'),
],
],

/*
|--------------------------------------------------------------------------
| Permission Table Names
|--------------------------------------------------------------------------
|
| The following table names are used by the permission package to store
| roles, permissions and their relationships. You may change these names
| to match your existing database schema or naming conventions.
|
*/

'table_names' => [
/*
* When using the "HasRoles" trait from this package, we need to know which
* table should be used to retrieve your roles. We have chosen a basic
* default value but you may easily change it to any table you like.
*/

'roles' => 'roles',

/*
* When using the "HasPermissions" trait from this package, we need to know which
* table should be used to retrieve your permissions. We have chosen a basic
* default value but you may easily change it to any table you like.
*/

'permissions' => 'permissions',

/*
* When using the "HasRoles" trait from this package, we need to know which
* table should be used to retrieve your roles permissions. We have chosen a
* basic default value but you may easily change it to any table you like.
*/

'role_has_permissions' => 'role_has_permissions',

/*
* When using the "HasPermissions" trait from this package, we need to know which
* table should be used to retrieve your models permissions. We have chosen a
* basic default value but you may easily change it to any table you like.
*/

'owner_has_permissions' => 'owner_has_permissions',

/*
* When using the "HasRoles" trait from this package, we need to know which
* table should be used to retrieve your models roles. We have chosen a
* basic default value but you may easily change it to any table you like.
*/

'owner_has_roles' => 'owner_has_roles',
],

/*
|--------------------------------------------------------------------------
| Permission Column Names
|--------------------------------------------------------------------------
|
| This configuration allows you to customize the column names used in
| the pivot tables and relationships. You can modify these to match
| your database schema or to resolve naming conflicts.
|
*/

'column_names' => [
/*
* Change this if you want to name the related pivots other than defaults
*/

'role_pivot_key' => 'role_id',
'permission_pivot_key' => 'permission_id',

/*
* Change this if you want to name the related model primary key other than
* `owner_id`.
*
* For example, this would be nice if your primary keys are all UUIDs. In
* that case, name this `owner_uuid`.
*/

'owner_morph_key' => 'owner_id',

/*
* The name of the morphable relation for the owner model.
* This is used to determine the owner type when using polymorphic relations.
*/

'owner_name' => 'owner',
],
/*
|--------------------------------------------------------------------------
| Permission Cache Configuration
|--------------------------------------------------------------------------
|
| By default all permissions are cached for 24 hours to speed up performance.
| When permissions or roles are updated the cache is flushed automatically.
| You may optionally indicate a specific cache driver to use for permission
| and role caching using any of the `store` drivers listed in the cache.php
| config file. Using 'default' here means to use the `default` set in cache.php.
|
*/

'cache' => [
/*
* By default all permissions are cached for 24 hours to speed up performance.
* When permissions or roles are updated the cache is flushed automatically.
*/

'expiration_seconds' => 86400, // 24 hours in seconds

'keys' => [
/*
* The cache key used to store all roles with their permissions.
* This is used for efficient role-permission lookups.
*/
'roles' => 'hypervel.permission.cache.roles',
/*
* The cache key prefix used to store roles for individual owners.
* The actual key will be: {prefix}:{owner_type}:{owner_id}
*/
'owner_roles' => 'hypervel.permission.cache.owner.roles',
/*
* The cache key prefix used to store permissions for individual owners.
* The actual key will be: {prefix}:{owner_type}:{owner_id}
*/
'owner_permissions' => 'hypervel.permission.cache.owner.permissions',
],

/*
* You may optionally indicate a specific cache driver to use for permission and
* role caching using any of the `store` drivers listed in the cache.php config
* file. Using 'default' here means to use the `default` set in cache.php.
*/

'store' => env('PERMISSION_CACHE_STORE', 'default'),
],
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?php

declare(strict_types=1);

use Hypervel\Database\Migrations\Migration;
use Hypervel\Database\Schema\Blueprint;
use Hypervel\Support\Facades\Schema;

return new class extends Migration {
/**
* Get the migration connection name.
*/
public function getConnection(): ?string
{
return config('permission.storage.database.connection')
?: parent::getConnection();
}

/**
* Run the migrations.
*/
public function up(): void
{
$schema = Schema::connection($this->getConnection());

$schema->create('roles', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name')->unique();
$table->string('guard_name');
$table->timestamps();

$table->index(['name', 'guard_name']);
});

$schema->create('permissions', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name')->unique();
$table->string('guard_name');
$table->timestamps();
$table->index(['name', 'guard_name']);
});
$schema->create('role_has_permissions', function (Blueprint $table) {
$table->unsignedBigInteger('permission_id');
$table->unsignedBigInteger('role_id');
$table->boolean('is_forbidden');
$table->timestamps();

$table->primary(['permission_id', 'role_id']);
$table->index('role_id');
$table->index('permission_id');
});

$schema->create('owner_has_permissions', function (Blueprint $table) {
$table->unsignedBigInteger('permission_id');
$table->morphs('owner');
$table->boolean('is_forbidden');
$table->timestamps();

$table->primary(['permission_id', 'owner_id', 'owner_type']);
$table->index('owner_id');
$table->index('permission_id');
});

$schema->create('owner_has_roles', function (Blueprint $table) {
$table->unsignedBigInteger('role_id');
$table->morphs('owner');
$table->timestamps();

$table->primary(['role_id', 'owner_id', 'owner_type']);
$table->index('owner_id');
$table->index('role_id');
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
$schema = Schema::connection($this->getConnection());
$schema->dropIfExists('owner_has_roles');
$schema->dropIfExists('owner_has_permissions');
$schema->dropIfExists('role_has_permissions');
$schema->dropIfExists('permissions');
$schema->dropIfExists('roles');
}
};
18 changes: 18 additions & 0 deletions _archive/src/permission/src/Contracts/Permission.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace Hypervel\Permission\Contracts;

use Hypervel\Database\Eloquent\Relations\BelongsToMany;

/**
* @mixin \Hypervel\Permission\Models\Permission
*/
interface Permission
{
/**
* A role may be given various permissions.
*/
public function roles(): BelongsToMany;
}
Loading