定制 opscale-co/nova-authorization 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

opscale-co/nova-authorization

Composer 安装命令:

composer require opscale-co/nova-authorization

包简介

Secure your Nova resources with roles and permissions

README 文档

README

Support Opscale

At Opscale, we’re passionate about contributing to the open-source community by providing solutions that help businesses scale efficiently. If you’ve found our tools helpful, here are a few ways you can show your support:

Star this repository to help others discover our work and be part of our growing community. Every star makes a difference!

💬 Share your experience by leaving a review on Trustpilot or sharing your thoughts on social media. Your feedback helps us improve and grow!

📧 Send us feedback on what we can improve at feedback@opscale.co. We value your input to make our tools even better for everyone.

🙏 Get involved by actively contributing to our open-source repositories. Your participation benefits the entire community and helps push the boundaries of what’s possible.

💼 Hire us if you need custom dashboards, admin panels, internal tools or MVPs tailored to your business. With our expertise, we can help you systematize operations or enhance your existing product. Contact us at hire@opscale.co to discuss your project needs.

Thanks for helping Opscale continue to scale! 🚀

Description

Secure your Nova resources with roles and permissions.

One of the most basic needs for a dashboard is differentiated user access, allowing each profile to manage and view specific information. Confidently manage access to your data with roles and permissions.

Authorization demo

Installation

Latest Version on Packagist

You can install the package in to a Laravel app that uses Nova via composer:

composer require opscale-co/nova-authorization

Next up, you must register the tool with Nova. This is typically done in the tools method of the NovaServiceProvider.

// in app/Providers/NovaServiceProvider.php
// ...
public function tools()
{
    return [
        // ...
        new \Opscale\NovaAuthorization\Tool(),
    ];
}

This package uses Spatie Permissions internally to manage roles and permissions structure. Follow the installation instructions for this package.

Then modify the following items in Spatie permissions configuration file (permissions.php):

  • 'permission' => Opscale\NovaAuthorization\Models\Permission::class,
  • 'role' => Opscale\NovaAuthorization\Models\Role::class,
  • 'register_permission_check_method' => false,
  • 'events_enabled' => true,

Important

This packages uses its own cache strategy, so we need to disable the default behavior with register_permission_check_method.

Then add the roles relationship to your User resource:

// in app/Nova/User.php
// ...
use Opscale\NovaAuthorization\Nova\Fields\RoleTag;

public function fields(NovaRequest $request): array
{
    return [
        // ...
        RoleTag::make(__('Roles'))
            ->hideFromIndex(),
    ];
}

Important

Use RoleTag instead of Nova's Tag field for roles. RoleTag uses Spatie's assignRole() and removeRole() methods internally, ensuring that RoleAttached and RoleDetached events are fired. Nova's default Tag field uses sync() directly on the relationship, bypassing the event system and preventing cache invalidation.

Usage

You will see a "Roles" item in your menu by default. You can create your roles here and assign them to users.

You can also automate the initial permissions setup using our built-in commands:

  • php artisan create-permissions to automatically read all your resources and create the related permissions
  • php artisan create-role to create a role assigning the selected permissions
  • php artisan assign-role to assign an existing role for an user
  • php artisan clear-cache to clear the permissions cache for users

Custom policies

This package create a dynamic Policy class for each Model class associated to your Nova app resources. If you want to use authorization for other resources or modify the logic for your resources, you can create your own policy and register it in nova-authorization config file.

Cache

Important

This package caches the permissions for each user, the cache last 24 hours and it's flushed any time a role is attached or detached from an user or a permission is attached or detached from a role.

If you want to avoid caching permission you can disable this behavior in nova-authorization config file.

Testing

npm run test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email development@opscale.co instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

opscale-co/nova-authorization 适用场景与选型建议

opscale-co/nova-authorization 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 435 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 03 月 26 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「package」 「authorization」 「nova」 「tool」 「laravel」 「permission」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 opscale-co/nova-authorization 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 opscale-co/nova-authorization 我们能提供哪些服务?
定制开发 / 二次开发

基于 opscale-co/nova-authorization 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 435
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 14
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-03-26