optionally split Shibboleth affiliation and return first or last value#8880
optionally split Shibboleth affiliation and return first or last value#8880pdurbin merged 27 commits intoIQSS:developfrom
Conversation
…an and English. Split and use only English affiliation.
…eter shibAffiliationOrder
…meter shibAffiliationOrder
…meter shibAffiliationOrder
…meter "shibAffiliationOrder" And "affiliationSeparator"
…eter "shibAffiliationOrder" And "affiliationSeparator"
src/main/java/edu/harvard/iq/dataverse/settings/SettingsServiceBean.java
Outdated
Show resolved
Hide resolved
src/main/java/edu/harvard/iq/dataverse/settings/SettingsServiceBean.java
Show resolved
Hide resolved
src/main/java/edu/harvard/iq/dataverse/settings/SettingsServiceBean.java
Show resolved
Hide resolved
System.out.print changed to logger.info Co-authored-by: Philip Durbin <philipdurbin@gmail.com>
…ndations folowing pull request 8880
|
@pdurbin Thank you for your comments. I think i solved all the issues, nevertheless please feel free to get back to me if more changes are required. |
Co-authored-by: Philip Durbin <philipdurbin@gmail.com>
placed .. _:ComputeBaseUrl: at the proper location
|
@pdurbin I took care of the issues you pointed out. I am not sure what went wrong with the indentations but it should look a lot more consistent now. |
|
Hi @Louis-wr , for this next sprint we are catching up on Community PRs. Would you mind updating/ refreshing thiis PR from develop? Thanks! |
|
@scolapasta done, let me know if you need anything else. |
|
Huh. I clicked the button to run the API tests (they don't run automatically for first-time pull request authors) and HarvestingServerIT.testOaiFunctionality is failing according to https://jenkins.dataverse.org/job/IQSS-Dataverse-Develop-PR/job/PR-8880/17/testReport/junit/edu.harvard.iq.dataverse.api/HarvestingServerIT/testOaiFunctionality/ I know @Louis-wr (and anyone off campus) can't see Jenkins due to a firewall but here's a screenshot: Let me ask about re-running the tests or maybe kick off a new run myself. UPDATE: We're seeing this test failing on the develop branch as well. As I suspected, this failure is unrelated to this pull request. All the other API tests for this pull request succeeded. UPDATE 2: I opened an issue for the harvest test failure: |
Hello, Also as this anything to do with this error ? from https://github.com/IQSS/dataverse/runs/8014075879?check_suite_focus=true |
|
Hmm, I'm not too worried about the "Guides Build Status" failure because the OTHER guides job ("docs/readthedocs...") passed and built docs that look good: https://dataverse-guide--8880.org.readthedocs.build/en/8880/installation/config.html#shibaffiliationorder By the way I opened #8937 about the first error I mentioned about harvesting. It definitely has nothing to do with this pull request. |
|
@Louis-wr I'm having a little trouble testing this PR. Rather than setting up all of Shibboleth on a server, I'm using the method described at https://guides.dataverse.org/en/5.11.1/developers/remote-users.html First, I add a shib auth provider: $ cat shibAuthProvider.json $ curl -X POST -H 'Content-type: application/json' --upload-file shibAuthProvider.json http://localhost:8080/api/admin/authenticationProviders Then I set the "debug shib" setting, starting with "random": $ curl http://localhost:8080/api/admin/settings/:DebugShibAccountType -X PUT -d RANDOM However, when I go to http://localhost:8080/shib.xhtml and click "Create Account" I get this stacktrace: [2022-09-07T13:31:43.220-0400] [Payara 5.2022.3] [WARNING] [] [javax.enterprise.web] [tid: _ThreadID=120 _ThreadName=http-thre Here's line 177: @ErykKul added this recently and might have some ideas of how to get it working with the "shib debug" method above. @Louis-wr meanwhile, I can't push to your branch. This isn't a problem necessarily but if I were able to fix the above I'd probably just push rather than making a pull request against your pull request. Do you want to try the "shib debug" thing above? In addition to "RANDOM" there cases like "TWO_EMAILS" and "INVALID_EMAIL". You could add a case or two having to do with affiliation. |
|
Phew! Ok. I just created DataverseNO#44 which is how I tested this PR. Again, instead of setting up all of Shibboleth on a server, it's much easier to test using the :DebugShibAccountType settings (I just added two cases in that PR). @Louis-wr if you're willing to merge that PR, I'd appreciate it. To test I used that PR to the "two affiliations" case like this: curl http://localhost:8080/api/admin/settings/:DebugShibAccountType -X PUT -d TWO_AFFILIATIONS That PR relies on setting the affiliation attribute to "ou" like this: curl http://localhost:8080/api/admin/settings/:ShibAffiliationAttribute -X PUT -d "ou" I left the separator undefined to get ";". Setting it should be fine. Here are the two affiliations at login ("SNPP;Stonecutters"): Likewise if you just look at the account page, you can see both affiliations, separated by a semicolon: Now, if you say you want the last affiliation, it works: curl -X PUT -d "lastAffiliation" http://localhost:8080/api/admin/settings/:ShibAffiliationOrder It also works to request the first affiliation: curl -X PUT -d "firstAffiliation" http://localhost:8080/api/admin/settings/:ShibAffiliationOrder I'm satisfied enough to move this to QA but again @Louis-wr please consider merging the PR above. Thanks! |
pdurbin
left a comment
There was a problem hiding this comment.
Works fine. See comments. I'd like for DataverseNO#44 to be merged into this PR because it was useful while testing.
I decided I should actually test this. I set it to "," to be different than the default (";") and it correctly did NOT split curl -X PUT -d "," http://localhost:8080/api/admin/settings/:ShibAffiliationSeparator |
add test cases for shib affiliation IQSS#8882
I've been talking with @ErykKul and he came up with a fix in PR #8969. I haven't played with that code. It wasn't required for me to test this PR. Until a fix like that is merged, you just have to be conscious that you might get errors from Shib with the debug method (and maybe prod Shib?). The work around is to log out and back in so that info about your user comes from the database. It's confusing but out of scope for this PR. I ran the API tests and they passed. I think we're good so I'm merging this. |






What this PR does / why we need it: Feide authentication service returns an array of values. The affiliation in English is expected to be the last element in the array. This modification adds an option to only return the last element of said array.
Which issue(s) this PR closes:
Closes #8882
Special notes for your reviewer:
Suggestions on how to test this: the array is comma separated for example :
"UiT Norges Arktiske Universitet,UiT The Arctic University of Norway"
The separator is set with the following curl command :
curl -X PUT -d "," http://localhost:8080/api/admin/settings/:ShibAffiliationSeparator
The last value is selected using :
curl -X PUT -d "lastAffiliation" http://localhost:8080/api/admin/settings/:ShibAffiliationOrder
will make it so the affiliation is only "UiT The Arctic University of Norway"
The first value is selected using :
curl -X PUT -d "firstAffiliation" http://localhost:8080/api/admin/settings/:ShibAffiliationOrder
will make it so the affiliation is only "UiT Norges Arktiske Universitet"
Does this PR introduce a user interface change? If mockups are available, please link/include them here: NO
Is there a release notes update needed for this change?: YES
New parameter in configuration : :ShibAffiliationOrder
New parameter in configuration : :ShibAffiliationSeparator
Additional documentation:
under database settings
:ShibAffiliationOrder
Returns the last value of an array in affiliations list.
The array is separated using :ShibAffiliationSeparator
curl -X PUT -d "lastAffiliation" http://localhost:8080/api/admin/settings/:ShibAffiliationOrder
:ShibAffiliationSeparator
Set the separator for the affiliation array
Default : ";"
curl -X PUT -d ";" http://localhost:8080/api/admin/settings/:affiliationSeparator