Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged documentation from master #78

Merged
merged 55 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
a368f1e
Commit new documentation site
visto9259 Feb 22, 2024
28b80d3
Adding github action to deploy automatically documentation site
visto9259 Feb 22, 2024
c563e66
Fixed link issue in intro.md
visto9259 Feb 22, 2024
cd72e0e
Merge pull request #45 from visto9259/3_docs
visto9259 Feb 22, 2024
a9cc0a3
Fixed base URL
visto9259 Feb 22, 2024
20c67c7
Merge pull request #46 from visto9259/3_docs
visto9259 Feb 22, 2024
87aebe5
Fixed base URL
visto9259 Feb 22, 2024
0752b5c
Merge pull request #47 from visto9259/3_docs
visto9259 Feb 22, 2024
7500563
Fixed base URL case
visto9259 Feb 22, 2024
5a95891
Merge remote-tracking branch 'upstream/3_docs' into 3_docs
visto9259 Feb 22, 2024
0fff079
Added manual workflow dispatch
visto9259 Feb 22, 2024
01b68a1
Fixing baseurl
visto9259 Feb 22, 2024
b162a09
Fixing baseurl
visto9259 Feb 22, 2024
985674b
Fixing baseurl
visto9259 Feb 22, 2024
a55c89b
Fixing baseurl
visto9259 Feb 22, 2024
5cd6936
Fixing baseurl
visto9259 Feb 22, 2024
8ab8973
Fixing baseurl again
visto9259 Feb 22, 2024
7cbcd25
Fixing baseurl again
visto9259 Feb 22, 2024
f695030
Fixing documentation link in README.md
visto9259 Feb 22, 2024
6314c3f
Merge pull request #48 from LM-Commons/3_docs
visto9259 Feb 23, 2024
d5580f4
Fixes #3, #4, #38 and #52
visto9259 Feb 29, 2024
2824801
CHanged ORM SQLite to in-memory storage
visto9259 Feb 29, 2024
294ca12
Update guards.md
visto9259 Mar 1, 2024
759aa8c
Merge pull request #53 from LM-Commons/visto9259-patch-1
visto9259 Mar 1, 2024
92ebb62
Added __toString() method imported from zfr Rbac. Removed deprecation…
visto9259 Mar 1, 2024
fe827f4
Added PermissionInterface interface
visto9259 Mar 1, 2024
d67c7be
Added PermissionInterface interface
visto9259 Mar 1, 2024
2762ce6
Removed locally created Rbac class.
visto9259 Mar 1, 2024
ac13389
Added component installer extra info
visto9259 Mar 4, 2024
699574c
Bump follow-redirects from 1.15.5 to 1.15.6 in /docs
dependabot[bot] Mar 17, 2024
d5ff08d
Bump webpack-dev-middleware from 5.3.3 to 5.3.4 in /docs
dependabot[bot] Mar 24, 2024
d3fb494
Bump express from 4.18.2 to 4.19.2 in /docs
dependabot[bot] Mar 29, 2024
c2248fd
Add renovate.json
renovate[bot] Apr 10, 2024
a66c7df
Merge pull request #58 from LM-Commons/renovate/configure
visto9259 Apr 10, 2024
2387db0
Update docusaurus monorepo to v3.2.1
renovate[bot] Apr 10, 2024
3f71331
Merge pull request #60 from LM-Commons/renovate/docusaurus-monorepo
visto9259 Apr 10, 2024
5c5693d
Merge pull request #56 from LM-Commons/dependabot/npm_and_yarn/docs/e…
visto9259 Apr 10, 2024
685bae5
Merge pull request #54 from LM-Commons/dependabot/npm_and_yarn/docs/f…
visto9259 Apr 10, 2024
aebbd45
Merge pull request #55 from LM-Commons/dependabot/npm_and_yarn/docs/w…
visto9259 Apr 10, 2024
9b73bf9
Updated documentation config and support page for Slack
visto9259 Apr 10, 2024
d4d20ef
Fixed GH workflows to deploy on push to master
visto9259 Apr 10, 2024
7005fa4
Small config changes to test workflows
visto9259 Apr 10, 2024
fcee16c
Merge pull request #62 from visto9259/update-docs
visto9259 Apr 10, 2024
0ee4b33
Update actions/checkout action to v4
renovate[bot] Apr 10, 2024
5b14b56
Merge pull request #63 from LM-Commons/renovate/actions-checkout-4.x
visto9259 Apr 10, 2024
6a007f0
Update actions/setup-node action to v4
renovate[bot] Apr 10, 2024
d975243
Merge pull request #64 from LM-Commons/renovate/actions-setup-node-4.x
visto9259 Apr 10, 2024
efa8fb6
Update peaceiris/actions-gh-pages action to v4
renovate[bot] Apr 10, 2024
f4114ae
Merge pull request #65 from LM-Commons/renovate/peaceiris-actions-gh-…
visto9259 Apr 10, 2024
b200a5c
Updated README.md in docs
visto9259 Apr 12, 2024
5423e76
Merge pull request #71 from visto9259/update-docs-readme
visto9259 Apr 12, 2024
da245a6
Updated badges and Slack chat in README.md
visto9259 Apr 22, 2024
340de69
Merge pull request #73 from visto9259/update_readme
visto9259 Apr 22, 2024
01f9e66
Merge branch 'refs/heads/master' into 4.x-dev-cherry-pick
visto9259 May 23, 2024
4886825
Updated badges and Slack chat in README.md
visto9259 May 23, 2024
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
48 changes: 48 additions & 0 deletions .github/workflows/deploy-gh-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Build and Deploy to GitHub Pages

