linotp.lib.realm module

realm processing logic

linotp.lib.realm.createDBRealm(realm)[source]

Store Realm in the DB Realm Table. If the realm already exist, we do not need to store it

Parameters:realm (string) – the realm name

:return : if realm is created(True) or already esists(False) :rtype : boolean

linotp.lib.realm.deleteRealm(realmname)[source]

delete the realm from the Database Table with the given name

Parameters:realmname (string) – the to be deleted realm
linotp.lib.realm.getDefaultRealm(config=None)[source]

return the default realm - lookup in the config for the DefaultRealm key

Returns:the realm name

:rtype : string

linotp.lib.realm.getRealmObject(name=u'', id=0)[source]

returns the Realm Object for a given realm name. If the given realm name is not found, it returns “None”

Parameters:name (string) – realmname to be searched

TODO: search by id not implemented, yet :param id: id of the realm object :type id: integer

:return : realmObject - the database object :rtype : the sql db object

linotp.lib.realm.getRealms(aRealmName='')[source]

lookup for a defined realm or all realms

Note:the realms dict is inserted into the LinOtp Config object

so that a lookup has not to reparse the whole config again

Parameters:aRealmName (string) – a realmname - the realm, that is of interestet, if ==”” all realms are returned
Returns:a dict with realm description like
:rtype : dict : {
u’myotherrealm’: {‘realmname’: u’myotherrealm’,
‘useridresolver’: [‘useridresolver.PasswdIdResolver.IdResolver.myOtherRes’], ‘entry’: u’linotp.useridresolver.group.myotherrealm’},
u’mydefrealm’: {‘default’: ‘true’,
‘realmname’: u’mydefrealm’, ‘useridresolver’: [‘useridresolver.PasswdIdResolver.IdResolver.myDefRes’], ‘entry’: u’linotp.useridresolver.group.mydefrealm’},
u’mymixrealm’: {‘realmname’: u’mymixrealm’,
‘useridresolver’: [‘useridresolver.PasswdIdResolver.IdResolver.myOtherRes’, ‘useridresolver.PasswdIdResolver.IdResolver.myDefRes’], ‘entry’: u’linotp.useridresolver.group.mymixrealm’}}
linotp.lib.realm.isRealmDefined(realm)[source]

check, if a realm already exists or not

Parameters:realm (string) – the realm, that should be verified

:return :found or not found :rtype :boolean

linotp.lib.realm.match_realms(request_realms, allowed_realms)[source]

Check if all requested realms are also allowed realms and return a filtered list with only the matched realms. In case of ‘*’ in reques_realms, return all allowed realms including /:no realm:/

Parameters:
  • allowed_realms – list of realms from request (without ‘*’)
  • request_realms – list of allowed realms according to policies
Returns:

list of realms which were in both lists

linotp.lib.realm.realm2Objects(realmList)[source]

convert a list of realm names to a list of realmObjects

Parameters:realmList (list) – list of realnames
Returns:list of realmObjects
Return type:list
linotp.lib.realm.setDefaultRealm(defaultRealm, check_if_exists=True)[source]

set the defualt realm attrbute

Note:verify, if the defualtRealm could be empty :”“
Parameters:defaultRealm – the default realm name
Returns:success or not
Return type:boolean