ROX-11070: Handle ID of groups within UI.#2075
Conversation
|
Skipping CI for Draft Pull Request. |
|
Current dependencies on/for this PR:
This comment was auto-generated by Graphite. |
|
Tag for build #729988 is 💻 For deploying this image using the dev scripts, run the following first: export MAIN_IMAGE_TAG='3.70.x-576-g7db44503a4'🕹️ A |
vjwilson
left a comment
There was a problem hiding this comment.
Seems fine to me (just minor nit and question about API usage)
I'd like @pedrottimark to check it, too.
| } | ||
| }); | ||
| } | ||
|
|
There was a problem hiding this comment.
nit: Try not to let your editor take out single blank lines. This one give some visual separation of the return statement from the logic of the function, which aid in "scanning" the code late.
| */ | ||
| export function getDefaultGroup({ authProviderId, roleName }) { | ||
| return axios | ||
| .get(`${url}?authProviderId=${authProviderId}&key=&value=&roleName=${roleName}`) |
There was a problem hiding this comment.
Does the API require us to spend a key and value with blank values specifically?
Seems unnecessary--is it a limitation of the proto system?
There was a problem hiding this comment.
It's not a limitation of the API, rather the following:
We are fetching the default group here, which has the following characteristics:
Only the auth provider ID is set within the properties, both key and value are empty, and the role name has to match.
Hence, the explicitly empty key and value within the query, otherwise this would not be needed.
Since we are talking about it, it seems to need additional clarification, I've added a comment explaining more the reason as to why both key and value are specified as empty explicitly.
There was a problem hiding this comment.
I thought that 'empty' and 'absence' will map to the same logical situation: don't filter by this field.
There was a problem hiding this comment.
No, surprisingly not.
Say you have two groups:
{"props":{"authProviderId":"0ceed22f-026f-41a2-9d91-96410e4c4846","key":"","value":""},"roleName":"Scope Manager"}
{"props":{"authProviderId":"0ceed22f-026f-41a2-9d91-96410e4c4846","key":"email","value":"something"},"roleName":"Scope Manager"}both groups are mapping to the role name Scope Manager.
Executing a request, i.e. via curl, you will retrieve the following without explicit empty fields:
curl <endpoint>/v1/groups?authProviderId=0ceed22f-026f-41a2-9d91-96410e4c4846&roleName="Scope Manager"
response:
{"groups":[{"props":{"authProviderId":"0ceed22f-026f-41a2-9d91-96410e4c4846","key":"","value":""},"roleName":"Scope Manager"},{"props":{"authProviderId":"0ceed22f-026f-41a2-9d91-96410e4c4846","key":"email","value":"something"},"roleName":"Scope Manager"}]}
Instead, if you execute the request with explicitly setting key and value to empty strings, you will receive the following:
curl <endpoint>/v1/groups?authProviderId=0ceed22f-026f-41a2-9d91-96410e4c4846&roleName="Scope Manager"&key=&value=
response:
{"groups":[{"props":{"authProviderId":"0ceed22f-026f-41a2-9d91-96410e4c4846","key":"","value":""},"roleName":"Scope Manager"}]}
TL;DR: we do need to explicitly set those, otherwise we return other groups that are not the default created one.
f4894c6 to
cf7585b
Compare
98627b2 to
d71d74b
Compare
cfccb5a to
9ac311b
Compare
d71d74b to
bfbce16
Compare
9ac311b to
e4f75d9
Compare
bfbce16 to
ffa4b84
Compare
e4f75d9 to
f642da0
Compare
ffa4b84 to
437d113
Compare
| */ | ||
| export function getDefaultGroup({ authProviderId, roleName }) { | ||
| return axios | ||
| .get(`${url}?authProviderId=${authProviderId}&key=&value=&roleName=${roleName}`) |
There was a problem hiding this comment.
I thought that 'empty' and 'absence' will map to the same logical situation: don't filter by this field.
| return axios | ||
| .get(`${url}?authProviderId=${authProviderId}&key=&value=&roleName=${roleName}`) | ||
| .then((response) => ({ | ||
| response: response.data?.groups[0], |
There was a problem hiding this comment.
Does this mean that if multiple default groups have been created (should be possible now from the backend perspective, e.g., via curl), a batch group request will delete all except the one that we stored here? Looks like a bug.
There was a problem hiding this comment.
@rukletsov Can you elaborate on what you now expect for multiple default groups?
Just because it is technically possible through the API, is it a requirement, or even an option, that we need to expose to customers?
The current UI has one form input, labelled "Minimum access role" that only allows you select one role from a list. Has this requirement changed?
There was a problem hiding this comment.
@rukletsov
While I agree it's technically possible to do so, I feel like we should be more strict on the datastore regarding this ambiguity.
I don't think we are ready to change requirements in the UI for this, i.e. allowing multiple "Minimum access roles" to be set (which would turn out to be multiple default groups) nor do I personally want this, from a user point of view it would be confusing.
Instead, if we decide to do anything, I feel we should restrict the API. Iff the client creates a group with only the auth provider ID set, it's not possible to do so when another group with only the same auth provider ID set exists. This way, we wouldn't have to deal with the ambiguity in the UI, can keep it as-is, and don't have to worry about potentially removing default groups here. However, this would mean we restrict the behavior from the API.
Otherwise, if we decide to change anything in the UI, how would you even know which default group to change? Let's say you have multiple groups with the same role name (which is what you would yield here): which group is the one originally created, and which is the one not and shouldn't be changed?
There was a problem hiding this comment.
If you will forgive a question out of an abundance of ignorance, is there any situation in which groups might be an empty array? Or more relevant, any situation which a user can cause to happen?
Apparently yes, because getGroupsWithDefault function has conditional logic for the situation:
// The default group is not yet created, meaning we have to make sure we create it here.
// Set the auth provider ID and role name.
// Use the default group if we receive a value here.There was a problem hiding this comment.
This is one of the most important files in services folder that is still JavaScript. Adding types/group.proto.ts and rewriting this file in TypeScript might be a good collaborative follow up for UI and Merlin in 72.
There was a problem hiding this comment.
@pedrottimark Yes, this may happen.
It could be, as you rightly mentioned, that the auth provider is currently eing created and the default group has not been created yet or the default group has been deleted via API (which is unlikely, but still possible).
I agree on the collaborative effort to migrate this to typescript, it would certainly make life better. I've created ROX-11600 for that with the aim to complete it within 3.72.
f642da0 to
6d061fe
Compare
437d113 to
9381fe0
Compare
…ID to be set. Fix failing tests.
…ne before setting values on properties.
…ore, minor comments).
6d061fe to
c5828e5
Compare
9381fe0 to
666fb17
Compare
666fb17 to
7db4450
Compare
|
Images are ready for the commit at 7db4450. To use with deploy scripts, first |

Description
This is the third PR in a series of PRs regarding removing the composite key from the groups datastore, allowing users to specify different roles for the same group properties.
For full context, you can navigate to the previous PRs by using the comment created below.
This PR will update the UI to include the ID of the default role when creating auth providers, as well as update the group object to include the ID within the properties.
Testing Performed
Manual testing
None.