6.2.1.4. useridresolver.SQLIdResolver module

This module implements the communication and data mapping to SQL servers.
The LinOTP server imports this module to use SQL databases as a userstore.

Dependencies: UserIdResolver

class useridresolver.SQLIdResolver.IdResolver[source]

Bases: useridresolver.UserIdResolver.UserIdResolver

checkMapping()[source]

check the given sql field map against the sql table definition

Returns:
checkPass(uid, password)[source]

checkPass - checks the password for a given uid.

Parameters:
  • uid (string) – userid to be checked
  • password (string) – user password

:return : true in case of success, false if password does not match :rtype : boolean

Todo :extend to support htpasswd passwords: http://httpd.apache.org/docs/2.2/misc/password_encryptions.html
close()[source]

close the db connection - will be called at the end of the request

connect(sqlConnect=None)[source]

create a db connection and preserve session in self.dbObj

getConfigEntry(config, key, conf, required=True, default='')[source]

getConfigEntry - retrieve an entry from the config

Parameters:
  • config (dict) – dict of all configs
  • key (string) – key which is searched
  • conf (string) – scope of the config eg. connect.sql
  • required (boolean) – if this value ist true and the key is not defined, an exception sill be raised
  • default (any) – fallback value if confg has no such entry
Returns:

the value of the specified key

Return type:

value type - in most cases string ;-)

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]
getResolverDescriptor()[source]
getResolverId()[source]

getResolverId - provide the resolver identifier

Returns:returns the resolver identifier string or empty string if not exist

:rtype : string

getResolverType()[source]

getResolverType - return the type of the resolver

Returns:returns the string ‘sqlresolver’
Return type:string
getSearchFields()[source]

return all fields on which a search could be made

Returns:dictionary of the search fields and their types
Return type:dict
getUserId(loginName)[source]

return the userId which mappes to a loginname

Parameters:loginName (string) – login name of the user
Returns:userid - unique idenitfier for this unser
Return type:string
getUserInfo(userId)[source]

return all user related information

@param userId: specied user @type userId: string @return: dictionary, containing all user related info @rtype: dict

getUserList(searchDict)[source]

retrieve a list of users

Parameters:searchDict (dict) – dictionary of the search criterias
Returns:list of user descriptions (as dict)
getUsername(userId)[source]

get the loginname from the given userid

Parameters:userId (string) – userid descriptor
Returns:loginname
Return type:string
loadConfig(config, conf='')[source]

loadConfig - load the config for the resolver

Parameters:
  • config (dict) – configuration for the sqlresolver
  • conf (string) – configuration postfix
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
useridresolver.SQLIdResolver.call_on_connect(dbapi_con, connection_record)[source]
class useridresolver.SQLIdResolver.dbObject[source]
close()[source]
connect(sqlConnect)[source]

create a db session with the sqlConnect string

Parameters:sqlConnect – sql url for the connection
count(table, where='')[source]
getTable(tableName)[source]
query(select)[source]
useridresolver.SQLIdResolver.make_connect(driver, user, pass_, server, port, db, conParams='')[source]

create a connect string from decicated parts - to build a SQLAlchemy Uri

Parameters:
  • driver (string) – mysql, postgres, ...
  • user (string) – database connection user
  • pass (string) – password of the database user
  • server (string) – servername
  • port (string or int) – database connection port
  • db (string) – database name
  • conParams (string) – additional connection parameters
useridresolver.SQLIdResolver.testconnection(params)[source]

This is used to test if the given parameter set will do a successful SQL connection and return the number of found users params are:

Driver Server Port Database User Password Table