kyma•tweaky . TWiki . SessionPlugin |
$doRememberRemoteUser
inside TWiki.cfg so that after a user logs in, his or her logon becomes tied to the IP address from which the user is connecting. This causes a problem when the user is going through a firewall that many users use or when the user's IP frequently changes (in the case of load balanced firewalls, both of these things might be happening at the same time).
Other fixes involve creating duplicate copies or links of non-authenticated scripts and force those copies to authenticate. Then, once a user authenticates, force them in some manner to only use the authenticated scripts. In the right implementation, this can work fairly transparently, but it still involves a noticable change of URL of TWiki pages after the "authentication barrier" is crossed. User's that want to copy and paste URLs to other people over e-mail will end up sending an authenticated URL to perhaps a person who does not even have a TWiki account.
What this plugin does with sessions is that it encapsulates all of this "logon memory" within the session. Once a user authenticates, their session contains their username and will use that username on all pages regardless of if they are authenticated pages or non-authenticated pages. This is a major improvement over the other mechanisms as it is nearly entirely transparent.
bin/logon
script provided with SessionPlugin accomplishes this. It is an artifact of the original TWiki:Plugins/SessionPlugin. The bin/logon
script must be setup in the bin/.htaccess
file to be a script which requires a valid user to authenticate. However, once authenticated, it will simply redirect the user to the view URL for the page from which logon was linked.
There are three TWikiVariables below that retrieve this logon URL. One of them is used explicitly by the TWiki:Plugins/TigerSkinPlugin and other similar plugins like TWiki:Plugins/GnuSkinPlugin.
?skin=_skinname_
after every URL, but this is hardly transparent to the user.
An idea that was implemented in the original version of TWiki:Plugins/SessionPlugin was to create the notion of a "sticky skin" which could be set via a configurable CGI variable (normally stickskin
) and would end up setting a session variable SKIN that would be respected over all other SKIN variables. In effect, this session variable would be exactly like passing ?skin=_skinname_
to every TWiki script.
This same idea is still implemented. The sticky persistent skin is available regardless of whether or not the user has logged in. On top of this, if the sticky skin is set to a configurable value (normally default
), the session SKIN will be cleared and let any other SKIN variables take over.
There are a number of TWikiVariables below that provide for easy methods to access these sticky skin features. If %SKINS% is set to be a comma-separated list of skins, the SelectSkin script will give an easy interface to changing skins on the fly and having them stick to the current session. An example of how to link to SelectSkin is given below. SelectSkin itself gives information on its usage as well. Plus, TWiki:Plugins/TigerSkinPlugin and TWiki:Plugins/GnuSkinPlugin both make a use of this SelectSkin page.
%GET_SESSION_VARIABLE{ varName }%The session variables can also be set and cleared via CGI variables (include more than one in the string if necessary, separated by commas, as demonstrated here):
%SET_SESSION_VARIABLE{ varName, varValue }%
%CLEAR_SESSION_VARIABLE{ varName }%
set_session_variable=" varName = varValue , varName = varValue , ... "That is, to set the session variable SKIN equal to "gnu" while clearing the session variable TEST, adding this to the end of a TWiki URL should work:
clear_session_variable=" varName , varName , ..."
Of course, all of the "sticky skin" features are shortcuts to this functionality (as hinted at in the above example).?set_session_variable=SKIN=gnu&clear_session_variable=TEST
$doRememberRemoteUser
feature, is left at its default setting of on. This is an important security feature that should only be turned off if you are confident that your users are going to be coming from some sort of proxy which frequently could change its outgoing IP. An example might be a load balanced firewall. However, it's better to insist that the administrator of that proxy or firewall install modern technologies to make HTTP connections persistent rather than turning off a major security feature on your system. Sessions are often used for more complicated authentication and/or storing of valuable information from the user in a hopefully secure place. It may not be worth trading off keeping this information secure.
NOTE: This setting currently cannot be set here in SessionPlugin. In order to change its setting, you must edit SessionPlugin.pm directly. This is because this plugin has a key role in authentication and must run earlier than preferences are initialized in the current version of TWiki. Because of this, this setting cannot be set like a normal TWiki preference. Edit the plugin module directly.
%SESSION_IF_AUTHENTICATED% Authenticated User %SESSION_ELSE% Not Authenticated %SESSION_ENDIF% %SESSION_IF_NOT_AUTHENTICATED% Not Authenticated %SESSION_ELSE% Authenticated User %SESSION_ENDIF% %SESSION_IF_AUTHENTICATED% Authenticated User %SESSION_ENDIF% %SESSION_IF_NOT_AUTHENTICATED% Not Authenticated %SESSION_ENDIF%If you have correctly installed this plugin, these will appear properly rendered here (square braces have been added around the tags since some of them will render an empty string if properly installed; these braces are not necessary and are only added here for clarity):
[ %SESSION_IF_AUTHENTICATED% Authenticated User %SESSION_ELSE% Not Authenticated %SESSION_ENDIF% ] [ %SESSION_IF_NOT_AUTHENTICATED% Not Authenticated %SESSION_ELSE% Authenticated User %SESSION_ENDIF% ] [ %SESSION_IF_AUTHENTICATED% Authenticated User %SESSION_ENDIF% ] [ %SESSION_IF_NOT_AUTHENTICATED% Not Authenticated %SESSION_ENDIF% ]
You type | You get | If correctly installed |
---|---|---|
%SESSIONID% | The unique ID for this session | %SESSIONID% |
%SESSIONVAR% | The CGI and session variable that stores the session ID | %SESSIONVAR% |
%STICKSKIN% | The current "sticky skin" being held in the session (see above for description) | %STICKSKIN% |
%SESSIONLOGON% | Pre-linked logon (used by TigerSkinPlugin) | %SESSIONLOGON% |
%SESSIONLOGONURL% | URL for forced logon script | %SESSIONLOGONURL% |
%SESSIONLOGONURLPATH% | URL path for forced logon script | %SESSIONLOGONURLPATH% |
%SKINSELECT% | Expects %SKINS% to have comma-separted list of installed skins. Produces select input to select a "sticky skin" | %SKINSELECT% |
%SESSION_IS_AUTHENTICATED% | Returns a 1 if the current session has gone through authentication. Otherwise returns a 0. Useful when used with something like TWiki:Plugins/ConditionalPlugin | %SESSION_IS_AUTHENTICATED% |
%SESSION_IF_AUTHENTICATED% | Session conditional. | See above for description and example. |
%SESSION_IF_NOT_AUTHENTICATED% | Session conditional. | See above for description and example. |
%SESSION_ELSE% | Session conditional. | See above for description and example. |
%SESSION_ENDIF% | Session conditional. | See above for description and example. |
%GET_SESSION_VARIABLE% | Gets a session variable. | See above for description and example. |
%SET_SESSION_VARIABLE% | Sets a session variable. | See above for description and example. |
%CLEAR_SESSION_VARIABLE% | Clears a session variable. | See above for description and example. |
You type | You get | If correctly installed |
---|---|---|
%DO_SESSION_IP_MATCHING% | Whether to verify that session ID is coming from same IP as its original creator (can currently only be set within SessionPlugin.pm) | %DO_SESSION_IP_MATCHING% |
%AUTHUSER_SESSIONVAR% | The session variable that stores the authenticated user name. By setting this to different values, hopefully this plugin can be more easily integrated into other authentication schemes that already fill this session variable in before this plugin gets a chance (can currently only be set within SessionPlugin.pm) | %AUTHUSER_SESSIONVAR% |
%USE_TRANS_SESSIONID% | Whether to use transparent session IDs | %USE_TRANS_SESSIONID% |
%STICKSKINVAR% | The CGI variable to select "sticky skin" | %STICKSKINVAR% |
%STICKSKINOFFVALUE% | The skin name to which to set the above CGI variable in order to turn off "sticky skins" | %STICKSKINOFFVALUE% |
data/debug.txt
)
SessionPlugin.zip
in your twiki installation directory. Content:
File: | Description: |
---|---|
data/TWiki/SessionPlugin.txt | Plugin topic |
data/TWiki/SessionPlugin.txt,v | Plugin topic repository |
lib/TWiki/Plugins/SessionPlugin.pm | Plugin Perl module |
bin/logon | Script to force logon |
bin/.htaccess
so that bin/logon
needs a valid-user. In other words, add these lines to bin/.htaccess
: <Files "logon"> require valid-user </Files>
?%SESSIONPLUGIN_STICKSKINVAR%=plain
to the end of the URL for this page and see if the skin changes to the plain skin.
?%SESSIONPLUGIN_STICKSKINVAR%=%SESSIONPLUGIN_STICKSKINOFFVALUE%
to a URL.
Plugin Author: | TedPavlic? |
Plugin Version: | 03 Sep 2003 (V2.122) |
Change History: | |
03 Sep 2003: | (V2.122) Changed things so plugin will work with modperl, SpeedyCGI, etc. |
24 Aug 2003: | (V2.121) Added set_session_variable and clear_session_variable CGI sensitivity to allow for mangling of session variables from CGI as well. |
24 Aug 2003: | (V2.120) Added SET_SESSION_VARIABLE, GET_SESSION_VARIABLE, and CLEAR_SESSION_VARIABLE and suggested addition to Plugin API to make clearing session variables easier from other plugins. This change really warns that TWiki.pm should be patched according to TWiki:Codev/SessionVariablesOverrideFinalPreferences to prevent users from easily overriding FINALPREFERENCES settings. Anticipate ways to set, get, and clear with CGI variables in 2.121. |
23 Aug 2003: | (V2.111) Added conditional operators SESSION_IF_AUTHENTICATED, SESSION_IF_NOT_AUTHENTICATED, SESSION_ELSE, SESSION_ENDIF that give ConditionalPlugin-like behavior without ConditionalPlugin (especially since ConditionalPlugin does not currently support SESSION_IS_AUTHENTICATED-based solutions). |
23 Aug 2003: | (V2.110) Added new SESSION_IS_AUTHENTICATED flag for use with things like TWiki:Plugins/ConditionalPlugin. Anticipate internal conditional symbols soon. |
23 Aug 2003: | (V2.103) Fixed minor bug that would not resolve %STICKSKIN% if it was not defined. |
17 Aug 2003: | (V2.102) Fixed minor bug that session to be cleared immediately after it was created. This bug was a result of an attempt to clean up some perl warnings. Fixed now (and still no warnings). |
17 Aug 2003: | (V2.101) Fixed minor bug that caused non-quoted hrefs to not render properly with transparent CGI session IDs. |
17 Aug 2003: | (V2.100) First release. Some new features. Fixed some bugs. Does not break mailnotify anymore. |
19 Jul 2003: | (V2.010) Beta release to fully replace TWiki:Plugins/SessionPlugin - lots of new features |
17 Jul 2003: | (V2.001) Initial alpha release to replace TWiki:Plugins/SessionPlugin |
CPAN Dependencies: | CGI::Session |
Other Dependencies: | none |
Perl Version: | 5.6.0 (though Perl5 should be fine) |
Plugin Home: | http://TWiki.org/cgi-bin/view/Plugins/SessionPlugin |
Feedback: | http://TWiki.org/cgi-bin/view/Plugins/SessionPluginDev |
----- Revision r1.19 - 21 Aug 2005 - 21:58 GMT - CarlaScaletti
|