Check if cas:memberOf is a string
if cas:memberOf comes from a LDAP directory, each entry contains commas. In our case, we use multiple memberOf tags to address this issue, so attributes["cas:memberOf"] is not a string.
This commit is contained in:
parent
10ee70466a
commit
4760019e80
1 changed files with 5 additions and 5 deletions
|
@ -122,13 +122,13 @@ def validate(ticket):
|
|||
current_app.logger.debug("valid")
|
||||
xml_from_dict = xml_from_dict["cas:serviceResponse"]["cas:authenticationSuccess"]
|
||||
username = xml_from_dict["cas:user"]
|
||||
attributes = xml_from_dict.get("cas:attributes", {})
|
||||
attributes = xml_from_dict["cas:attributes"]
|
||||
|
||||
if "cas:memberOf" in attributes:
|
||||
attributes["cas:memberOf"] = attributes["cas:memberOf"].lstrip('[').rstrip(']').split(',')
|
||||
for group_number in range(0, len(attributes['cas:memberOf'])):
|
||||
attributes['cas:memberOf'][group_number] = attributes['cas:memberOf'][group_number].lstrip(' ').rstrip(' ')
|
||||
|
||||
if isinstance(attributes["cas:memberOf"], basestring):
|
||||
attributes["cas:memberOf"] = attributes["cas:memberOf"].lstrip('[').rstrip(']').split(',')
|
||||
for group_number in range(0, len(attributes['cas:memberOf'])):
|
||||
attributes['cas:memberOf'][group_number] = attributes['cas:memberOf'][group_number].lstrip(' ').rstrip(' ')
|
||||
flask.session[cas_username_session_key] = username
|
||||
flask.session[cas_attributes_session_key] = attributes
|
||||
else:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue