I recently set up an instance of Kanboard using this plugin to sign in users through Slack. As part of the set-up, I wanted to have users grouped by the id of the workspace associated with their slack account. The Slack userInfo response does include this information under the key https://slack.com/team_id, so I configured the "Groups Key" to be https://slack.com/team_id.
However, this created two issues:
The key https://slack.com/team_id contains a '.', causing the GenericOAuth2UserProvider::getKey function to split it up. Essentially, the plugin thought that the key was referring to a member of a sub-object of the response, when it was actually just a literal '.' in the key.
Once I fixed 1, I was still getting a crash. Turns out, the plugin expects the data returned from the "Groups Key" to be an array of groups. However, I was just getting a literal string, causing array_unique to throw an error.
My solution is the following:
Add a configuration option to disable splitting keys. None of my keys are composite, so I don't need the splitting functionality. So I added the oauth2_split_keys setting, which will disable key splitting when set to '0'.
Wrap the $groups in an array if it is not already an array. That way, if the "Groups Key" returns just a single group, it will be automatically wrapped into an array of length 1.
I recently set up an instance of Kanboard using this plugin to sign in users through Slack. As part of the set-up, I wanted to have users grouped by the id of the workspace associated with their slack account. The Slack userInfo response does include this information under the key
https://slack.com/team_id
, so I configured the "Groups Key" to behttps://slack.com/team_id
.However, this created two issues:
https://slack.com/team_id
contains a '.', causing the GenericOAuth2UserProvider::getKey function to split it up. Essentially, the plugin thought that the key was referring to a member of a sub-object of the response, when it was actually just a literal '.' in the key.array_unique
to throw an error.My solution is the following:
oauth2_split_keys
setting, which will disable key splitting when set to '0'.$groups
in an array if it is not already an array. That way, if the "Groups Key" returns just a single group, it will be automatically wrapped into an array of length 1.