Forums / Suggestions / Improved site access matching

Improved site access matching

Author Message

Jan Borsodi

Wednesday 29 October 2003 2:20:00 am

Currently the site access matching system is more complex than it needs to be, for instance it consists of too many separate settings.
Also the PHP code that does the matching is hard to read and has already had several bugs (It's better in 3.2-3 and 3.3 thanks to Volker Lenz)

I propose to create a totally new matching system which will solve this problems as well as make the system more flexible.

1. The matching
Instead of having 5-10 settings for determing how to match I propose a simple list/array of matching rules.
Each rule will try to match and if it does returns a site access name, that name is checked against valid site accesses.
If the site access is valid it used if not the next rule is checked.

a) host

SiteAccessMatch[]=hostmap:www.example.com=user
SiteAccessMatch[]=hostmap:admin.example.com=admin

This has two rules which matches against a hostname an designates it a site access.

SiteAccessMatch[]=hostelement:3

Fetches the text from the third element in the hostname and uses it as the site access. eg. www.example.com, here the first element is com and the third is www.

SiteAccessMatch[]=hostregexp:(.+).www.example.com:1

Matches the hostname against a regexp and returns the nth submatch, in this case 1.

b) port

SiteAccessMatch[]=portmap:81=admin

Maps a port number to a siteaccess.

c) path
This was currently known as URI but is really just the path element.

SiteAccessMatch[]=pathelement:1

Fetches the nth element of the path (separated by /) and uses that as siteaccess name.

SiteAccessMatch[]=pathregexp:^([^/]+)/:1

Matches the path against a regexp and returns the nth element.

d) url

SiteAccessMatch[]=urlmap:http://www.example.com=user
SiteAccessMatch[]=urlmap:https://www.example.com=admin

Maps against the whole request url and maps it to a site access.

SiteAccessMatch[]=urlregexp:https?://([^.]+).example.com:1

Matches the url against a regexp and uses the nth match as the site access.

2. Compatability

The old code should be moved to a new file and a new setting in site.ini should be added.
That way it's possible to call the old code if you don't want to change your existing settings.

Also all new settings should be placed in a new .ini (e.g. access.ini) file.

--
Amos

Documentation: http://ez.no/ez_publish/documentation
FAQ: http://ez.no/ez_publish/documentation/faq