Shield
Simple, yet powerfull library for Nette Framework that will help you block access of unauthorized visitors when in maintenance mode, all this based on listed IP addresses.
Abandoned
After some usage I came to realize that this tool makes more problems than it solves.
Installation
Best way to install Shield is using composer.
$ composer require juniwalk/shield:~1.3
Usage
Add Shield configuration to your config.neon file.
extensions:
shield: JuniWalk\Shield\DI\ShieldExtension
shield:
enabled: true
debugger: true
autorun: true
actions:
output: "Forbidden! 403"
include: %appDir%/tmp/maintenance.html
redirect: /tmp/maintenance.html
callback: {@service, method} #will receive instance of Shield
abort: 255 #status code
hosts:
- 127.0.0.1 # Local IPv4
- ::1 # Local IPv6
That's it!
Actions
Include
: Include any file you wish.Redirect
: Redirect to given url.Output
: Print out given text directly.Callback
: Given callback will be invoked.Abort
: Code execution is aborted.
You can use all above mentioned actions one time, but do not use Output
and Redirect
in that order as headers will be send and redirect will fail. You can also leave the action empty to take no action.
Abort
action is called automatically with status code 0 if you don't add it yourself.
-
v1.3.2 Released version 1.3.2
What's new in this version?
- Fixed compatibility with Nette ~2.2
- Fixed Shield icon for older Tracy (<2.3)
- Switched to standard prefixed service name
Visit changelog
-
v1.3.1 Released version 1.3.1
What's new in this version?
- Version 1.3 needs Nette 2.3, fixed composer.
Visit changelog
-
v1.3.0 Released version 1.3.0
What's new in this version?
- Completely rewritten.
- Decreased coupling on other classes.
- Removed dependency on juniwalk/common.
- Improved actions handling
- Actions were renamed. (BC break)
- Improved code quality and tests.
Visit changelog
-
v1.2.10 Released version 1.2.10
What's new in this version?
- Decreased size of the icon to fit nicely in Tracy.
Visit changelog
-
v1.2.9 Released version 1.2.9
What's new in this version?
- Changed color of the icon.
Visit changelog
-
v1.2.8 Released version 1.2.8
What's new in this version?
- Small improvement, added padding.
Visit changelog
-
v1.2.7 Released version 1.2.7
What's new in this version?
- Switched to SVG icon, ready for Nette 2.3
Visit changelog
-
v1.2.6 Released version 1.2.6
What's new in this version?
- Leveraged new additions to juniwalk/common.
Shield::takeAction()
now throw AbortException as it should.
Visit changelog
-
v1.2.5 Released version 1.2.5
What's new in this version?
- Fixed method name after update to juniwalk/common.
Visit changelog
-
v1.2.4 Released version 1.2.4
What's new in this version?
- Added dependency on juniwalk/Common package.
- Config switched to use Container.
- ErrorException switched to common declaration.
- Added one more test.
Visit changelog
-
v1.2.3 Released version 1.2.3
What's new in this version?
- few code adjustments and tiny bug fixes
- Added new tests, code coverage raised from 64% to 95%!
Visit changelog
-
v1.2.2 Released version 1.2.2
What's new in this version?
- few code adjustments
- As of this release, we will honor semantic versioning
Visit changelog
-
v1.2-patch.1 Released version 1.2-patch.1
What's new in this version?
- critical bug fixes
Visit changelog
-
v1.0 Released version 1.0
Very first version of Shield library.
-
v1.2 Released version 1.2
What's new in this version:
- Action handling has been moved out into standalone class ShieldAction
- There is now possibility of multiple actions.
- Changed the ways actions are defined in config. (BC break)
- Removed Shield::TASK_NONE. Just don't define any action to do nothing.
- Renamed action constants. Check possible actions (BC break)
Visit changelog
-
v1.1 Released version 1.1
Main changes in this release:
- Shield now executes desired action before terminating the script.
- Switched to MIT license
- PSR-1 and PSR-2 compliant code
- Decoupled tracy panel logic into
ShieldPanel
class - Shield is now run automatically, no need to add additional code besides config!
- Library has now automated tests.
- Shield no longer fiddles with Tracy\Debugger settings
Visit changelog