defaults:
run:
shell: bash
working-directory: ./docs

on:
push:
branches:
- 'master'
paths:
- 'docs/**'
workflow_dispatch:


jobs:
deploy:
name: Build and Deploy to GitHub Pages
runs-on: ubuntu-latest
defaults:
run:
shell: bash
working-directory: ./docs
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
cache: yarn
cache-dependency-path: docs/yarn.lock
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Build website
run: yarn build
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
# Build output to publish to the `gh-pages` branch:
publish_dir: ./docs/build
# The following lines assign commit authorship to the official
# GH-Actions bot for deploys to `gh-pages` branch:
# https://github.com/actions/checkout/issues/13#issuecomment-724415212
# The GH actions bot is used by default if you didn't specify the two fields.
# You can swap them out with your own user credentials.
user_name: github-actions[bot]
user_email: 41898282+github-actions[bot]@users.noreply.github.com
32 changes: 32 additions & 0 deletions .github/workflows/test-deploy-gh-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Build GitHub Pages on PRs No Deploy

defaults:
run:
shell: bash
working-directory: ./docs

on:
push:
paths:
- 'docs/**'
pull_request:
paths:
- 'docs/**'
# Review gh actions docs if you want to further define triggers, paths, etc
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on

jobs:
test-deploy:
name: Build GitHub Pages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
cache: yarn
cache-dependency-path: docs/yarn.lock
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Test build website
run: yarn build
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# LmcRbacMvc

