← Index
NYTProf Performance Profile   « line view »
For ./view
  Run on Fri Jul 31 19:05:14 2015
Reported on Fri Jul 31 19:08:10 2015

Filename/var/www/foswiki11/lib/Foswiki/Plugins/ModifyLoginPlugin.pm
StatementsExecuted 21 statements in 337µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11117µs27µsFoswiki::Plugins::ModifyLoginPlugin::::initPluginFoswiki::Plugins::ModifyLoginPlugin::initPlugin
11114µs26µsFoswiki::Plugins::ModifyLoginPlugin::::BEGIN@42Foswiki::Plugins::ModifyLoginPlugin::BEGIN@42
1119µs9µsFoswiki::Plugins::ModifyLoginPlugin::::initializeUserHandlerFoswiki::Plugins::ModifyLoginPlugin::initializeUserHandler
1113µs3µsFoswiki::Plugins::ModifyLoginPlugin::::BEGIN@44Foswiki::Plugins::ModifyLoginPlugin::BEGIN@44
1113µs3µsFoswiki::Plugins::ModifyLoginPlugin::::BEGIN@45Foswiki::Plugins::ModifyLoginPlugin::BEGIN@45
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1# See bottom of file for default license and copyright information
2
3=begin TML
4
5---+ package ModifyLoginPlugin
6
7This is a simple plugin that can convert the login provided by the user
8to a the format needed by Foswiki server to identify the user.
9
10It is typically used when you have a single sign on scheme like mod_ldap
11where the login name can be authenticated in more than one way. Typically
12ldap servers will authenticate users without paying attention to case.
13
14This means that the same user can be authenticated as ABC123 and abc123
15
16Foswiki however is case sensitive. This means that users that sometimes use
17uppercase and sometimes lowercase login will often not be recognized by
18Foswiki but appear with their raw login name and maybe be denied access.
19
20Using this plugin you can set
21Foswiki::cfg{Plugins}{ModifyLoginPlugin}{ChangeCase} to 'lower' and the user
22will always have his login name converted to lowercase.
23
24Foswiki will then always see the user as his lowercase login.
25
26The plugin has one additional independent feature. It can assign a login name
27based on a specific path. This is used to open a controlled backdoor to
28Foswiki via a specific list of topics. This enables creating a special user
29with a carefully assigned set of access rights. A typical use is to create
30a query page that can lookup information within a web without authentication.
31
32A plugin may be implemented to look directly at the ENV and use the
33REMOTE_USER directly. This plugin cannot deal with that. But most plugin
34should behave correctly.
35
36=cut
37
38# change the package name!!!
39package Foswiki::Plugins::ModifyLoginPlugin;
40
41# Always use strict to enforce variable scoping
42227µs239µs
# spent 26µs (14+13) within Foswiki::Plugins::ModifyLoginPlugin::BEGIN@42 which was called: # once (14µs+13µs) by Foswiki::Plugin::BEGIN@2.22 at line 42
use strict;
# spent 26µs making 1 call to Foswiki::Plugins::ModifyLoginPlugin::BEGIN@42 # spent 13µs making 1 call to strict::import
43
44219µs13µs
# spent 3µs within Foswiki::Plugins::ModifyLoginPlugin::BEGIN@44 which was called: # once (3µs+0s) by Foswiki::Plugin::BEGIN@2.22 at line 44
use Foswiki::Func (); # The plugins API
# spent 3µs making 1 call to Foswiki::Plugins::ModifyLoginPlugin::BEGIN@44
452252µs13µs
# spent 3µs within Foswiki::Plugins::ModifyLoginPlugin::BEGIN@45 which was called: # once (3µs+0s) by Foswiki::Plugin::BEGIN@2.22 at line 45
use Foswiki::Plugins (); # For the API version
# spent 3µs making 1 call to Foswiki::Plugins::ModifyLoginPlugin::BEGIN@45
46
47# $VERSION is referred to by Foswiki, and is the only global variable that
48# *must* exist in this package. This should always be in the format
49# $Rev: 6504 (2010-02-24) $ so that Foswiki can determine the checked-in status of the
50# extension.
511500nsour $VERSION = '$Rev: 6504 (2010-02-24) $';
52
53# $RELEASE is used in the "Find More Extensions" automation in configure.
541200nsour $RELEASE = '2.0';
55
56# Short description of this plugin
57# One line description, is shown in the %SYSTEMWEB%.TextFormattingRules topic:
581200nsour $SHORTDESCRIPTION = 'The plugin can modify a login by changing case or stripping all after @';
59
60# You must set $NO_PREFS_IN_TOPIC to 0 if you want your plugin to use
61# preferences set in the plugin topic. This is required for compatibility
62# with older plugins, but imposes a significant performance penalty, and
63# is not recommended. Instead, leave $NO_PREFS_IN_TOPIC at 1 and use
64# =$Foswiki::cfg= entries, or if you want the users
65# to be able to change settings, then use standard Foswiki preferences that
66# can be defined in your %USERSWEB%.SitePreferences and overridden at the web
67# and topic level.
68#
69# %SYSTEMWEB%.DevelopingPlugins has details of how to define =$Foswiki::cfg=
70# entries so they can be used with =configure=.
711200nsour $NO_PREFS_IN_TOPIC = 1;
72
73=begin TML
74
75---++ initPlugin($topic, $web, $user) -> $boolean
76 * =$topic= - the name of the topic in the current CGI query
77 * =$web= - the name of the web in the current CGI query
78 * =$user= - the login name of the user
79 * =$installWeb= - the name of the web the plugin topic is in
80 (usually the same as =$Foswiki::cfg{SystemWebName}=)
81
82*REQUIRED*
83
84Called to initialise the plugin. If everything is OK, should return
85a non-zero value. On non-fatal failure, should write a message
86using =Foswiki::Func::writeWarning= and return 0. In this case
87%<nop>FAILEDPLUGINS% will indicate which plugins failed.
88
89In the case of a catastrophic failure that will prevent the whole
90installation from working safely, this handler may use 'die', which
91will be trapped and reported in the browser.
92
93__Note:__ Please align macro names with the Plugin name, e.g. if
94your Plugin is called !FooBarPlugin, name macros FOOBAR and/or
95FOOBARSOMETHING. This avoids namespace issues.
96
97=cut
98
99
# spent 27µs (17+10) within Foswiki::Plugins::ModifyLoginPlugin::initPlugin which was called: # once (17µs+10µs) by Foswiki::Plugin::__ANON__[/var/www/foswiki11/lib/Foswiki/Plugin.pm:241] at line 234 of /var/www/foswiki11/lib/Foswiki/Plugin.pm
sub initPlugin {
10012µs my ( $topic, $web, $user, $installWeb ) = @_;
101
102 # check for Plugins.pm versions
103117µs110µs if ( $Foswiki::Plugins::VERSION < 2.0 ) {
# spent 10µs making 1 call to version::vxs::VCMP
104 Foswiki::Func::writeWarning( 'Version mismatch between ',
105 __PACKAGE__, ' and Plugins.pm' );
106 return 0;
107 }
108
109 # Plugin correctly initialized
11016µs return 1;
111}
112
113=begin TML
114
115---++ initializeUserHandler( $loginName, $url, $pathInfo )
116 * =$loginName= - login name recovered from $ENV{REMOTE_USER}
117 * =$url= - request url
118 * =$pathInfo= - pathinfo from the CGI query
119Allows a plugin to set the username. Normally Foswiki gets the username
120from the login manager. This handler gives you a chance to override the
121login manager.
122
123Return the *login* name.
124
125This handler is called very early, immediately after =earlyInitPlugin=.
126
127*Since:* Foswiki::Plugins::VERSION = '2.0'
128
129=cut
130
131
# spent 9µs within Foswiki::Plugins::ModifyLoginPlugin::initializeUserHandler which was called: # once (9µs+0s) by Foswiki::Plugin::load at line 196 of /var/www/foswiki11/lib/Foswiki/Plugin.pm
sub initializeUserHandler {
1321800ns my ( $loginName, $url, $pathInfo ) = @_;
133
134 # Map path to special users
13512µs if ( defined $Foswiki::cfg{Plugins}{ModifyLoginPlugin}{MapPathToUser}{$pathInfo} ) {
136 return $Foswiki::cfg{Plugins}{ModifyLoginPlugin}{MapPathToUser}{$pathInfo};
137 }
138
139 # Change case of login name
140 # This plugin assumes {Register}{AllowLoginName}, otherwise it will do nothing
141
14211µs return $loginName unless $Foswiki::cfg{Register}{AllowLoginName};
143
14411µs if ( $Foswiki::cfg{Plugins}{ModifyLoginPlugin}{ChangeCase} eq 'lowercase' ) {
145 $loginName = lc($loginName);
146 }
147 elsif ( $Foswiki::cfg{Plugins}{ModifyLoginPlugin}{ChangeCase} eq 'uppercase' ) {
148 $loginName = uc($loginName);
149 }
150
151 # Strip everything from @ till the end of the login incl @
1521600ns if ( $Foswiki::cfg{Plugins}{ModifyLoginPlugin}{StripAfterAtsign} ) {
1531600ns $loginName =~ s/@.*$//;
154 }
155
15614µs return $loginName;
157}
158
15913µs1;
160__END__