linotp.useridresolver.PasswdIdResolver module

This module implements the communication interface
for resolvin user info to the /etc/passwd user base
PasswdIdResolver.IdResolver class
implements the UserIdResolver for local /etc/passwd lookup
Don’t use this as an enterprise solution!
class linotp.useridresolver.PasswdIdResolver.IdResolver[source]

Bases: linotp.useridresolver.UserIdResolver.UserIdResolver

checkDescription(line, pattern)[source]
checkEmail(line, pattern)[source]
checkPass(uid, password)[source]

This function checks the password for a given uid. - returns true in case of success - false if password does not match

We do not support shadow passwords at the moment. so the seconds column of the passwd file needs to contain the crypted password

checkUserId(line, pattern)[source]

check for the userId

checkUserName(line, pattern)[source]

check for user name


request hook - to close down resolver object

db_prefix = 'useridresolver.PasswdIdResolver.IdResolver'
fields = {'description': 0, 'email': 0, 'gender': 0, 'givenname': 0, 'mobile': 0, 'phone': 0, 'surname': 0, 'userid': 1, 'username': 1}
classmethod getResolverClassDescriptor()[source]

return the descriptor of the resolver, which is - the class name and - the config description

Returns:resolver description dict
Return type:dict
classmethod getResolverClassType()[source]

provide the resolver type for registration


return the descriptor of the resolver, which is - the class name and - the config description

Returns:resolver description dict
Return type:dict
  • returns the resolver identifier string
  • empty string if not exist

getResolverType - return the type of the resolver

Returns:returns the string ‘ldapresolver’
Return type:string

show, which search fields this userIdResolver supports

TODO: implementation is not completed

Parameters:searchDict – fields, which should be queried
Returns:dict of all searchFields
search the user id from the login name
we need the encoding no more as the input is converted to unicode by the str2unicode function
Parameters:LoginName – the login of the user
Returns:the userId
getUserInfo(userId, no_passwd=False)[source]

get some info about the user as we only have the loginId, we have to traverse the dict for the value

  • userId – the to be searched user
  • no_passwd – retrun no password

dict of user info


get a list of all users matching the search criteria of the searchdict

Parameters:searchDict – dict of search expressions

## TODO: why does this return bool

Parameters:userId – the user to be searched
Returns:true, if a user id exists

The UserIdResolver could be configured from the pylon app config - here this could be the passwd file , whether it is /etc/passwd or /etc/shadow

init loads the /etc/passwd
user and uid as a dict for / user loginname lookup
resolver_parameters = {'fileName': (True, None, <function text>), 'linotp.root': (False, None, <function text>), 'readonly': (False, False, <function boolean>)}
sF = {'cryptpass': 1, 'description': 4, 'email': 4, 'userid': 2, 'username': 0}
searchFields = {'description': 'text', 'email': 'text', 'userid': 'numeric', 'username': 'text'}
classmethod setup(config=None, cache_dir=None)[source]

this setup hook is triggered, when the server starts to serve the first request

Parameters:config (the linotp config dict) – the linotp config
stringMatch(cString, cPattern)[source]

convert as binary string into a unicode string by trying various encodings :param input_str: input binary string :return: unicode output