Esempio n. 1
0
 def store_association(cls, server_url, association):
     from social_auth.models import Association
     args = {'server_url': server_url, 'handle': association.handle}
     try:
         assoc = Association.objects.get(**args)
     except Association.DoesNotExist:
         assoc = Association(**args)
     assoc.secret = base64.encodestring(association.secret)
     assoc.issued = association.issued
     assoc.lifetime = association.lifetime
     assoc.assoc_type = association.assoc_type
     assoc.save()
Esempio n. 2
0
 def storeAssociation(self, server_url, association):
     """Store new assocition if doesn't exist"""
     args = {'server_url': server_url, 'handle': association.handle}
     try:
         assoc = Association.objects.get(**args)
     except Association.DoesNotExist:
         assoc = Association(**args)
     assoc.secret = base64.encodestring(association.secret)
     assoc.issued = association.issued
     assoc.lifetime = association.lifetime
     assoc.assoc_type = association.assoc_type
     assoc.save()
Esempio n. 3
0
    def handle(self, *args, **options):
        from social_auth.models import Association
        print('Clearing expired Association instances')
        timestamp = time.time() + Signatory.SECRET_LIFETIME
        associations = Association.objects.filter(issued__lt=timestamp)
        remove = []

        for assoc in associations:
            oid = OIDAssociation(assoc.handle,
                                 base64.decodestring(assoc.secret),
                                 assoc.issued,
                                 assoc.lifetime,
                                 assoc.assoc_type)
            if oid.getExpiresIn() == 0:
                remove.append(assoc.pk)
        if remove:
            print('Cleaning %s Associations' % len(remove))
            Association.filter(pk__in=remove).delete()
        else:
            print('No Associations to remove')
Esempio n. 4
0
 def store_association(cls, server_url, association):
     from social_auth.models import Association
     args = {'server_url': server_url, 'handle': association.handle}
     try:
         assoc = Association.objects.get(**args)
     except Association.DoesNotExist:
         assoc = Association(**args)
     assoc.secret = base64.encodestring(association.secret)
     assoc.issued = association.issued
     assoc.lifetime = association.lifetime
     assoc.assoc_type = association.assoc_type
     assoc.save()
Esempio n. 5
0
 def storeAssociation(self, server_url, association):
     """Store new assocition if doesn't exist"""
     args = {'server_url': server_url, 'handle': association.handle}
     try:
         assoc = Association.objects.get(**args)
     except Association.DoesNotExist:
         assoc = Association(**args)
     assoc.secret = base64.encodestring(association.secret)
     assoc.issued = association.issued
     assoc.lifetime = association.lifetime
     assoc.assoc_type = association.assoc_type
     assoc.save()