Пример #1
0
 def _list_tokens_for_trust(self, trust_id):
     tokens = []
     now = timeutils.utcnow()
     for token, ref in self.db.items():
         if not token.startswith('token-') or self.is_expired(now, ref):
             continue
         if self.trust_matches(trust_id, ref):
             tokens.append(token.split('-', 1)[1])
     return tokens
Пример #2
0
 def _list_tokens_for_trust(self, trust_id):
     tokens = []
     now = timeutils.utcnow()
     for token, ref in self.db.items():
         if not token.startswith('token-') or self.is_expired(now, ref):
             continue
         if self.trust_matches(trust_id, ref):
             tokens.append(token.split('-', 1)[1])
     return tokens
Пример #3
0
 def list_revoked_tokens(self):
     tokens = []
     for token, token_ref in self.db.items():
         if not token.startswith('revoked-token-'):
             continue
         record = {}
         record['id'] = token_ref['id']
         record['expires'] = token_ref['expires']
         tokens.append(record)
     return tokens
Пример #4
0
 def list_revoked_tokens(self):
     tokens = []
     for token, token_ref in self.db.items():
         if not token.startswith("revoked-token-"):
             continue
         record = {}
         record["id"] = token_ref["id"]
         record["expires"] = token_ref["expires"]
         tokens.append(record)
     return tokens
Пример #5
0
 def list_revoked_tokens(self):
     tokens = []
     for token, token_ref in self.db.items():
         if not token.startswith('revoked-token-'):
             continue
         record = {}
         record['id'] = token_ref['id']
         record['expires'] = token_ref['expires']
         tokens.append(record)
     return tokens
Пример #6
0
 def list_tokens(self, user_id):
     tokens = []
     now = datetime.datetime.utcnow()
     for token, user_ref in self.db.items():
         if not token.startswith("token-"):
             continue
         if "user" not in user_ref:
             continue
         if user_ref["user"].get("id") != user_id:
             continue
         if user_ref.get("expires") and user_ref.get("expires") < now:
             continue
         tokens.append(token.split("-", 1)[1])
     return tokens
Пример #7
0
 def list_tokens(self, user_id):
     tokens = []
     now = timeutils.utcnow()
     for token, user_ref in self.db.items():
         if not token.startswith('token-'):
             continue
         if 'user' not in user_ref:
             continue
         if user_ref['user'].get('id') != user_id:
             continue
         if user_ref.get('expires') and user_ref.get('expires') < now:
             continue
         tokens.append(token.split('-', 1)[1])
     return tokens
Пример #8
0
    def _list_tokens_for_user(self, user_id, tenant_id=None):
        def user_matches(user_id, ref):
            return ref.get("user") and ref["user"].get("id") == user_id

        def tenant_matches(tenant_id, ref):
            return (tenant_id is None) or (ref.get("tenant") and ref["tenant"].get("id") == tenant_id)

        tokens = []
        now = timeutils.utcnow()
        for token, ref in self.db.items():
            if not token.startswith("token-") or self.is_expired(now, ref):
                continue
            else:
                if user_matches(user_id, ref) and tenant_matches(tenant_id, ref):
                    tokens.append(token.split("-", 1)[1])
        return tokens
Пример #9
0
    def _list_tokens_for_user(self, user_id, tenant_id=None):
        def user_matches(user_id, ref):
            return ref.get('user') and ref['user'].get('id') == user_id

        def tenant_matches(tenant_id, ref):
            return ((tenant_id is None)
                    or (ref.get('tenant')
                        and ref['tenant'].get('id') == tenant_id))

        tokens = []
        now = timeutils.utcnow()
        for token, ref in self.db.items():
            if not token.startswith('token-') or self.is_expired(now, ref):
                continue
            else:
                if (user_matches(user_id, ref)
                        and tenant_matches(tenant_id, ref)):
                    tokens.append(token.split('-', 1)[1])
        return tokens
Пример #10
0
    def _list_tokens_for_user(self, user_id, tenant_id=None):
        def user_matches(user_id, ref):
            return ref.get('user') and ref['user'].get('id') == user_id

        def tenant_matches(tenant_id, ref):
            return ((tenant_id is None) or
                    (ref.get('tenant') and
                     ref['tenant'].get('id') == tenant_id))

        tokens = []
        now = timeutils.utcnow()
        for token, ref in self.db.items():
            if not token.startswith('token-') or self.is_expired(now, ref):
                continue
            else:
                if (user_matches(user_id, ref) and
                        tenant_matches(tenant_id, ref)):
                        tokens.append(token.split('-', 1)[1])
        return tokens
Пример #11
0
 def list_tokens(self, user_id, tenant_id=None):
     tokens = []
     now = datetime.datetime.utcnow()
     for token, ref in self.db.items():
         if not token.startswith('token-'):
             continue
         if 'user' not in ref:
             continue
         if ref['user'].get('id') != user_id:
             continue
         if ref.get('expires') and ref.get('expires') < now:
             continue
         if tenant_id is not None:
             if 'tenant' not in ref:
                 continue
             if ref['tenant'].get('id') != tenant_id:
                 continue
         tokens.append(token.split('-', 1)[1])
     return tokens
Пример #12
0
 def list_tokens(self, user_id, tenant_id=None):
     tokens = []
     now = timeutils.utcnow()
     for token, ref in self.db.items():
         if not token.startswith('token-'):
             continue
         if 'user' not in ref:
             continue
         if ref['user'].get('id') != user_id:
             continue
         if ref.get('expires') and ref.get('expires') < now:
             continue
         if tenant_id is not None:
             if 'tenant' not in ref:
                 continue
             if ref['tenant'].get('id') != tenant_id:
                 continue
         tokens.append(token.split('-', 1)[1])
     return tokens
Пример #13
0
 def list_tokens(self, user_id, tenant_id=None):
     tokens = []
     now = timeutils.utcnow()
     for token, ref in self.db.items():
         if not token.startswith('token-'):
             continue
         user = ref.get('user')
         if not user:
             continue
         if user.get('id') != user_id:
             continue
         if ref.get('expires') and ref.get('expires') < now:
             continue
         if tenant_id is not None:
             tenant = ref.get('tenant')
             if not tenant:
                 continue
             if tenant.get('id') != tenant_id:
                 continue
         tokens.append(token.split('-', 1)[1])
     return tokens