Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
divineniiquaye committed May 4, 2020
1 parent cf069bf commit c4565fb
Show file tree
Hide file tree
Showing 96 changed files with 9,768 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/Tests export-ignore
/phpunit.xml.dist export-ignore
/.gitignore export-ignore
18 changes: 18 additions & 0 deletions .github/ISSUE_TEMPLATE/Bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
name: "🐛 Bug Report"
about: "If something isn't working as expected 🤔"

---
## Version: ?.?.?

### Bug Description
... A clear and concise description of what the bug is. A good bug report shouldn't leave others needing to chase you up for more information.

### Steps To Reproduce
... If possible a minimal demo of the problem ...

### Expected Behavior
... A clear and concise description of what you expected to happen.

### Possible Solution
... Only if you have suggestions on a fix for the bug
9 changes: 9 additions & 0 deletions .github/ISSUE_TEMPLATE/Feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
name: "🚀 Feature Request"
about: "I have a suggestion (and may want to implement it) 🙂"

---

- Is your feature request related to a problem? Please describe.
- Explain your intentions.
- It's up to you to make a strong case to convince the project's developers of the merits of this feature.
26 changes: 26 additions & 0 deletions .github/ISSUE_TEMPLATE/Support_us.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
name: "❤️ Support us"
about: "If you would like to support our efforts in maintaining this project 🙌"

---

> ## https://biurad.com/donate
## Help support Biurad Lap Agency!

We are developing over one hundred project in 2years. In order to make your life more comfortable. Biurad cares about the safety of your proejct. Biurad saves you time. And gives job opportunities.

Biurad projects earns you money. And is absolutely free.

To ensure future development and improving the documentation, we need your donation.

