Revision c1f65a1e snf-astakos-app/astakos/im/views/target/shibboleth.py

b/snf-astakos-app/astakos/im/views/target/shibboleth.py
90 90

  
91 91
    try:
92 92
        eppn = tokens.get(Tokens.SHIB_EPPN)
93

  
93
        fullname, first_name, last_name, email = None, None, None, None
94 94
        if global_settings.DEBUG and not eppn:
95 95
            eppn = getattr(global_settings, 'SHIBBOLETH_TEST_EPPN', None)
96
            realname = getattr(global_settings, 'SHIBBOLETH_TEST_REALNAME',
96
            fullname = getattr(global_settings, 'SHIBBOLETH_TEST_FULLNAME',
97 97
                               None)
98 98

  
99 99
        if not eppn:
......
102 102
                'contact_email': settings.CONTACT_EMAIL
103 103
            })
104 104
        if Tokens.SHIB_DISPLAYNAME in tokens:
105
            realname = tokens[Tokens.SHIB_DISPLAYNAME]
105
            fullname = tokens[Tokens.SHIB_DISPLAYNAME]
106 106
        elif Tokens.SHIB_CN in tokens:
107
            realname = tokens[Tokens.SHIB_CN]
108
        elif Tokens.SHIB_NAME in tokens and Tokens.SHIB_SURNAME in tokens:
109
            realname = tokens[Tokens.SHIB_NAME] + ' ' + \
110
                tokens[Tokens.SHIB_SURNAME]
111
        else:
112
            if settings.SHIBBOLETH_REQUIRE_NAME_INFO:
113
                raise KeyError(_(astakos_messages.SHIBBOLETH_MISSING_NAME))
114
            else:
115
                realname = ''
107
            fullname = tokens[Tokens.SHIB_CN]
108
        if Tokens.SHIB_NAME in tokens:
109
            first_name = tokens[Tokens.SHIB_NAME]
110
        if Tokens.SHIB_SURNAME in tokens:
111
            last_name = tokens[Tokens.SHIB_SURNAME]
112

  
113
        if fullname:
114
            splitted = fullname.split(' ', 1)
115
            if len(splitted) == 2:
116
                first_name, last_name = splitted
117
        fullname = '%s %s' % (first_name, last_name)
118

  
119
        if not any([first_name, last_name]) and \
120
                    settings.SHIBBOLETH_REQUIRE_NAME_INFO:
121
            raise KeyError(_(astakos_messages.SHIBBOLETH_MISSING_NAME))
116 122

  
117 123
    except KeyError, e:
118 124
        # invalid shibboleth headers, redirect to login, display message
......
122 128
    affiliation = tokens.get(Tokens.SHIB_EP_AFFILIATION, 'Shibboleth')
123 129
    email = tokens.get(Tokens.SHIB_MAIL, '')
124 130
    eppn_info = tokens.get(Tokens.SHIB_EPPN)
125
    provider_info = {'eppn': eppn_info, 'email': email, 'name': realname,
131
    provider_info = {'eppn': eppn_info, 'email': email, 'name': fullname,
126 132
                     'headers': shibboleth_headers}
127 133
    userid = eppn
128 134

  
......
132 138
                                        affiliation, third_party_key)
133 139
    except AstakosUser.DoesNotExist, e:
134 140
        third_party_key = get_pending_key(request)
135
        user_info = {'affiliation': affiliation, 'realname': realname}
141
        user_info = {'affiliation': affiliation,
142
                     'first_name': first_name,
143
                     'last_name': last_name,
144
                     'email': email}
136 145
        return handle_third_party_signup(request, userid, 'shibboleth',
137 146
                                         third_party_key,
138 147
                                         provider_info,

Also available in: Unified diff