[![Build](https://github.com/visto9259/LmcRbacMvc/actions/workflows/build_test.yml/badge.svg)](https://github.com/visto9259/LmcRbacMvc/actions/workflows/build_test.yml)
[![Version](https://poser.pugx.org/lm-commons/lmc-rbac-mvc/version)](//packagist.org/packages/lm-commons/lmc-rbac-mvc)
[![Total Downloads](https://poser.pugx.org/lm-commons/lmc-rbac-mvc/downloads)](//packagist.org/packages/lm-commons/lmc-rbac-mvc)
[![License](https://poser.pugx.org/lm-commons/lmc-rbac-mvc/license)](//packagist.org/packages/lm-commons/lmc-rbac-mvc)
[![Build](https://github.com/lm-commons/LmcRbacMvc/actions/workflows/build_test.yml/badge.svg)](https://github.com/lm-commons/LmcRbacMvc/actions/workflows/build_test.yml)
<!-- ![Gitter](https://badges.gitter.im/LM-Commons/community.svg)](https://gitter.im/LM-Commons/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) -->
[![Coverage Status](https://coveralls.io/repos/github/LM-Commons/LmcRbacMvc/badge.svg?branch=master)](https://coveralls.io/github/LM-Commons/LmcRbacMvc?branch=master)
<!-- [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/LM-Commons/LmcRbacMvc/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/LM-Commons/LmcRbacMvc/?branch=master) -->
![Dynamic JSON Badge](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fapi.github.com%2Frepos%2Flm-commons%2Flmcrbacmvc%2Fproperties%2Fvalues&query=%24%5B%3A1%5D.value&label=Maintenance%20Status)
[![Static Badge](https://img.shields.io/badge/Chat_on-Slack-blue)](https://join.slack.com/t/lm-commons/shared_invite/zt-2gankt2wj-FTS45hp1W~JEj1tWvDsUHQ)

Role-based access control module to provide additional features on top of Laminas\Permissions\Rbac
Role-based access control module to provide additional features on top of Zend\Permissions\Rbac

## Requirements

Expand Down Expand Up @@ -46,11 +46,12 @@ the `lmc_rbac.global.php.dist` file to your `config/autoload` folder.

## Documentation

The official documentation is available in the [/docs](/docs) folder.
The official documentation is available [here](https://lm-commons.github.io/LmcRbacMvc).

You can also find some Doctrine entities in the [/data](/data) folder that will help you to more quickly take advantage
of LmcRbac.

## Support

- File issues at https://github.com/LM-Commons/LmcRbacMvc/issues.
- Ask questions in the [LM-Commons Slack](https://join.slack.com/t/lm-commons/shared_invite/zt-2gankt2wj-FTS45hp1W~JEj1tWvDsUHQ) chat.
7 changes: 6 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"laminas/laminas-i18n": "^2.7",
"laminas/laminas-serializer": "^2.2",
"laminas/laminas-view": "^2.12",
"phpunit/phpunit": "9.5.21",
"phpunit/phpunit": "10.5.11",
"squizlabs/php_codesniffer": "^3.5.5",
"php-coveralls/php-coveralls": "^2.2",
"phpspec/prophecy-phpunit": "^2.0",
Expand All @@ -71,6 +71,11 @@
"LmcRbacMvcTest\\": "tests"
}
},
"extra": {
"laminas": {
"module": "LmcRbacMvc"
}
},
"scripts": {
"test": "phpunit",
"test-coverage": "phpunit --coverage-clover ./build/logs/clover.xml --exclude-group Functional",
Expand Down
7 changes: 6 additions & 1 deletion config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
'LmcRbacMvc\Guards' => \LmcRbacMvc\Factory\GuardsFactory::class,

/* Factories that map to a class */
\Rbac\Rbac::class => \LmcRbacMvc\Factory\RbacFactory::class,
\LmcRbacMvc\Assertion\AssertionPluginManager::class => \LmcRbacMvc\Factory\AssertionPluginManagerFactory::class,
// TODO Remove RbacCollector once it is moved to a separate library
\LmcRbacMvc\Collector\RbacCollector::class => \Laminas\ServiceManager\Factory\InvokableFactory::class,
\LmcRbacMvc\Guard\GuardPluginManager::class => \LmcRbacMvc\Factory\GuardPluginManagerFactory::class,
\LmcRbacMvc\Identity\AuthenticationIdentityProvider::class => \LmcRbacMvc\Factory\AuthenticationIdentityProviderFactory::class,
Expand Down Expand Up @@ -64,6 +64,10 @@
]
],

/*
* Developer tools are now provided by the companion module LmcRbacMvcDevTools
* You can still use the config below but you are encouraged to use the new module
*
'laminas-developer-tools' => [
'profiler' => [
'collectors' => [
Expand All @@ -76,6 +80,7 @@
],
],
],
*/

'lmc_rbac' => [
// Guard plugin manager
Expand Down
85 changes: 45 additions & 40 deletions data/FlatRole.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,21 @@
* and is licensed under the MIT license.
*/


use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Laminas\Permissions\Rbac\RoleInterface;
use Doctrine\ORM\Mapping as ORM;
use Rbac\Role\RoleInterface;
use LmcRbac\Permission\PermissionInterface;

/**
* There is no specific implementation of a flot role.
* A flot role is a simple utilization of the Laminas\Permission\Rbac\Role without children
*/


/**
* @ORM\Entity
* @ORM\Table(name="roles")
* @ORM\Table(name="flat_roles")
*/
class FlatRole implements RoleInterface
{
Expand All @@ -32,83 +39,81 @@ class FlatRole implements RoleInterface
*
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
* @ORM\GeneratedValue
*/
protected $id;
private ?int $id;

/**
* @var string|null
*
* @ORM\Column(type="string", length=48, unique=true)
* @ORM\Column(type="string", length=32, unique=true)
*/
protected $name;
protected ?string $name;

/**
* @var PermissionInterface[]|\Doctrine\Common\Collections\Collection
*
* @ORM\ManyToMany(targetEntity="Permission", indexBy="name", fetch="EAGER", cascade={"persist"})
* @var Collection
* @ORM\ManyToMany(targetEntity="Permission", indexBy="name", cascade={"persist"}, fetch="EAGER")
*/
protected $permissions;
protected Collection $permissions;

/**
* Init the Doctrine collection
*/
public function __construct()
public function __construct($name)
{
$this->name = (string) $name;
$this->permissions = new ArrayCollection();
}

/**
* Get the role identifier
*
* @return int
* @return int|null
*/
public function getId()
public function getId(): ?int
{
return $this->id;
}

/**
* Set the role name
* Add a permission
*
* @param string $name
* @param string $name
* @return void
*/
public function setName($name)
public function addPermission(string $name):void
{
$this->name = (string) $name;
$permission = new \LmcRbacMvcTest\Asset\Permission($name);

$this->permissions[$name] = $permission;
}

/**
* Get the role name
*
* @return string
*/
public function getName()
public function getName(): string
{
return $this->name;
}

/**
* {@inheritDoc}
*/
public function addPermission($permission)
public function hasPermission(string $name): bool
{
if (is_string($permission)) {
$permission = new Permission($permission);
}
return isset($this->permissions[$name]);
}

$this->permissions[(string) $permission] = $permission;
public function addChild(RoleInterface $child): void
{
// Do nothing
}

/**
* {@inheritDoc}
*/
public function hasPermission($permission)
public function getChildren(): iterable
{
// This can be a performance problem if your role has a lot of permissions. Please refer
// to the cookbook to an elegant way to solve this issue
return [];
}

return isset($this->permissions[(string) $permission]);
public function addParent(RoleInterface $parent): void
{
// Do nothing
}

public function getParents(): iterable
{
return [];
}
}
33 changes: 20 additions & 13 deletions data/Permission.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,27 @@
* and is licensed under the MIT license.
*/


use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use LmcRbac\Permission\PermissionInterface;

/**
* @ORM\Entity
* @ORM\Table(name="permissions")
*/
class Permission implements PermissionInterface
class Permission
{
/**
* @var int|null
*
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
private ?int $id;

/**
* @var string|null
*
* @ORM\Column(type="string", length=128, unique=true)
* @ORM\Column(type="string", length=32, unique=true)
*/
protected $name;
private ?string $name;

/**
* Constructor
Expand All @@ -52,18 +49,28 @@ class Permission implements PermissionInterface
/**
* Get the permission identifier
*
* @return int
* @return int|null
*/
public function getId()
public function getId(): ?int
{
return $this->id;
}

/**
* {@inheritDoc}
* Get the permission name
*
* @return string|null
*/
public function __toString()
public function getName(): ?string
{
return $this->name;
}

/**
*
*/
public function __toString(): string
{
return $this->getName();
}
}
2 changes: 1 addition & 1 deletion data/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
These files are only provided as-in, and are not part of LmcRbac. They provide you some basic Doctrine ORM
These files are only provided as-in, and are not part of LmcRbacMvc. They provide you some basic Doctrine ORM
entities that you can use as a starting point.

## Flat role or hierarchical role?
Expand Down
Loading