AxKit::XSP::Auth - Authorization tag library for AxKit eXtensible Server Pages.
Add the auth: namespace to your XSP
<xsp:page language="Perl" xmlns:xsp="http://apache.org/xsp/core/v1" xmlns:auth="http://www.creITve.de/2002/XSP/Auth" >
Add this taglib to AxKit (via httpd.conf or .htaccess):
You must add the Session taglib as well, and if you plan to use <login>, then also the Globals taglib.
The XSP session taglib provides authorization management to XSP pages. It allows you to view, check and modify access permissions for users (logging in and out) and the effective permissions of an object (file, directory or subtarget). Moreover, it provides utilities for password handling.
This taglib works in conjunction with Apache::AxKit::Plugin::Session, which does all the hard work. There are several configuration variants available, see the man page for details.
Users are authorized via their associated session object. The session object may contain varying authorization information. This is in contrast to most other schemes where a user has a fixed, static set of access permissions. You can easily create pages which need extra confirmation to access with this mechanism. Another consequence is that a user may be logged in multiple times at the same time. This is checked and prevented when using <auth:login>, though.
Each user has a set of access permissions, or accesses. Each access consists of a type and a value or a list of values which grant that access. Each target file has a set of permissions, which may be inherited. Each permission consists of a type and a value or list of values. How the user's access is compared to the value of the permission depends on the type: user and group grant if any member of the access value matches a member of the permission's value. level grants if the user's level is greater than or equal the permission level. Moreover, using 'not', 'combined' and 'alternate', you can create more complex requirements. Overall access is granted if any permission grants access.
Each page can have subtargets which can be given different permissions from the page itself. This can be used for example to give anyone access to a guestbook but let the admin see the recorded ip addresses. Subtargets are referenced as <page>#<subtarget>.
The default implementation (see Apache::AxKit::Plugin::Session) uses the Apache configuration directive 'require' to store permissions. This unfortunately means that modifying permissions is usually impossible and unusually dangerous. You have to subclass the default implementation in order to store them somewhere else.
These tags work on the user privileges.
This tag retrieves the access permissions for the current session. It returns an XML fragment that could theoretically be passed back into auth:set-access. This is not possible though within one xsp run.
<auth:get-single-access> is just a convenience tag for retrieving exactly one type of access information suitable for processing in perl code. For this tag, a 'type' attribute is mandatory.
These tags modify the user's access privileges. They take a set of
<auth:access type="some-type" value="some-value"/> nodes. set-access works absolute, it replaces all accesses with the input set, while add-access merges the existing accesses with the input set. Do not even think of trying to add more than one user or level - You will be denied any permission of that type afterwards. To modify the level, remove it, then add a new value.
This tag removes entries from the users access set. It takes input like set-access. If you leave out the value, any access of that type is removed, else only exact matches are revoked.
Takes attributes/children 'type' and 'value'. Returns true if the user currently has access privilege type 'type' equal to / containing 'value'.
This tag logs in a user name. It works just like set-access, but additionally the user name is checked and any existing session of that user is invalidated, so that users can be logged in only once. Moreover, an external redirect is triggered. You can provide a 'destination' attribute or child tag to set the destination location, otherwise, the HTTP request parameter 'destination' is used. If you set 'destination' to "none", no redirect is performed.
You can add the parameter
<exclusive="no"> to allow a user to be logged in multiple times. Note that you need globals enabled to have the exclusive-login mechanism to work.
This tag invalidates the current session, thus logging the user out. If you supply a 'destination' tag or attribute, or if the server config specifies one, a redirect is triggered.
These tags work on permissions of objects. Targets are generally specified as an attribute or child element called 'target'. An empty target denotes the current page. Permissions are nested
<permission> tags with a 'type' attribute (or child) and either other permission tags or a text value inside.
This tag returns a node set of all permissions the given target has.
These tags attempts to modify a target's permission set. In the default implementation this is only possible if you find out how to enable it yourself, since it is dangerous.
ditto. Note that only exact matching permissions are removed.
These tags perform miscellaneous useful stuff.
This tag checks if the current user has logged in. It returns 1 or 0.
This tag aborts the page with a 'access denied' error code. It takes an attribute or child tag 'reason' which contains a symbolic reason to be examined later, and a list of
<text lang=".."> tags which specify human readable messages.
This tag checks if the current user is allowed to access a resource. It takes a target specification like get-permission. It returns 1 or 0.
This tag checks if the current user is allowed to access a resource and aborts the current page if not. It takes a target specification like get-permission and a reason code and message list like deny-permission.
This tag returns a random password suitable for sending it to users. It consists of 6 letters or digits, both upper and lower case. There are some checks made to make sure it doesn't contain an offensive word.
This tag encrypts its contents as a password and inserts the result.
This tag checks if a password matches an encrypted password. Pass the passes in child tags or attributes named 'clear' and 'encrypted'. Returns 1 or 0.
This tag returns a symbolic value which describes the last auth error. This can be used to explain a foreced logout to the user (session expired, IP address mismatch, or others). There is currently no list of possible error codes. An empty value means "no error". An unknown error most likely results in 'bad_session_provided'.
This tag returns the URI associated with the reason returned by <auth:get-reason>.
This tag clears the reason.
This tag sets the symbolic value described above.
This software has beta quality. Use with care and contact the author if any problems occur.
JÃ¶rg Walter <firstname.lastname@example.org>
Copyright (c) 2002 JÃ¶rg Waltr All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.