Skip to content

Commit 033513c

Browse files
authored
Merge pull request #31 from dotkernel/issue-26
updated docs, workflows, security, composer.json
2 parents 89cb743 + 521e9e1 commit 033513c

File tree

13 files changed

+233
-154
lines changed

13 files changed

+233
-154
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: "Continuous Integration"
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
tags:
8+
9+
jobs:
10+
ci:
11+
uses: laminas/workflow-continuous-integration/.github/workflows/[email protected]

.github/workflows/cs-tests.yml

Lines changed: 0 additions & 47 deletions
This file was deleted.

.github/workflows/docs-build.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: docs-build
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
8+
jobs:
9+
build-deploy:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Build Docs
13+
uses: dotkernel/documentation-theme/github-actions/docs@main
14+
env:
15+
DEPLOY_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/static-analysis.yml

Lines changed: 0 additions & 47 deletions
This file was deleted.

.github/workflows/unit-tests.yml

Lines changed: 0 additions & 48 deletions
This file was deleted.

README.md

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# dot-rbac-guard
22

3-
Defines authorization guards that authorize users to access certain parts of an application based on various criteria.
4-
If the authorization service can be used to check authorization on a narrow level, the guards are meant to work as gateways to bigger parts of an application.
5-
Usually, you'll want to use both methods in an application for additional security.
3+
Defines authorization guards that authorize users for accessing certain parts of an application based on various criteria. If the authorization service can be used to check authorization on a narrow level, the guards are meant to work as gateways to bigger parts of an application. Usually, you'll want to use both methods in an application for increased security.
64

