Ejemplo n.º 1
0
def _create_user(username, attributes):
    user_creator = getattr(settings, 'CAS_USER_CREATOR', None)
    if isinstance(user_creator, basestring):
        user_creator = import_string(user_creator)

    if user_creator:
        return user_creator(username, attributes)
    else:
        user = User(username=username, email=username)
        user.set_unusable_password()

        if attributes and _CAS_USER_DETAILS_RESOLVER:
            _CAS_USER_DETAILS_RESOLVER(user, attributes)
        user.save()
        return user
Ejemplo n.º 2
0
    def authenticate(self, ticket, service):
        """Verifies CAS ticket and gets or creates User object
           NB: Use of PT to identify proxy
        """
        username, authentication_response = _verify(ticket, service)

        if not username:
            return None

        try:
            user = User.objects.get(email=username)
        except User.DoesNotExist:
            u_name = username
            user = User(username=u_name, email=username)
            user.set_unusable_password()

        try:
            # get user's full name from authentication response(xml tree)
            user.first_name = authentication_response[0][1].find(CAS + 'first_name').text
            user.last_name = authentication_response[0][1].find(CAS + 'last_name').text
        except IndexError:
            pass

        if authentication_response and _CAS_USER_DETAILS_RESOLVER:
            _CAS_USER_DETAILS_RESOLVER(user, authentication_response)

        user.save()
        return user
Ejemplo n.º 3
0
    def authenticate(self, ticket, service):
        """Verifies CAS ticket and gets or creates User object
           NB: Use of PT to identify proxy
        """
        username, authentication_response = _verify(ticket, service)
        if not username:
            return None

        try:
            user = User.objects.get(username=username)
        except User.DoesNotExist:
            user = User(username=username, email=username)
            user.set_unusable_password()

        if authentication_response and _CAS_USER_DETAILS_RESOLVER:
            _CAS_USER_DETAILS_RESOLVER(user, authentication_response)

        user.save()
        return user
Ejemplo n.º 4
0
def _create_user(username, attributes):
    user_creator = getattr(settings, 'CAS_USER_CREATOR', None)
    if isinstance(user_creator, basestring):
        user_creator = import_string(user_creator)

    if user_creator:
        return user_creator(username, attributes)
    else:
        user = User(username=username, email=username)
        user.set_unusable_password()

        if attributes and _CAS_USER_DETAILS_RESOLVER:
            _CAS_USER_DETAILS_RESOLVER(user, attributes)
        user.save()
        return user
Ejemplo n.º 5
0
    def authenticate(self, ticket, service):
        """Verifies CAS ticket and gets or creates User object
           NB: Use of PT to identify proxy
        """
        username, authentication_response = _verify(ticket, service)
        if not username:
            return None

        try:
            user = User.objects.get(username=username)
        except User.DoesNotExist:
            user = User(username=username, email=username)
            user.set_unusable_password()

        if authentication_response and _CAS_USER_DETAILS_RESOLVER:
            _CAS_USER_DETAILS_RESOLVER(user, authentication_response)

        user.save()
        return user