Recent Changes - Search:

Cookbook

PmWiki

pmwiki.org

AuthenticatedAsConditional

Summary: A different way of performing authentication than PmWiki's "default"
Version:
Prerequisites:
Status:
Maintainer:
Categories: Obsolete, Security

Depending on what the user is authenticated as will output the inner text. Examples of usage are below.

This recipe is superceded by later versions of PmWiki -- use the (:if auth read:) and (:if authid:) conditional markups instead. --Pm

Important

This is a out of date as PmWiki now handles authentication differently.

How so? Have recent changes made this recipe invalid? If this script is outdated, is there a way to achieve the same conditional effect? --cboe

The $AuthFunction default method call in pmwiki.php has changed. Authentication in pmwiki.php now only remembers one password, whereas before it maintained a password set (Maybe other changes I haven't looked). This cookbook item will still work, BUT authentication is not the same as out-of-the-box pmwiki.php. -- MarkS

This recipe should still be valid even as of 2.0.beta29 -- it's just a different way of performing authentication than PmWiki's "default". Also, contrary to what MarkS writes - pmwiki still remembers all of the passwords entered by a user (or at least it's supposed to). If not, that's a bug in pmwiki.php . --Pm


Usage:

(:if authenticated admin :)THE Administrator(:if:)
(:if authenticated read :)Read(:if:)
(:if authenticated edit :)Edit(:if:)
(:if authenticated attr :)Attr(:if:)

Output if the role is "admin": "THE AdministratorReadEditAttr"
Output if the role is "read": "Read"
Output if the role is "edit": "Edit"
Output if the role is "attr": "Attr"


Changes that effect the wiki infrastructure

$Conditions['authenticated'] = 'AuthenticatedAsRole($pagename, $condparm)';
$AuthFunction = 'BasicAuthUsingAuthenticatedAsRoleMethod';


Solution

Choose only one of the following files,


Put "AuthenticatedAs_V??.php" into the cookbook/ directory and add the following line to local/config.php

  include_once("cookbook/AuthenticatedAs_V??.php");

or maybe the following if you have having troubles with your includes.

  include_once('./../pmwiki/cookbook/AuthenticatedAs_V??.php');

Comments

It even allows (:include PageName:), or (:nofooter:) and such directives as inner text.
One can also build alternatives to the page actions, for instance include in the Side Bar:(:if authenticated edit :)*[[{$Name}?action=edit |Edit Page]](:if:)

21-Feb-2005 Even when i use such directives it would be nice to have also syntax enahncement notauthenticated like (:if notauthenticated edit :)(:noheader:)(:if:). If using DropDownSkin its possible to hide the "Actiontabs" - but if you are authenticated as edit you also get read so its not possible to hide the tabs _only_ for read(ers). Is someone able to enhance the systax? newmy

  • It already does this with the ! character see ConditionalMarkup -- MarkS
    • whups - this i didn't recognise - works perfect. tnx - newmy]

Is this something that one is supposed to place into the editable portion of the wiki page? I am very interested in getting this functionality into the templates themselves (so that one can define out the edit links if no-one is logged in). Also, is this for use with the UserAuth plugin?

  • Magnus
    • In response: This is a directive so it is to be used within a wiki page. I haven't thought about moving it into the template. Personally I have not used the UserAuth plugin, so I don't know if they can co-exist. -- MarkS

03.Mar-2005After update to 2.24/5 the Constellation (:AuthenticatedAsConditional, DropDownSkin with the markup (:if ! authenticated edit:) (:noheader:) (:notitle:) (:if:) in GroupHeader) only the header is hidden when a unauthenticated user opens the page. The edit-line in the button is always shown. In 2.23 the edit-line will be hidden (as described in the "manual"). newmy

  • So is the tag (:notitle:) not being done?
  • What if you replaced the (:notitle:) tag with text such as "APPLE", what would be output?
  • What is to stop you using the following code as a substitute?
    (:if ! authenticated edit:) (:noheader:) (:if:)
    (:if ! authenticated edit:) (:notitle:) (:if:)

18-Mar-2005 Would it be possible (or can you tell me how) it could be achieved to add a "Login" button or something similar so an authentication could happen without requiring e.g. editing the page (so the authentication is required before editing is possible?). Would help a lot when e.g. an edit link should be visible only after authentication as e.g. admin. Is calling @[$Authfunction@] sufficient for this task? Which parameters?Klonk

You may want to consider the following;

(:if ! authenticated edit :) [[Main.HomePage?action=edit | Logon]] (:if:)
(:if authenticated edit :) [[{$Name}?action=edit | Edit Page]] (:if:)

I haven't quite figured out how to ask for authentication without then moving to the edit page. It would probably mean you have to hack the PmWiki code, which I find tricky at the best of times. No doco, so have to strain the brain I spose. -- MarkS?

Edit the page works? What?

Edit - History - Print - Recent Changes - Search
Page last modified on March 31, 2008, at 06:55 PM