SU-SWS / stanford_ssp

Drupal module for configuring SimpleSAMLphp in Stanford web environments
GNU General Public License v2.0
9 stars 8 forks source link

DEVOPS-261: modified array if only one member in workgroup #100

Closed boznik closed 3 years ago

boznik commented 3 years ago

READY FOR REVIEW

Summary

Review By (Date)

Urgency

Review Tasks

Setup tasks and/or behavior to test

  1. Setup local to login with saml on d7.
  2. Check out this branch
  3. Map administrator role to a workgroup with only one member
  4. Verify that upon login with the one member in the workgroup, the role is assigned.
  5. Add another member to the workgroup and verify that upon login, the role is still assigned.
jbickar commented 3 years ago

I did not get to this today due to Drupal core security advisories. I am requesting a review from @pookmish or @sherakama , or for them to delegate to any one of the other back-end devs.

Local SAML setup is not required; this code can be pushed to any dev environment and tested via the steps that Greg has listed.

The code looks like it makes sense to me. @boznik , you are responsible for owning this to resolution. Please follow up with Mike and Shea in my absence.

sherakama commented 3 years ago

Which workgroups are you using for testing?

boznik commented 3 years ago

i setup my own ~ggarvey:ggarvey so i could control the members.

sherakama commented 3 years ago

I'm not seeing a difference in structure in the API response.

https://aswsweb.stanford.edu/mais/workgroupsvc/v1/workgroups/~ggarvey:ggarvey

<?xml version="1.0" encoding="UTF-8"?>
<workgroup>
    <description>Personal workgroup for web development.</description>
    <filter />
    <visibility>STANFORD</visibility>
    <reusable>TRUE</reusable>
    <privgroup>TRUE</privgroup>
    <members>
        <member id="jbickar" url="https://workgroupsvc.stanford.edu/v1/users/jbickar" name="Bickar, John" />
        <member id="ggarvey" url="https://workgroupsvc.stanford.edu/v1/users/ggarvey" name="Garvey, Greg" />
    </members>
    <administrators>
        <member id="ggarvey" url="https://workgroupsvc.stanford.edu/v1/users/ggarvey" name="Garvey, Greg" />
    </administrators>
</workgroup>

https://aswsweb.stanford.edu/mais/workgroupsvc/v1/workgroups/~sheamck:sheamck

<?xml version="1.0" encoding="UTF-8"?>
<workgroup>
    <description>My test workgroup</description>
    <filter />
    <visibility>STANFORD</visibility>
    <reusable>TRUE</reusable>
    <privgroup>TRUE</privgroup>
    <members>
        <member id="sheamck" url="https://workgroupsvc.stanford.edu/v1/users/sheamck" name="McKinney, Shea" />
    </members>
    <administrators>
        <member id="sheamck" url="https://workgroupsvc.stanford.edu/v1/users/sheamck" name="McKinney, Shea" />
    </administrators>
</workgroup>

https://workgroupsvc-uat.stanford.edu/v1/workgroups/~jbickar:jbickar

<?xml version="1.0" encoding="UTF-8"?>
<workgroup>
    <description>Includes jbickar only</description>
    <filter />
    <visibility>STANFORD</visibility>
    <reusable>FALSE</reusable>
    <privgroup>TRUE</privgroup>
    <members>
        <member id="jbickar" url="https://workgroupsvc-uat.stanford.edu/v1/users/jbickar" name="Bickar, John" />
    </members>
    <administrators>
        <member id="jbickar" url="https://workgroupsvc-uat.stanford.edu/v1/users/jbickar" name="Bickar, John" />
    </administrators>
</workgroup>

https://workgroupsvc.stanford.edu/v1/workgroups/~jbickar:jbickar

<?xml version="1.0" encoding="UTF-8"?>
<workgroup>
    <description>Includes jbickar only</description>
    <filter />
    <visibility>STANFORD</visibility>
    <reusable>FALSE</reusable>
    <privgroup>TRUE</privgroup>
    <members>
        <member id="jbickar" url="https://workgroupsvc.stanford.edu/v1/users/jbickar" name="Bickar, John" />
    </members>
    <administrators>
        <member id="jbickar" url="https://workgroupsvc.stanford.edu/v1/users/jbickar" name="Bickar, John" />
    </administrators>
</workgroup>

Where are you seeing the difference in structure in the response?

pookmish commented 3 years ago

Oh its not a difference in the API response, its the way the xml is parsed image

pookmish commented 3 years ago

That's just the way this works:

  $xml = simplexml_load_string($response);
  $json = json_encode($xml);
  $values = json_decode($json, TRUE);
sherakama commented 3 years ago

Ah so it is something in simplexml_load_string. I wonder if there is an option to normalize that behavior.

pookmish commented 3 years ago

https://stackoverflow.com/questions/23766159/php-simplexml-arrays-generated-differently-for-single-child-and-multiple-child

Probably not worth the effort for the D7 stuff.

sherakama commented 3 years ago

That is a ball of wax. Ok.

sherakama commented 3 years ago

Thanks for splainin'