75
![OSS Lifecycle](https://img.shields.io/osslifecycle/dotkernel/dot-rbac-guard)
86
![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-rbac-guard/3.4.3)
@@ -12,7 +10,7 @@ Usually, you'll want to use both methods in an application for additional securi
1210
[![GitHub stars](https://img.shields.io/github/stars/dotkernel/dot-rbac-guard)](https://github.com/dotkernel/dot-rbac-guard/stargazers)
1311
[![GitHub license](https://img.shields.io/github/license/dotkernel/dot-rbac-guard)](https://github.com/dotkernel/dot-rbac-guard/blob/3.4.0/LICENSE.md)
1412

15-
[![Build Static](https://github.com/dotkernel/dot-rbac-guard/actions/workflows/static-analysis.yml/badge.svg?branch=3.0)](https://github.com/dotkernel/dot-rbac-guard/actions/workflows/static-analysis.yml)
13+
[![Build Static](https://github.com/dotkernel/dot-rbac-guard/actions/workflows/continuous-integration.yml/badge.svg?branch=3.0)](https://github.com/dotkernel/dot-rbac-guard/actions/workflows/continuous-integration.yml)
1614
[![codecov](https://codecov.io/gh/dotkernel/dot-rbac-guard/graph/badge.svg?token=HB718GSIKS)](https://codecov.io/gh/dotkernel/dot-rbac-guard)
1715

1816
[![SymfonyInsight](https://insight.symfony.com/projects/ebbe47ef-852a-47bd-94d4-9e1725a85377/big.svg)](https://insight.symfony.com/projects/ebbe47ef-852a-47bd-94d4-9e1725a85377)
@@ -25,17 +23,16 @@ Run the following command in your project's root directory
2523
$ composer require dotkernel/dot-rbac-guard
2624
```
2725

28-
Please note that this module is built around the authorization service defined in module dot-rbac.
29-
Running the above command will also install that package. You'll have to first configure dot-rbac before using this module.
26+
Please note that this module is built around the authorization service defined in module dot-rbac. Running the above command will also install that package. You'll have to first configure dot-rbac before using this module.
3027

3128
## Configuration
3229

3330
As with many DotKernel modules, we focus on the configuration based approach of customizing the module for your needs.
3431

35-
After installing, make sure you merge the module's `ConfigProvider` with your application's config to make sure required dependencies and default module configuration is registered.
36-
Create a configuration file for this module in your 'config/autoload' folder
32+
After installing, merge the module's `ConfigProvider` with your application's config to make sure required dependencies and default module configuration are registered. Create a configuration file for this module in your 'config/autoload' folder.
33+
34+
### authorization-guards.global.php
3735

38-
##### authorization-guards.global.php
3936
```php
4037
return [
4138
'dot_authorization' => [
@@ -137,9 +134,10 @@ return [
137134
## Register the RbacGuardMiddleware in the pipe
138135

139136
The last step in order to use this package is to register the middleware. This middleware triggers the authorization event.
140-
You MUST insert this middleware between the routing middleware and the dispatch middleware of the application, because the guards need the RouteResult in order to get the matched route and params.
137+
You MUST insert this middleware between the routing middleware and the dispatch middleware of the application, because the guards need the `RouteResult` in order to get the matched route and params.
138+
139+
### middleware-pipeline.global.php
141140

142-
##### middleware-pipeline.global.php
143141
```php
144142
//...
145143

SECURITY.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Security Policy
2+
3+
## Supported Versions
4+
5+
6+
| Version | Supported | PHP Version |
7+
|---------|--------------------|------------------------------------------------------------------------------------------------------------------|
8+
| 3.x | :white_check_mark: | ![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-rbac-guard/3.4.3) |
9+
| <= 2.x | :x: | |
10+
11+
12+
## Reporting Potential Security Issues
13+
14+
If you have encountered a potential security vulnerability in this project,
15+
please report it to us at <[email protected]>. We will work with you to
16+
verify the vulnerability and patch it.
17+
18+
When reporting issues, please provide the following information:
19+
20+
- Component(s) affected
21+
- A description indicating how to reproduce the issue
22+
- A summary of the security vulnerability and impact
23+
24+
We request that you contact us via the email address above and give the
25+
project contributors a chance to resolve the vulnerability and issue a new
26+
release prior to any public exposure; this helps protect the project's
27+
users, and provides them with a chance to upgrade and/or update in order to
28+
protect their applications.
29+
30+
31+
## Policy
32+
33+
If we verify a reported security vulnerability, our policy is:
34+
35+
- We will patch the current release branch, as well as the immediate prior minor
36+
release branch.
37+
38+
- After patching the release branches, we will immediately issue new security
39+
fix releases for each patched release branch.
40+

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@
4747
"config": {
4848
"sort-packages": true,
4949
"allow-plugins": {
50-
"dealerdirect/phpcodesniffer-composer-installer": true
50+
"dealerdirect/phpcodesniffer-composer-installer": true,
51+
"laminas/laminas-dependency-plugin": false
5152
}
5253
},
5354
"scripts": {

docs/book/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../README.md

docs/book/v3/configuration.md

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# Configuration
2+
3+
As with many DotKernel modules, we focus on the configuration based approach of customizing the module for your needs.
4+
5+
After installing, merge the module's `ConfigProvider` with your application's config to make sure required dependencies and default module configuration are registered. Create a configuration file for this module in your 'config/autoload' folder.
6+
7+
## authorization-guards.global.php
8+
9+
```php
10+
return [
11+
'dot_authorization' => [
12+
13+
//define how it will treat non-matching guard rules, allow all by default
14+
'protection_policy' => \Dot\Rbac\Guard\GuardInterface::POLICY_ALLOW,
15+
16+
'event_listeners' => [
17+
[
18+
'type' => 'class or service name of the listener',
19+
'priority' => 1,
20+
],
21+
],
22+
23+
//define custom guards here
24+
'guard_manager' => [],
25+
26+
//register custom guards providers here
27+
'guards_provider_manager' => [],
28+
29+
//define which guards provider to use, along with its configuration
30+
//the guards provider should know how to build a list of GuardInterfaces based on its configuration
31+
'guards_provider' => [
32+
'type' => 'ArrayGuards',
33+
'options' => [
34+
'guards' => [
35+
[
36+
'type' => 'Route',
37+
'options' => [
38+
'rules' => [
39+
'premium' => ['admin'],
40+
'login' => ['guest'],
41+
'logout' => ['admin', 'user', 'viewer'],
42+
'account' => ['admin', 'user'],
43+
'home' => ['*'],
44+
]
45+
]
46+
],
47+
[
48+
'type' => 'RoutePermission',
49+
'options' => [
50+
'rules' => [
51+
'premium' => ['premium'],
52+
'account' => ['my-account'],
53+
'logout' => ['only-logged'],
54+
]
55+
]
56+
],
57+
[
58+
'type' => 'Controller',
59+
'options' => [
60+
'rules' => [
61+
[
62+
'route' => 'controller route name',
63+
'actions' => [//list of actions to apply, or empty array for all actions],
64+
//by default, authorization pass if all permissions are present(AND)
65+
'roles' => [//list of roles to allow],
66+
],
67+
]
68+
]
69+
],
70+
[
71+
'type' => 'ControllerPermission',
72+
'options' => [
73+
'rules' => [
74+
[
75+
'route' => 'controller route name',
76+
'actions' => [//list of actions to apply, or empty array for all actions],
77+
//by default, authorization pass if all permissions are present(AND)
78+
'permissions' => [//list of permissions to allow],
79+
],
80+
[
81+
'route' => 'controller route name',
82+
'actions' => [//list of actions to apply, or empty array for all actions],
83+
'permissions' => [
84+
//permission can be defined in this way too, for all permission type guards
85+
'permissions' => [//list of permissions],
86+
'condition' => \Dot\Rbac\Guard\GuardInterface::CONDITION_OR,
87+
]
88+
]
89+
]
90+
]
91+
]
92+
]
93+
],
94+
],
95+
96+
//overwrite default messages
97+
'messages_options' => [
98+
'messages' => [
99+
//MessagesOptions::UNAUTHORIZED => 'You must sign in first to access the requested content',
100+
//MessagesOptions::FORBIDDEN => 'You don\'t have enough permissions to access the requested content',
101+
]
102+
],
103+
],
104+
];
105+
```

0 commit comments

Comments
 (0)