Skip to content

Commit c3cf5d3

Browse files
committed
Initial commit.
0 parents  commit c3cf5d3

File tree

14 files changed

+925
-0
lines changed

14 files changed

+925
-0
lines changed

.gitattributes

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto
3+
4+
# Custom for Visual Studio
5+
*.cs diff=csharp
6+
*.sln merge=union
7+
*.csproj merge=union
8+
*.vbproj merge=union
9+
*.fsproj merge=union
10+
*.dbproj merge=union
11+
12+
# Standard to msysgit
13+
*.doc diff=astextplain
14+
*.DOC diff=astextplain
15+
*.docx diff=astextplain
16+
*.DOCX diff=astextplain
17+
*.dot diff=astextplain
18+
*.DOT diff=astextplain
19+
*.pdf diff=astextplain
20+
*.PDF diff=astextplain
21+
*.rtf diff=astextplain
22+
*.RTF diff=astextplain

.gitignore

Lines changed: 215 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
#################
2+
## Eclipse
3+
#################
4+
5+
*.pydevproject
6+
.project
7+
.metadata
8+
bin/
9+
tmp/
10+
*.tmp
11+
*.bak
12+
*.swp
13+
*~.nib
14+
local.properties
15+
.classpath
16+
.settings/
17+
.loadpath
18+
19+
# External tool builders
20+
.externalToolBuilders/
21+
22+
# Locally stored "Eclipse launch configurations"
23+
*.launch
24+
25+
# CDT-specific
26+
.cproject
27+
28+
# PDT-specific
29+
.buildpath
30+
31+
32+
#################
33+
## Visual Studio
34+
#################
35+
36+
## Ignore Visual Studio temporary files, build results, and
37+
## files generated by popular Visual Studio add-ons.
38+
39+
# User-specific files
40+
*.suo
41+
*.user
42+
*.sln.docstates
43+
44+
# Build results
45+
46+
[Dd]ebug/
47+
[Rr]elease/
48+
x64/
49+
build/
50+
[Bb]in/
51+
[Oo]bj/
52+
53+
# MSTest test Results
54+
[Tt]est[Rr]esult*/
55+
[Bb]uild[Ll]og.*
56+
57+
*_i.c
58+
*_p.c
59+
*.ilk
60+
*.meta
61+
*.obj
62+
*.pch
63+
*.pdb
64+
*.pgc
65+
*.pgd
66+
*.rsp
67+
*.sbr
68+
*.tlb
69+
*.tli
70+
*.tlh
71+
*.tmp
72+
*.tmp_proj
73+
*.log
74+
*.vspscc
75+
*.vssscc
76+
.builds
77+
*.pidb
78+
*.log
79+
*.scc
80+
81+
# Visual C++ cache files
82+
ipch/
83+
*.aps
84+
*.ncb
85+
*.opensdf
86+
*.sdf
87+
*.cachefile
88+
89+
# Visual Studio profiler
90+
*.psess
91+
*.vsp
92+
*.vspx
93+
94+
# Guidance Automation Toolkit
95+
*.gpState
96+
97+
# ReSharper is a .NET coding add-in
98+
_ReSharper*/
99+
*.[Rr]e[Ss]harper
100+
101+
# TeamCity is a build add-in
102+
_TeamCity*
103+
104+
# DotCover is a Code Coverage Tool
105+
*.dotCover
106+
107+
# NCrunch
108+
*.ncrunch*
109+
.*crunch*.local.xml
110+
111+
# Installshield output folder
112+
[Ee]xpress/
113+
114+
# DocProject is a documentation generator add-in
115+
DocProject/buildhelp/
116+
DocProject/Help/*.HxT
117+
DocProject/Help/*.HxC
118+
DocProject/Help/*.hhc
119+
DocProject/Help/*.hhk
120+
DocProject/Help/*.hhp
121+
DocProject/Help/Html2
122+
DocProject/Help/html
123+
124+
# Click-Once directory
125+
publish/
126+
127+
# Publish Web Output
128+
*.Publish.xml
129+
*.pubxml
130+
131+
# NuGet Packages Directory
132+
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
133+
#packages/
134+
135+
# Windows Azure Build Output
136+
csx
137+
*.build.csdef
138+
139+
# Windows Store app package directory
140+
AppPackages/
141+
142+
# Others
143+
sql/
144+
*.Cache
145+
ClientBin/
146+
[Ss]tyle[Cc]op.*
147+
~$*
148+
*~
149+
*.dbmdl
150+
*.[Pp]ublish.xml
151+
*.pfx
152+
*.publishsettings
153+
154+
# RIA/Silverlight projects
155+
Generated_Code/
156+
157+
# Backup & report files from converting an old project file to a newer
158+
# Visual Studio version. Backup files are not needed, because we have git ;-)
159+
_UpgradeReport_Files/
160+
Backup*/
161+
UpgradeLog*.XML
162+
UpgradeLog*.htm
163+
164+
# SQL Server files
165+
App_Data/*.mdf
166+
App_Data/*.ldf
167+
168+
#############
169+
## Windows detritus
170+
#############
171+
172+
# Windows image file caches
173+
Thumbs.db
174+
ehthumbs.db
175+
176+
# Folder config file
177+
Desktop.ini
178+
179+
# Recycle Bin used on file shares
180+
$RECYCLE.BIN/
181+
182+
# Mac crap
183+
.DS_Store
184+
185+
186+
#############
187+
## Python
188+
#############
189+
190+
*.py[co]
191+
192+
# Packages
193+
*.egg
194+
*.egg-info
195+
dist/
196+
build/
197+
eggs/
198+
parts/
199+
var/
200+
sdist/
201+
develop-eggs/
202+
.installed.cfg
203+
204+
# Installer logs
205+
pip-log.txt
206+
207+
# Unit test / coverage reports
208+
.coverage
209+
.tox
210+
211+
#Translations
212+
*.mo
213+
214+
#Mr Developer
215+
.mr.developer.cfg

Module.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
/**
3+
* This file is placed here for compatibility with Zendframework 2's ModuleManager.
4+
* It allows usage of this module even without composer.
5+
* The original Module.php is in 'src/MxcRouteGuard' in order to respect PSR-0
6+
*/
7+
require_once __DIR__ . '/src/MxcRouteGuard/Module.php';

