{"id":14974613,"url":"https://github.com/silvanite/brandenburg","last_synced_at":"2025-10-06T15:21:08.409Z","repository":{"id":21929993,"uuid":"94466469","full_name":"Silvanite/brandenburg","owner":"Silvanite","description":"Laravel Authentication Package","archived":false,"fork":false,"pushed_at":"2022-02-10T06:34:54.000Z","size":148,"stargazers_count":95,"open_issues_count":10,"forks_count":24,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-06T00:09:24.044Z","etag":null,"topics":["acl","auth","authentication","authorisation","authorization","laravel","laravel-5-package","laravel-framework","laravel55","permissions","php","roles","users"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Silvanite.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-06-15T18:12:34.000Z","updated_at":"2025-01-15T07:57:39.000Z","dependencies_parsed_at":"2022-08-07T10:01:20.926Z","dependency_job_id":null,"html_url":"https://github.com/Silvanite/brandenburg","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Silvanite%2Fbrandenburg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Silvanite%2Fbrandenburg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Silvanite%2Fbrandenburg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Silvanite%2Fbrandenburg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Silvanite","download_url":"https://codeload.github.com/Silvanite/brandenburg/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247415967,"owners_count":20935387,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["acl","auth","authentication","authorisation","authorization","laravel","laravel-5-package","laravel-framework","laravel55","permissions","php","roles","users"],"created_at":"2024-09-24T13:50:48.850Z","updated_at":"2025-10-06T15:21:03.360Z","avatar_url":"https://github.com/Silvanite.png","language":"PHP","readme":"# Brandenburg\n\nLaravel Authorization Package\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/Silvanite/brandenburg.svg?style=for-the-badge)](https://packagist.org/packages/silvanite/brandenburg)\n[![Build Status](https://img.shields.io/travis/Silvanite/brandenburg/master.svg?style=for-the-badge)](https://travis-ci.org/Silvanite/brandenburg)\n\nA opinionated Authorization package to closely integrate with standard Laravel Gates. It differs from other authorization packages by using hard-coded permissions defined within gate policies, rather than duplicating them within the Database.\n\nTLDR; This package provides Users with Roles which are granted access to permissions (Laravel Gates).\n\n## Package maintenance\n\nUnfortunately I am no longer actively working in the Laravel ecosystem and as such am unable to maintian this package. If anyone would like to take over the maintenance of the package please get in touch (open an issue or contact me on [Twitter](https://twitter.com/m2de_io)).\n\n## Version compatibility\n\n| Laravel | Brandenburg |\n| ------- | ----------- |\n| \u003c=5.7.x | 1.1.x       |\n| \u003e=5.8.x | 1.2.x       |\n| ^6.0    | 1.3.x       |\n| ^7.0    | 1.4.x       |\n| ^8.0    | 1.5.x       |\n\n## Installation\n\n```sh\ncomposer require silvanite/brandenburg\n```\n\nThis package uses auto-loading in Laravel 5.5 of both the service provider and the `BrandenburgPolicy` Facade\n\nFor Laravel 5.1 - 5.4 load the Service Provider and Facade.\n\n```php\n// config/app.php\n'providers' =\u003e [\n    ...\n    Silvanite\\Brandenburg\\Providers\\BrandenburgServiceProvider::class,\n];\n\n'aliases' =\u003e [\n    ...\n    'BrandenburgPolicy' =\u003e Silvanite\\Brandenburg\\Facades\\PolicyFacade::class,\n],\n```\n\nThree additional tables are required to enable User Roles. These will be installed automatically when you run the migrations. See the migration in this repository's source code for details about the tables created.\n\n```sh\nphp artisan migrate\n```\n\nIf you are not going to use Brandenburg's default migrations, you should change the `ignoreMigrations` option in the configuration file. You may export the default migrations using:\n\n```sh\nphp artisan vendor:publish --tag=brandenburg-config\n```\n\n## Usage\n\nThis package provides two traits. The main trait is intended for your user model which enabled model relationships.\n\n```php\nuse Silvanite\\Brandenburg\\Traits\\HasRoles;\n\nclass User\n{\n    use HasRoles;\n    ...\n}\n```\n\nThe second Trait `ValidatesPermissions` can optionally be used in your AuthServiceProvider when writing Gates. It can be used to stop users from getting locked out or to make some permissions optional by allowing access to a permission if no user in the system has been given access to it.\n\n```php\n// AuthServiceProvider.php\n\nif ($this-\u003enobodyHasAccess('create-articles')) {\n    return true;\n};\n\n// Check if the user has access\n...\n```\n\n### Creating Roles\n\nUse the `Silvanite\\Brandenburg\\Role` model to create and manage user roles.\n\n```php\n$editor = Silvanite\\Brandenburg\\Role::create([\n    'name' =\u003e 'Editor',\n    'slug' =\u003e 'editor',\n]);\n```\n\n### Creating Permissions\n\nAll Gates defined within your application will automatically be available as Permissions, there is no need/way to create these specifically in the database. Please see the [Laravel Gates documentation](https://laravel.com/docs/5.5/authorization#writing-gates) for additional information.\n\n### Managing Roles and Permissions\n\nAll permissions are assigned by providing the key defined by your Gate. They can be granted and revoked.\n\n```php\n// Grant access\n$editor-\u003egrant('create-articles');\n\n// Revoke access\n$editor-\u003erevoke('create-articles');\n```\n\nA couple of additional helper methods provide a convenient way to manage permissions.\n\n```php\n// Grant access to a set of permissions and remove all other permissions\n$editor-\u003esetPermissions([\n    'create-articles',\n    'read-articles',\n    'update-articles',\n    'delete-articles',\n]);\n\n// Revoke all permissions\n$editor-\u003erevokeAll();\n```\n\nYou can see which permissions a given role has by accessing the `permissions` attribute.\n\n```php\n$editorPermissions = $editor-\u003epermissions;\n\n// returns ['create-articles', 'read-articles', 'update-articles', 'delete-articles']\n```\n\n### Assigning/Removing Roles\n\nRoles can be assigned/removed directly from the User model (provided the `HasRoles` trait is used). You can either pass in the `Role` model or the slug of the role.\n\n```php\n// Using slug\n$user-\u003eassignRole('editor');\n$user-\u003eremoveRole('editor');\n\n// Using model\nuse Silvanite\\Brandenburg\\Role;\n\n$user-\u003eassignRole(Role::first());\n$user-\u003eremoveRole(Role::first());\n```\n\nThere is also a helper method to sync roles (or you can simply use the eloquent relationship itself).\n\n```php\n$user-\u003esetRolesById([1, 3, 4]);\n\n// Same as\n$user-\u003eroles()-\u003esync([1, 3, 4]);\n```\n\n### Validating Access Rights\n\nWithin your Gate definition you can validate if a given user has access to a specific permission, which will be based on the user Role(s).\n\n```php\n$canCreateArticle = $user-\u003ehasRoleWithPermission('create-articles');\n```\n\nOutside of your Gate definitions you should use the standard Laravel Gate methods and helpers to check if a user has access rights. See the [Laravel Documentation](https://laravel.com/docs/5.5/authorization#authorizing-actions-via-gates) for more details.\n\n## Contributing\n\n1. Fork it!\n2. Create your feature branch: `git checkout -b my-new-feature`\n3. Commit your changes: `git commit -am 'Add some feature'`\n4. Run the tests: `./vendor/bin/phpunit`\n5. Push to the branch: `git push origin my-new-feature`\n6. Submit a pull request\n\n## Support\n\nIf you require any support please contact me on [Twitter](https://twitter.com/m2de_io) or open an issue on this repository.\n\n## License\n\nGPL\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsilvanite%2Fbrandenburg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsilvanite%2Fbrandenburg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsilvanite%2Fbrandenburg/lists"}