Whether you are chief of IT company which benefits from Biurad, or developer who goes for advice on our forum, or any other person interested in our work. If you like Biurad projects, [please make a donation now](https://biurad.com/donate).

Thank you!

> # Pledges ($5 - $50 one-time-payment)
- Ankrah Elvis
- Opare Emmanuel Asare
- Oduru Kelvin Ansong
- [AlbDroid Movies](https://movies.albdroid.com)
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
composer.lock
phpunit.xml.dist
vendor/
20 changes: 20 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
tools:
php_mess_detector: true
php_analyzer:
config:
parameter_reference_check: { enabled: false }
checkstyle: { enabled: false, no_trailing_whitespace: true, naming: { enabled: true, local_variable: '^[a-z][a-zA-Z0-9]*$', abstract_class_name: '^[A-Z][a-zA-Z0-9]*|Abstract|Factory$', utility_class_name: 'Utils?$', constant_name: '^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$', property_name: '^[a-z][a-zA-Z0-9]*$', method_name: '^(?:[a-z]|__)[a-zA-Z0-9]*$', parameter_name: '^[a-z][a-zA-Z0-9]*$', interface_name: '^[A-Z][a-zA-Z0-9]*Interface$', type_name: '^[A-Z][a-zA-Z0-9]*$', exception_name: '^[A-Z][a-zA-Z0-9]*Exception$' } }
check_calls: { enabled: true, too_many_arguments: true, missing_argument: true, argument_type_checks: lenient }
verify_php_doc_comments: { enabled: false, parameters: false, return: false, suggest_more_specific_types: false, ask_for_return_if_not_inferrable: false, ask_for_param_type_annotation: false }
check_usage_context: { enabled: true, foreach: { value_as_reference: true, traversable: true } }
phpunit_checks: { enabled: false }
use_statement_fixes: { enabled: true, remove_unused: true, preserve_multiple: false, preserve_blanklines: false, order_alphabetically: false }
php_code_sniffer: true
sensiolabs_security_checker: true
php_cpd: true
php_loc: true
php_pdepend: true
external_code_coverage: true
filter:
paths:
- src/*
35 changes: 35 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
language: php
sudo: false

matrix:
include:
- php: 7.2
- php: 7.3
- php: 7.4
- php: nightly
allow_failures:
- php: nightly
fast_finish: true

cache:
directories:
- $HOME/.composer/cache

install:
- if [ $TRAVIS_PHP_VERSION = 'nightly' ]; then composer install --prefer-dist --ignore-platform-reqs; else composer install --prefer-dist; fi

before_install:
- composer self-update
- phpenv config-rm xdebug.ini || true
- composer require phpunit/phpunit ^8.5

before_script:
- composer update $COMPOSER_FLAGS --prefer-dist

script:
- stty cols 120
- mkdir -p build/logs
- vendor/bin/phpunit --coverage-clover=clover.xml

after_script:
- if [ "$SCRUTINIZER" == 1 ]; then wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover coverage.xml; fi
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Changelog

All notable changes to `biurad/biurad-security` will be documented in this file.

## 0.1.0 - 2020-05-04

- First release
30 changes: 30 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Contributing

Contributions are **welcome** and will be fully **credited**.

We accept contributions via Pull Requests on [Github](https://github.com/biurad/biurad-security).

## Pull Requests

- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](http://pear.php.net/package/PHP_CodeSniffer).

- **Add tests!** - Your patch won't be accepted if it doesn't have tests.

- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date.

- **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option.

- **Create feature branches** - Don't ask us to pull from your master branch.

- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.

- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](http://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting.

## Running Tests

``` bash
$ composer test
```


**Happy coding**!
68 changes: 67 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,67 @@
# security-manager
# A Security system that provides authentication, authorization and a role-based access control management plus more

Symfony's security system is incredibly powerful, but it can also be confusing to set up and use. Not only that, It requires a whole lot of packages from symfony which is not mostly un used. This package utilizes Symfony security system as standalone, but for now, only supports BiuradPHP and Nette Framework projects.


**`Please note that you can get the documentation for this dependency on symfony website, security-http`**

## Installation

The recommended way to install Security Manager is via Composer:

```bash
composer require biurad/biurad-security
```

It requires PHP version 7.2 and supports PHP up to 7.4. The dev-master version requires PHP 7.3.

## Changelog

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

## Contributing

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

## Testing

To run the tests you'll have to start the included node based server if any first in a separate terminal window.

With the server running, you can start testing.

```bash
vendor/bin/phpunit
```

## Security

If you discover any security related issues, please report using the issue tracker.
use our example [Issue Report](.github/ISSUE_TEMPLATE/Bug_report.md) template.

## Want to be listed on our projects website

You're free to use this package, but if it makes it to your production environment we highly appreciate you sending us a message on our website, mentioning which of our package(s) you are using.

Post Here: [Project Patreons - https://patreons.biurad.com](https://patreons.biurad.com)

We publish all received request's on our website;

## Credits

- [Divine Niiquaye](https://github.com/divineniiquaye)
- [All Contributors](https://biurad.com/projects/biurad-security/contributers)

## Support us

`Biurad Lap` is a technology agency in Accra, Ghana. You'll find an overview of all our open source projects [on our website](https://biurad.com/opensource).

Does your business depend on our contributions? Reach out and support us on to build more project's. We want to build over one hundred project's in two years. [Support Us](https://biurad.com/donate) achieve our goal.

Reach out and support us on [Patreon](https://www.patreon.com/biurad). All pledges will be dedicated to allocating workforce on maintenance and new awesome stuff.

[Thanks to all who made Donations and Pledges to Us.](.github/ISSUE_TEMPLATE/Support_us.md)

## License

The BSD-3-Clause . Please see [License File](LICENSE.md) for more information.

60 changes: 60 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"name": "biurad/biurad-security",
"type": "library",
"description": "A Security system that provides authentication, authorization and a role-based access control management plus more",
"keywords": [
"nette",
"authentication",
"authorization",
"ACL",
"biuradphp",
"php7"
],
"homepage": "https://www.biurad.com",
"license": "BSD-3-Clause",
"authors": [
{
"name": "Divine Niiquaye Ibok",
"email": "divineibok@gmail.com"
},
{
"name": "Biurad Lap Community",
"homepage": "https://biurad.com/contributors"
}
],
"require": {
"php": "^7.2.5",
"psr/log": "~1.0",
"biurad/biurad-http": "^0.1",
"biurad/biurad-sessions": "^0.1",
"biurad/flight-routing-bridge": "^0.1",
"symfony/security-core": "^4.4|^5.0",
"symfony/security-csrf": "^4.4|^5.0"
},
"require-dev": {
"biurad/nette-di-bridge": "^0.1",
"phpunit/phpunit": "^8.4"
},
"conflict": {
"symfony/security-csrf": "<4.4"
},
"autoload": {
"psr-4": {
"BiuradPHP\\Security\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"autoload-dev": {
"psr-4": {
"BiuradPHP\\Security\\Tests\\": "Tests/"
}
},
"minimum-stability": "dev",
"extra": {
"branch-alias": {
"dev-master": "0.1-dev"
}
}
}
59 changes: 59 additions & 0 deletions src/AccessMap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

declare(strict_types=1);

/*
* This code is under BSD 3-Clause "New" or "Revised" License.
*
* PHP version 7 and above required
*
* @category SecurityManager
*
* @author Divine Niiquaye Ibok <divineibok@gmail.com>
* @copyright 2019 Biurad Group (https://biurad.com/)
* @license https://opensource.org/licenses/BSD-3-Clause License
*
* @link https://www.biurad.com/projects/securitymanager
* @since Version 0.1
*/

namespace BiuradPHP\Security;

use BiuradPHP\Http\Interfaces\RequestMatcherInterface;
use BiuradPHP\Security\Interfaces\AccessMapInterface;
use Psr\Http\Message\ServerRequestInterface as Request;

/**
* AccessMap allows configuration of different access control rules for
* specific parts of the website.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class AccessMap implements AccessMapInterface
{
private $map = [];

/**
* @param RequestMatcherInterface $requestMatcher
* @param array $attributes An array of attributes to pass to the access decision manager (like roles)
* @param string|null $channel The channel to enforce (http, https, or null)
*/
public function add(RequestMatcherInterface $requestMatcher, array $attributes = [], string $channel = null)
{
$this->map[] = [$requestMatcher, $attributes, $channel];
}

/**
* {@inheritdoc}
*/
public function getPatterns(Request $request)
{
foreach ($this->map as $elements) {
if (null === $elements[0] || $elements[0]->matches($request)) {
return [$elements[1], $elements[2]];
}
}

return [null, null];
}
}
Loading

0 comments on commit c4565fb

Please sign in to comment.