See
PublishedAPI for packages intended to be used by Plugin and Contrib authors, or
browse all packages.
See also
Developing plugins,
Developer's Bible,
Technical Overview
internal package
Foswiki::Users::UnixUserMapping
canonical users ids = login unix name
* $cUID
* is the same as login in Foswiki
* the same as canonical user name too
ClassMethod
new($session) → $object
Constructs a new password handler of this type, referring to $session
for any required Foswiki services.
ObjectMethod
finish()
Break circular references.
Note to developers; please undef
all fields in the object explicitly,
whether they are references or not. That way this method is "golden
documentation" of the live fields in the object.
ObjectMethod
supportsRegistration() → $boolean
Return true if the
UserMapper supports registration (ie can create new users)
Default is
false
ObjectMethod
handlesUser($cUID, $login, $wikiname) → $boolean
Called by the
Foswiki::Users object to determine which loaded mapping
to use for a given user (must be fast).
ObjectMethod
addUser($login, $wikiname, $password, $emails) → cUID
UnixUserMapping does not allow creation of users.
ObjectMethod
removeUser($user) → $boolean
UnixUserMapping does not allow removeal of users.
ObjectMethod
getWikiName($cUID) → wikiname
Map a canonical user name to a wikiname.
Returns the $cUID by default.
The
WikiName of an unix user is its Full Name in camel case mode. In the
example below the
WikiName of joao is "JoaoSilva".
# getent passwd joao
joao:x:1003:1004:Joao Silva„,:/home/joao:/bin/bash
Canonical user name is the same as login in
UnixUserMapping.
ObjectMethod
eachGroupMember($group) → Foswiki::ListIterator of cUIDs
Called from
Foswiki::Users. See the documentation of the corresponding
method in that module for details.
If $group is a Unix Group then returns users members of that group.
Unix users should have "Full Name", it will be used to calculate the
WikiName.
Subclasses
must implement this method.
ObjectMethod
eachGroup() → ListIterator of groupnames
Called from
Foswiki::Users. See the documentation of the corresponding
method in that module for details.
Get all unix groups that match with cfg "GroupFilter", by default match all
unix groups "*_group", like admins_group, users_group, etc.
Subclasses
must implement this method.
ObjectMethod
isInGroup($user, $group, $scanning) → bool
Called from
Foswiki::Users. See the documentation of the corresponding
method in that module for details.
Default is
false
ObjectMethod
checkPassword($userName, $passwordU) → $boolean
Finds if the password is valid for the given user.
Uses PAM to authenticate user, it is necessary to the webserver user have
read acces to /etc/shadow, in Debian system you can do:
# adduser www-data shadow
Returns 1 on success, undef on failure.
Default behaviour is to return 1.
ObjectMethod
setPassword($user, $newPassU, $oldPassU) → $boolean
UnixUserMapper does not change user passwords using.
ObjectMethod
passwordError() → $string
Returns a string indicating the error that happened in the password handlers
returns undef if no error (the default)
ObjectMethod
unixGroups() → \%groups
Fetch all unix groups that match with "GroupFilter" configuration:
- $Foswiki::cfg{UnixUsersContrib}{GroupFilter} = '^wiki';
By default all groups starting with "wiki" (ex: wikiadmins, wikiusers) will be
fetched. These group names will be converted to
WikiName like
WikiadminsGroup.
Ex.: wikiadmins →
WikiadminsGroup
ObjectMethod
unixUsers() → \%users
Fetch all unix users present in Unix Usesr Database (normally /etc/passwd)
ObjectMethod
getLoginName($cUID) → login
Converts an internal cUID to that user's login
(undef on failure)
Subclasses
must implement this method.
In
UnixUserMapping canonical and login are the same!
ObjectMethod
login2cUID($login, $dontcheck) → cUID
Convert a login name to the corresponding canonical user name. The
canonical name can be any string of 7-bit alphanumeric and underscore
characters, and must correspond 1:1 to the login name.
(undef on failure)
(if dontcheck is true, return a cUID for a nonexistant user too - used for registration)
Subclasses
must implement this method.
Login and canonical user name are the same in
UnixUserMapping.