Пример #1
0
 def save(self, profile_callback=None):
     """
     Create the new ``User`` and ``RegistrationProfile``, and
     returns the ``User``.
     
     This is essentially a light wrapper around
     ``RegistrationProfile.objects.create_inactive_user()``,
     feeding it the form data and a profile callback (see the
     documentation on ``create_inactive_user()`` for details) if
     supplied.
     
     """
     ssl_info = SSLInfo(self.request)
     if not ssl_info.cert:
         raise ValueError('Missing cert')
     new_user = User.objects.create_user(
             username=self.cleaned_data['username'],
             email=self.cleaned_data['email'])
     new_user.backend = 'authentic2.auth2_auth.auth2_ssl.backend.SSLBackend'
     cert = ClientCertificate()
     cert.user = new_user
     cert.cert = ssl_info.cert
     cert.save()
     # Automatically log in the new user
     login(self.request, new_user)
     return new_user
Пример #2
0
 def save(self, profile_callback=None):
     """
     Create the new ``User`` and ``RegistrationProfile``, and
     returns the ``User``.
     
     This is essentially a light wrapper around
     ``RegistrationProfile.objects.create_inactive_user()``,
     feeding it the form data and a profile callback (see the
     documentation on ``create_inactive_user()`` for details) if
     supplied.
     
     """
     ssl_info = SSLInfo(self.request)
     if not ssl_info.cert:
         raise ValueError('Missing cert')
     new_user = User.objects.create_user(
         username=self.cleaned_data['username'],
         email=self.cleaned_data['email'])
     new_user.backend = 'authentic2.auth2_auth.auth2_ssl.backend.SSLBackend'
     cert = ClientCertificate()
     cert.user = new_user
     cert.cert = ssl_info.cert
     cert.save()
     # Automatically log in the new user
     login(self.request, new_user)
     return new_user
Пример #3
0
    def link_user(self, ssl_info, user):
        """
        This method creates a new django User and ClientCertificate record
        for the passed certificate info. It does not create an issuer record,
        just a subject for the ClientCertificate.
        """
        if not user:
            return none

        # auto creation only created a DN for the subject, not the issuer
        subject = DistinguishedName()
        for attr, val in ssl_info.get_subject().iteritems():
            if not val: val = ''
            subject.__setattr__(attr.replace('subject_', ''), val)
        subject.save()

        # get username and check if the user exists already
        if settings_get('SSLAUTH_CREATE_USERNAME_CALLBACK'):
            build_username = settings_get('SSLAUTH_CREATE_USERNAME_CALLBACK')
        else:
            build_username = self.build_username

        # create the certificate record and save
        cert = ClientCertificate()
        cert.user = user
        cert.subject = subject
        if ssl_info.cert:
            cert.cert = ssl_info.cert
        if ssl_info.serial:
            cert.serial = ssl_info.serial
        cert.save()

        return user
Пример #4
0
    def link_user(self, ssl_info, user):
        """
        This method creates a new django User and ClientCertificate record
        for the passed certificate info. It does not create an issuer record,
        just a subject for the ClientCertificate.
        """
        if not user:
            return none

        # auto creation only created a DN for the subject, not the issuer
        subject = DistinguishedName()
        for attr,val in ssl_info.get_subject().iteritems():
            if not val: val = ''
            subject.__setattr__(attr.replace('subject_',''), val)
        subject.save()

        # get username and check if the user exists already
        if settings_get('SSLAUTH_CREATE_USERNAME_CALLBACK'):
            build_username = settings_get('SSLAUTH_CREATE_USERNAME_CALLBACK')
        else:
            build_username = self.build_username

        # create the certificate record and save
        cert = ClientCertificate()
        cert.user = user
        cert.subject = subject
        if ssl_info.cert:
            cert.cert = ssl_info.cert
        if ssl_info.serial:
            cert.serial = ssl_info.serial
        cert.save()

        return user
Пример #5
0
    def link_user(self, ssl_info, user):
        """
        This method creates a new django User and ClientCertificate record
        for the passed certificate info. It does not create an issuer record,
        just a subject for the ClientCertificate.
        """
        if not user:
            return None

        # auto creation only created a DN for the subject, not the issuer
        subject = DistinguishedName()
        for attr,val in ssl_info.get_subject().iteritems():
            if not val: val = ''
            subject.__setattr__(attr.replace('subject_',''), val)
        subject.save()

        # create the certificate record and save
        cert = ClientCertificate()
        cert.user = user
        cert.subject = subject
        if ssl_info.cert:
            cert.cert = ssl_info.cert
        if ssl_info.serial:
            cert.serial = ssl_info.serial
        cert.save()

        return user