Package TWiki::LoginManager
The package is also a Factory for login managers and also the base class
for all login managers.
On it's own, an object of this class is used when you specify 'none' in
the security setup section of
configure. When it is used,
logins are not supported. If you want to authenticate users then you should
consider Template Login? or Apache Login? , which are subclasses of this class.
If you are building a new login manager, then you should write a new subclass
of this class, implementing the methods marked as VIRTUAL. There are already
examples in the lib/TWiki/LoginManager directory.
The class has extensive tracing, which is enabled by
$TWiki::cfg{Trace}{LoginManager.pm}. The tracing is done in such a way as to
let the perl optimiser optimise out the trace function as a no-op if tracing
is disabled.
Here's an overview of how it works:
Early in TWiki::new, the login manager is created. The creation of the login manager does two things: - If sessions are in use, it loads CGI::Session but doesn't initialise the session yet.
- Creates the login manager object
- Calls loginManager->getUser to get the username before the session is created
- TWiki::LoginManager::ApacheLogin looks at REMOTE_USER (only for authenticated scripts)
- TWiki::LoginManager::TemplateLogin just returns undef
- reads the TWIKISID cookie to get the SID (or the TWIKISID parameters in the CGI query if cookies aren't available, or IP2 SID? mapping if that's enabled).
- Creates the CGI::Session object, and the session is thereby read.
- If the username still isn't known, reads it from the cookie. Thus TWiki::LoginManager::ApacheLogin overrides the cookie using REMOTE_USER, and TWiki::LoginManager::TemplateLogin always uses the session.
Object Data? twiki
The TWiki object this login manager is attached to.
On this page:
- ObjectData twiki
- StaticMethod makeLoginManager ($twiki) -> $TWiki::LoginManager
- ClassMethod new ($session,$impl)
- ObjectMethod finish ()
- ClassMethod _real_trace ($session,$impl)
- ClassMethod _IP2SID ($session,$impl)
- ObjectMethod loadSession ($defaultUser) -> $login
- ObjectMethod checkAccess ()
- ObjectMethod complete ()
- StaticMethod expireDeadSessions ()
- ObjectMethod userLoggedIn ($login,$wikiname)
- ObjectMethod _myScriptURLRE ($thisl)
- ObjectMethod _rewriteURL ($thisl)
- ObjectMethod _rewriteFORM ($thisl)
- ObjectMethod endRenderingHandler ()
- ObjectMethod _pushCookie ($thisl)
- ObjectMethod addCookie ($c)
- ObjectMethod modifyHeader (\%header)
- ObjectMethod redirectCgiQuery ($url)
- ObjectMethod getSessionValues () -> \%values
- ObjectMethod getSessionValue ($name) -> $value
- ObjectMethod setSessionValue ($name,$value)
- ObjectMethod clearSessionValue ($name) -> $boolean
- ObjectMethod forceAuthentication () -> boolean
- ObjectMethod loginUrl (...) -> $url
- ObjectMethod getUser ()
- ObjectMethod _LOGIN ($thisl)
- ObjectMethod _LOGOUTURL ($thisl)
- ObjectMethod _LOGOUT ($thisl)
- ObjectMethod _AUTHENTICATED ($thisl)
- ObjectMethod _CANLOGIN ($thisl)
- ObjectMethod _SESSION_VARIABLE ($thisl)
- ObjectMethod _LOGINURL ($thisl)
- ObjectMethod _dispLogon ($thisl)
- PrivateMethod _skinSelect ()
Static Method makeLoginManager ($twiki) -> $TWiki::LoginManager
Factory method, used to generate a new TWiki::LoginManager object for the given session.Class Method new ($session,$impl)
Construct the user management objectObject Method finish ()
Break circular references.Class Method _real_trace ($session,$impl)
Construct the user management objectClass Method _IP2SID ($session,$impl)
read/write IP to SID map, return SIDObject Method loadSession ($defaultUser) -> $login
Get the client session data, using the cookie and/or the request URL. Set up appropriate session variables in the twiki object and return the login name. $defaultUser is a username to use if one is not available from other sources. The username passed when you create a TWiki instance is passed in here.Object Method checkAccess ()
Check if the script being run in this session is authorised for execution. If not, throw an access control exception.Object Method complete ()
Complete processing after the client's HTTP request has been responded to. Flush the user's session (if any) to disk.Static Method expireDeadSessions ()
Delete sessions and passthrough files that are sitting around but are really expired. This assumes that the sessions are stored as files. This is a static method, but requires TWiki::cfg. It is designed to be run from a session or from a cron job.Object Method userLoggedIn ($login,$wikiname)
Called when the user is known. It's invoked from TWiki::UI::Register::finish for instance,- when the user follows the link in their verification email message
- or when the session store is read
- when the user authenticates (via templatelogin / sudo)
-
$login- string login name -
$wikiname- string wikiname
Object Method _myScriptURLRE ($thisl)
Object Method _rewriteURL ($thisl)
Object Method _rewriteFORM ($thisl)
Object Method endRenderingHandler ()
This handler is called by getRenderedVersion just before the plugins postRenderingHandler. So it is passed all HTML text just before it is printed. DEPRECATED Use postRenderingHandler instead.Object Method _pushCookie ($thisl)
Object Method addCookie ($c)
Add a cookie to the list of cookies for this session.-
$c- a CGI::Cookie
Object Method modifyHeader (\%header)
Modify a HTTP header-
\%header- header entries
Object Method redirectCgiQuery ($url)
Generate an HTTP redirect on STDOUT, if you can. Return 1 if you did.-
$url- target of the redirection.
Object Method getSessionValues () -> \%values
Get a name->value hash of all the defined session variablesObject Method getSessionValue ($name) -> $value
Get the value of a session variable.Object Method setSessionValue ($name,$value)
Set the value of a session variable. We do not allow setting of AUTHUSER.Object Method clearSessionValue ($name) -> $boolean
Clear the value of a session variable. We do not allow setting of AUTHUSER.Object Method forceAuthentication () -> boolean
VIRTUAL METHOD implemented by subclasses Triggered by an access control violation, this method tests to see if the current session is authenticated or not. If not, it does whatever is needed so that the user can log in, and returns 1. If the user has an existing authenticated session, the function simply drops though and returns 0.Object Method loginUrl (...) -> $url
VIRTUAL METHOD implemented by subclasses Return a full URL suitable for logging in.-
...- url parameters to be added to the URL, in the format required by TWiki::getScriptUrl()
Object Method getUser ()
VIRTUAL METHOD implemented by subclasses If there is some other means of getting a username - for example, Apache has remote_user() - then return it. Otherwise, return undef and the username stored in the session will be used.Object Method _LOGIN ($thisl)
Object Method _LOGOUTURL ($thisl)
Object Method _LOGOUT ($thisl)
Object Method _AUTHENTICATED ($thisl)
Object Method _CANLOGIN ($thisl)
Object Method _SESSION_VARIABLE ($thisl)
Object Method _LOGINURL ($thisl)
Object Method _dispLogon ($thisl)
Private Method? _skinSelect ()
Internal use only TODO: what does it do?| Topic TWikiLoginManagerDotPm . { Edit | Attach | Backlinks: Web All webs | Printable | History: r1 More } |