Issue with SSO and media plugin causing errors and broken editing in Sanity installation.
14 replies
Last updated: Jun 15, 2021
T
I have a sanity installation setup with SSO which has worked great for the last 6 months. Today i installed the media plugin (https://www.sanity.io/plugins/sanity-plugin-media ) and now things really don’t work anymore. Right after login i am greeted with an error prompt saying: “Error: Unauthorized - User must be a member of this project to perform this operation”. From the console output and network log, it looks like this error is due to a HTTP 401 response after a call to https://PROJECT_ID.api.sanity.io/v2021-06-07/projects/PROJECT_ID/datasets/DATASET_NAME/acl?tag=sanity.studio.acl.get I am running the latest version of sanity (ran sanity upgrade). Editing is completely broken and giving me an error message of: “undefined is not an object (evaluating ‘currentUser.roles.length’)“. Any suggestions on where to go from here?
Jun 14, 2021, 5:38 PM
R
Hey
That said (and just spitballing here):
- Does the issue still persist when you uninstall
- If you are seeing this locally, have you tried running
user F
– this seems like more of an ACL / auth issue rather than something tied specifically to the pluginThat said (and just spitballing here):
- Does the issue still persist when you uninstall
sanity-plugin-media? - Are you seeing the issue locally or on a deployed studio?
- If you are seeing this locally, have you tried running
sanity logoutand then
sanity login? (It could be the case you’re logged into another project’s Studio)
Jun 14, 2021, 5:58 PM
T
Yes, i agree, but just wanted to mention it in case it was related somehow. Seeing this locally, so i will try it in an test environment.
sanity logindoesn’t really work with SSO, since there is no “SSO” option.
Jun 14, 2021, 6:04 PM
T
So, i did a little more digging. Initial finding is that the “desk tool” still crashes when i go to open/edit a document. The error output is from
Adding a console log i see that currentUser does not have a
PermissionCheckBannerand it now says: “Cannot read property ‘length’ of undefined”. This is the line which fails :
var plural = (currentUser === null || currentUser === void 0 ? void 0 : currentUser.roles.length) !== 1;
rolesproperty, but instead a
roleproperty with the value of
editoras a string.
Jun 14, 2021, 6:58 PM
T
And the
roleproperty with a value of
editori assume is linked to this guide: https://www.sanity.io/docs/third-party-login#generating-sanity-tokens-ca87073af0ca So somewhere, an array must be added perhaps instead of a string? :)
Jun 14, 2021, 7:00 PM
T
This is on v 2.11.1 of the desk-tool by the way
Jun 15, 2021, 7:05 AM
Ahhh, this makes sense. Thanks for digging into it, will see if we can add a fix for this asap
Jun 15, 2021, 10:53 AM
T
Well, things have changed so it seems editing works, but i now get a 500 internal server error when Sanity Studio loads the previous mentioned
/aclurl
Jun 15, 2021, 2:08 PM
🕵️♂️ I'm seeing a bug where system groups has an unexpected shape - one that doesn't have a
membersarray. Pushing out a fix shortly
Jun 15, 2021, 2:42 PM
T
Yes, looking and working great now. Thanks 🙂
Jun 15, 2021, 4:32 PM
Sanity– build remarkable experiences at scale
Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.