|
5 | 5 | from pymongo.mongo_replica_set_client import MongoReplicaSetClient
|
6 | 6 | import pymongo.uri_parser
|
7 | 7 | import pymongo.errors
|
| 8 | +from saml2.saml import NAMEID_FORMAT_PERSISTENT |
| 9 | + |
8 | 10 | from saml2.eptid import Eptid
|
9 | 11 | from saml2.mdstore import InMemoryMetaData
|
10 | 12 | from saml2.mdstore import metadata_modules
|
@@ -163,6 +165,20 @@ def find_local_id(self, name_id):
|
163 | 165 | return item[self.mdb.primary_key]
|
164 | 166 | return None
|
165 | 167 |
|
| 168 | + def match_local_id(self, userid, sp_name_qualifier, name_qualifier): |
| 169 | + """ |
| 170 | + Look for an existing persistent NameID matching userid, |
| 171 | + sp_name_qualifier and name_qualifier. |
| 172 | + """ |
| 173 | + filter = {"name_id.sp_name_qualifier": sp_name_qualifier, |
| 174 | + "name_id.name_qualifier": name_qualifier, |
| 175 | + "name_id.format": NAMEID_FORMAT_PERSISTENT, |
| 176 | + } |
| 177 | + res = self.mdb.get(value=userid, **filter) |
| 178 | + if not res: |
| 179 | + return None |
| 180 | + return from_dict(res[0]["name_id"], ONTS, True) |
| 181 | + |
166 | 182 | def remove_remote(self, name_id):
|
167 | 183 | cnid = to_dict(name_id, MMODS, True)
|
168 | 184 | self.mdb.remove(name_id=cnid)
|
|
0 commit comments