README.md

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
MxcRouteGuard
2+
=============
3+
Version 0.0.1 Created by Frank Hein and the maxence team
4+
5+
Introduction
6+
------------
7+
8+
MxcRouteGuard restricts access to routes by unauthenticated users.
9+
Out of the box MxcRouteGuard works with ZfcUser, however, alternative authentication
10+
may be used as long as they provide a public function hasIdentity() returning bool.
11+
MxcRouteGuard is designed to be very simple.
12+
13+
Requirements
14+
------------
15+
16+
* [Zend Framework 2](https://github.com/zendframework/zf2) (latest master)
17+
18+
Features / Goals
19+
----------------
20+
21+
* Allow/Deny access to application routes globally for anonymous users
22+
* Support for ZfcUser Registration Feature (automatically whitelist if enabled)
23+
* Support for ZfcUser redirect feature
24+
25+
Installation
26+
------------
27+
28+
### Main Setup
29+
30+
#### By cloning project
31+
32+
1. Clone this project into your `./vendor/` directory.
33+
34+
#### With composer
35+
36+
1. Add this project in your composer.json:
37+
38+
```json
39+
"require": {
40+
"mxc-commons/mxc-routeguard": "dev-master"
41+
}
42+
```
43+
44+
2. Now tell composer to download MxcRouteGuard by running the command:
45+
46+
```bash
47+
$ php composer.phar update
48+
```
49+
50+
#### Post installation
51+
52+
1. Enabling it in your `application.config.php`file.
53+
54+
```php
55+
<?php
56+
return array(
57+
'modules' => array(
58+
// ...
59+
'MxcRouteGuard',
60+
),
61+
// ...
62+
);
63+
```
64+
65+
Options
66+
-------
67+
68+
The MxcRouteGuard module has some options to allow you to quickly customize the basic
69+
functionality. After installing MxcRouteGuard, copy
70+
`./vendor/maxence/MxcRouteGuard/config/mxcrouteguard.global.php.dist` to
71+
`./config/autoload/mxcrouteguard.global.php` and change the values as desired.
72+
73+
The following options are available:
74+
75+
- **auth_service** - Name of Authentication Service class to use. Useful for using your own
76+
authentication service instead of the default ZfcUser. Default is `zfcuser_auth_service`.
77+
- **guard_mode** - Two modes ('white', 'black') are provided to handle the observed routes list
78+
(see below). In whitelist mode all routes but the routes provided in the observed routes list
79+
are protected from anonymous access. In blacklist mode only the routes provided in the observed
80+
route list are protected from anonymous acceess. Default is 'white'.
81+
- **observed_routes** - List of routes to protect from anonymous success (black mode) or allow to
82+
anonymous access (white mode)
83+
- **anonymous_redirect** - If access gets blocked the anonymous user gets redirected to the route
84+
specified here. Note: The anonymous_redirect route automatically gets whitelisted regardless of
85+
the guard mode. Default: 'zfcuser/login'
86+
- **strategy** - By default MxcRouteGuard redirects attempts to access protected routes by an
87+
anonymous user. If you want something else but a redirect to happen you may supply an alternative
88+
strategy here to handle anonymous access.
89+
90+
ZfcUser support
91+
---------------
92+
93+
If ZfcUser is used and the ZfcUser enable_registration flag is set true then MxcRouteGuard
94+
automatically whitelists 'zfcuser/register' regardless of the guard mode.
95+
96+
In case a route gets blocked MxcRouteGuard applies a redirectto parameter to the anonymous_redirect
97+
route which can be used by ZfcUser, if the use_redirect_parameter_if_present setting is set true.
98+
99+
Note
100+
----
101+
102+
For authenticated users MxcRouteGuard provides full access to all routes. If you need a more
103+
detailled control of who can access what route, use ZfcRbac or BjyAuthorize or similar modules
104+
instead of MxcRouteGuard.
105+
106+
Common use cases for MxcRouteGuard are demo apps which only require a user to be known.

composer.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "mxc-commons/mxc-routeguard",
3+
"description": "Zend Framework 2 Module that provides protection for routes from anonymous access.",
4+
"type": "library",
5+
"keywords": [
6+
"module",
7+
"zf2"
8+
],
9+
"homepage": "http://www.github.com/mxc-commons/MxcRouteGuard/",
10+
"authors": [
11+
{
12+
"name": "Frank Hein",
13+
"email": "[email protected]",
14+
"homepage": "http://www.maxence.de/"
15+
}
16+
],
17+
"require": {
18+
"php": ">=5.3.3",
19+
"zendframework/zend-mvc": ">=2.1",
20+
"zendframework/zend-servicemanager": ">=2.1",
21+
"zendframework/zend-eventmanager": ">=2.1",
22+
"zendframework/zend-stdlib": "~2.1"
23+
},
24+
"autoload": {
25+
"psr-0": {
26+
"MxcRouteGuard\\": "src/"
27+
}
28+
}
29+
}

config/module.config.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?php
2+
return array();

0 commit comments

Comments
 (0)