Skip to content

ROX-11070: Handle ID of groups within UI.#2075

Merged
dhaus67 merged 13 commits intomasterfrom
dh/06-15-Handle_ID_of_groups_within_UI
Jul 4, 2022
Merged

ROX-11070: Handle ID of groups within UI.#2075
dhaus67 merged 13 commits intomasterfrom
dh/06-15-Handle_ID_of_groups_within_UI

Conversation

@dhaus67
Copy link
Contributor

@dhaus67 dhaus67 commented Jun 14, 2022

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

  • see CI (existing tests regarding auth providers should still pass).

Manual testing

  1. Create an auth provider, use minimum access role None.
    Screenshot 2022-06-15 at 01 45 30
  2. Configure multiple rules with the same attribute key and values, but different role mappings.
    Screenshot 2022-06-15 at 01 55 22
  3. Login with the configured user and observe multiple roles being assigned.
    Screenshot 2022-06-15 at 01 56 13

@openshift-ci
Copy link

openshift-ci bot commented Jun 14, 2022

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@dhaus67
Copy link
Contributor Author

dhaus67 commented Jun 14, 2022

@ghost
Copy link

ghost commented Jun 15, 2022

Tag for build #729988 is 3.70.x-576-g7db44503a4.

💻 For deploying this image using the dev scripts, run the following first:

export MAIN_IMAGE_TAG='3.70.x-576-g7db44503a4'

🕹️ A roxctl binary can be downloaded from the CircleCI artifacts.

Copy link
Contributor

@vjwilson vjwilson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine to me (just minor nit and question about API usage)

I'd like @pedrottimark to check it, too.

}
});
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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}`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought that 'empty' and 'absence' will map to the same logical situation: don't filter by this field.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@vjwilson vjwilson requested a review from pedrottimark June 15, 2022 13:49
@dhaus67 dhaus67 force-pushed the dh/06-14-Update_service_and_datastore branch from f4894c6 to cf7585b Compare June 15, 2022 14:03
@dhaus67 dhaus67 force-pushed the dh/06-15-Handle_ID_of_groups_within_UI branch from 98627b2 to d71d74b Compare June 15, 2022 14:04
@dhaus67 dhaus67 force-pushed the dh/06-14-Update_service_and_datastore branch from cfccb5a to 9ac311b Compare June 15, 2022 18:48
@dhaus67 dhaus67 force-pushed the dh/06-15-Handle_ID_of_groups_within_UI branch from d71d74b to bfbce16 Compare June 15, 2022 18:48
@dhaus67 dhaus67 requested a review from vjwilson June 17, 2022 21:39
Copy link
Contributor

@vjwilson vjwilson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@dhaus67 dhaus67 force-pushed the dh/06-14-Update_service_and_datastore branch from 9ac311b to e4f75d9 Compare June 22, 2022 23:21
@dhaus67 dhaus67 force-pushed the dh/06-15-Handle_ID_of_groups_within_UI branch from bfbce16 to ffa4b84 Compare June 22, 2022 23:21
@dhaus67 dhaus67 force-pushed the dh/06-14-Update_service_and_datastore branch from e4f75d9 to f642da0 Compare June 23, 2022 23:52
@dhaus67 dhaus67 force-pushed the dh/06-15-Handle_ID_of_groups_within_UI branch from ffa4b84 to 437d113 Compare June 23, 2022 23:52
@dhaus67 dhaus67 requested a review from a team June 30, 2022 00:58
@dhaus67 dhaus67 removed the request for review from a team June 30, 2022 00:58
*/
export function getDefaultGroup({ authProviderId, roleName }) {
return axios
.get(`${url}?authProviderId=${authProviderId}&key=&value=&roleName=${roleName}`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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?

Copy link
Contributor Author

@dhaus67 dhaus67 Jun 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

@dhaus67 dhaus67 Jul 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vjwilson @dhaus67 Let's restrict the API to at most one default rule / group per auth provider. @dhaus67 could you please send a new PR in this chain for this?

@dhaus67 dhaus67 force-pushed the dh/06-14-Update_service_and_datastore branch from f642da0 to 6d061fe Compare June 30, 2022 21:03
@dhaus67 dhaus67 force-pushed the dh/06-15-Handle_ID_of_groups_within_UI branch from 437d113 to 9381fe0 Compare June 30, 2022 21:03
@dhaus67 dhaus67 requested a review from rukletsov July 1, 2022 04:52
@dhaus67 dhaus67 force-pushed the dh/06-14-Update_service_and_datastore branch from 6d061fe to c5828e5 Compare July 4, 2022 02:42
@dhaus67 dhaus67 force-pushed the dh/06-15-Handle_ID_of_groups_within_UI branch from 9381fe0 to 666fb17 Compare July 4, 2022 02:42
@dhaus67 dhaus67 force-pushed the dh/06-15-Handle_ID_of_groups_within_UI branch from 666fb17 to 7db4450 Compare July 4, 2022 12:13
Base automatically changed from dh/06-14-Update_service_and_datastore to master July 4, 2022 19:18
@ghost
Copy link

ghost commented Jul 4, 2022

Images are ready for the commit at 7db4450.

To use with deploy scripts, first export MAIN_IMAGE_TAG=3.70.x-580-g10ae8ade93.

@dhaus67 dhaus67 merged commit a149f5b into master Jul 4, 2022
@dhaus67 dhaus67 deleted the dh/06-15-Handle_ID_of_groups_within_UI branch July 4, 2022 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants