Package TWiki::Users
This package provides services for the lookup and manipulation of login and
wiki names of users, and their authentication.
It is a Facade that presents a common interface to the User Mapping
and Password modules. The rest of the core should only use the methods
of this package, and should never call the mapping or password managers
directly.
TWiki uses the concept of a login name which is used to authenticate a
user. A login name maps to a wiki name that is used to identify the user
for display. Each login name is unique to a single user, though several
login names may map to the same wiki name.
Using this module (and the associated plug-in user mapper) TWiki supports
the concept of groups. Groups are sets of login names that are treated
equally for the purposes of access control. Group names do not have to be
wiki names, though it is helpful for display if they are.
Internally in the code TWiki uses something referred to as a _canonical user
id_ or just user id. The user id is also used externally to uniquely identify
the user when (for example) recording topic histories. The user id is usually
just the login name, but it doesn't need to be. It just has to be a unique
7-bit alphanumeric and underscore string that can be mapped to/from login
and wiki names by the user mapper.
The canonical user id should never be seen by a user. On the other hand,
core code should never use anything but a canonical user id to refer
to a user.
Terminology - A login name is the name used to log in to TWiki. Each login name is assumed to be unique to a human. The Password module is responsible for authenticating and manipulating login names.
- A canonical user id is an internal TWiki representation of a user. Each canonical user id maps 1:1 to a login name.
- A wikiname is how a user is displayed. Many user ids may map to a single wikiname. The user mapping module is responsible for mapping the user id to a wikiname.
- A group id represents a group of users and other groups. The user mapping module is responsible for mapping from a group id to a list of canonical user ids for the users in that group.
- An email is an email address asscoiated with a login name. A single login name may have many emails.
- wherever the code references $user, its a canonical_id
- wherever the code references $group, its a group_name
On this page:
- ClassMethod new ($session)
- ObjectMethod finish ()
- ObjectMethod loginTemplateName () -> templateFile
- ObjectMethod supportsRegistration () -> boolean
- ObjectMethod initialiseUser ($login) -> cUID
- randomPassword()
- ObjectMethod addUser ($login,$wikiname,$password,$emails) -> $cUID
- StaticMethod forceCUID ($cUID) -> $cUID
- ObjectMethod getCanonicalUserID ($login) -> $user
- ObjectMethod findUserByWikiName ($wn) -> \@users
- ObjectMethod findUserByEmail ($email) -> \@users
- ObjectMethod getEmails ($user) -> @emailAddress
- ObjectMethod setEmails ($user,@emails)
- ObjectMethod isAdmin ($cUID) -> $boolean
- ObjectMethod isInList ($user,$list) -> $boolean
- ObjectMethod getLoginName ($cUID) -> $string
- ObjectMethod getWikiName ($cUID) -> $wikiName
- ObjectMethod webDotWikiName ($user) -> $webDotWiki
- ObjectMethod userExists ($cUID) -> $boolean
- ObjectMethod eachUser () -> $iterator
- ObjectMethod eachGroup () -> $iterator
- ObjectMethod eachGroupMember ($group) -> $iterator
- ObjectMethod isGroup ($user) -> boolean
- ObjectMethod isInGroup ($user,$group) -> $boolean
- ObjectMethod eachMembership ($cUID) -> $iterator
- ObjectMethod checkPassword ($userName,$passwordU) -> $boolean
- ObjectMethod setPassword ($user,$newPassU,$oldPassU) -> $boolean
- ObjectMethod passwordError () -> $string
- ObjectMethod removeUser ($user) -> $boolean
- ObjectMethod ASSERT_IS_CANONICAL_USER_ID ($user_id) -> $boolean
- ObjectMethod ASSERT_IS_USER_LOGIN_ID ($user_login) -> $boolean
- ObjectMethod ASSERT_IS_USER_DISPLAY_NAME ($user_display) -> $boolean
ClassMethod new ($session)
Construct the user management object that is the facade to the BaseUserMapping and the user mapping chosen in the configuration.ObjectMethod finish ()
Break circular references.ObjectMethod loginTemplateName () -> templateFile
allows UserMappings to come with customised login screens - that should preffereably only over-ride the UI functionObjectMethod supportsRegistration () -> boolean
#return 1 if the main UserMapper supports registration (ie can create new users)ObjectMethod initialiseUser ($login) -> cUID
randomPassword()
Static function that returns a random passwordObjectMethod addUser ($login,$wikiname,$password,$emails) -> $cUID
-
$login
- user login name. Ifundef
,$wikiname
will be used as the login name. -
$wikiname
- user wikiname. Ifundef
, the user mapper will be asked to provide it. -
$password
- password. If undef, a password will be generated.
StaticMethod forceCUID ($cUID) -> $cUID
This function ensures that any cUID's are able to be used for rcs, and other internals not capable of coping with user identifications that contain more than 7 bit ascii. repeated calls must result in the same result (sorry, can't spell the word for it)so the '_' must not be re-encoded Please, call this function in any custom Usermapper to simplifyyour mapping code.ObjectMethod getCanonicalUserID ($login) -> $user
Works out the unique TWiki identifier for the user who logs in with the given login. The canonical user ID is an alphanumeric string that is unique to the login name, and can be mapped back to a login name and the corresponding wiki name using the methods of this class. returns undef if the user does not exist.ObjectMethod findUserByWikiName ($wn) -> \@users
-
$wn
- wikiname to look up
ObjectMethod findUserByEmail ($email) -> \@users
-
$email
- email address to look up
ObjectMethod getEmails ($user) -> @emailAddress
If this is a user, return their email addresses. If it is a group,
return the addresses of everyone in the group.
The password manager and user mapping manager are both consulted for emails
for each user (where they are actually found is implementation defined).
Duplicates are removed from the list.
ObjectMethod setEmails ($user,@emails)
Set the email address(es) for the given user. The password manager is tried first, and if it doesn't want to know the user mapping manager is tried.ObjectMethod isAdmin ($cUID) -> $boolean
True if the user is an admin- is $TWiki::cfg{SuperAdminGroup}
- is a member of the $TWiki::cfg{SuperAdminGroup}
ObjectMethod isInList ($user,$list) -> $boolean
Return true if $user is in a list of user wikinames and group ids. $list is a comma-separated wikiname and group list. The list may contain the conventional web specifiers (which are ignored).ObjectMethod getLoginName ($cUID) -> $string
Get the login name of a user.ObjectMethod getWikiName ($cUID) -> $wikiName
Get the wikiname to display for a canonical user identifier. can return undef if the user is not in the mapping system (or the special case from initialiseUser)ObjectMethod webDotWikiName ($user) -> $webDotWiki
Return the fully qualified wikiname of the userObjectMethod userExists ($cUID) -> $boolean
Determine if the user already exists or not. A user exists if they are known to to the user mapper.ObjectMethod eachUser () -> $iterator
Get an iterator over the list of all the registered users not including groups. list of canonical_ids ??? Use it as follows:my $iterator = $umm->eachUser(); while ($iterator->hasNext()) { my $user = $iterator->next(); ... }