Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Custom Applications multiple permissions #2806

Merged
merged 16 commits into from
Dec 9, 2022
Merged

Conversation

kark
Copy link
Contributor

@kark kark commented Sep 15, 2022

Summary

In preparation for the Custom Applications Multiple Permissions support.

Relates to #2799

@changeset-bot
Copy link

changeset-bot bot commented Sep 15, 2022

⚠️ No Changeset found

Latest commit: 17ac6c9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@kark kark changed the title docs: add Custom Applications multiple permissions docs docs: Custom Applications multiple permissions Sep 15, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Sep 15, 2022

Deploy preview for merchant-center-application-kit ready!

✅ Preview
https://merchant-center-application-8f565q22t-commercetools.vercel.app
https://appkit-sha-c6f69e001aeb61c9c8fbdf64752716919dcfadc4.commercetools.vercel.app
https://appkit-pr-2806.commercetools.vercel.app

Built with commit 17ac6c9.
This pull request is being automatically deployed with vercel-action

Copy link
Member

@emmenko emmenko left a comment

Choose a reason for hiding this comment

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

Super nice, this is looking already good! 🥳

I left some minor suggestions, let me know what you think about it.
Thanks 🤗

@@ -355,6 +357,68 @@ Using `manage_` OAuth Scopes always imply the corresponding `view_` OAuth Scope.

</Info>

## `additionalOAuthScopes`

The configuration for [additional OAuth Scopes and user permissions](/concepts/oauth-scopes-and-user-permissions#additional-oauth-scopes) extending [oAuthScopes configuration](#oauthscopes).
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
The configuration for [additional OAuth Scopes and user permissions](/concepts/oauth-scopes-and-user-permissions#additional-oauth-scopes) extending [oAuthScopes configuration](#oauthscopes).
<Info>
This feature is available from version `21.21.0` onwards.
</Info>
The optional configuration for defining more granular [OAuth Scopes and user permissions](/concepts/oauth-scopes-and-user-permissions#additional-oauth-scopes).

Comment on lines 366 to 368
A name used to build the permission keys based on the default permissions pair.

The `additionalOAuthScopes.name` value must adhere to the following restrictions:
Copy link
Member

Choose a reason for hiding this comment

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

Let's try to use the same terminology "permission group" to make it easier for users to relate things to each other.

Suggested change
A name used to build the permission keys based on the default permissions pair.
The `additionalOAuthScopes.name` value must adhere to the following restrictions:
A unique name for the additional permission group.
```json
{
"additionalOAuthScopes": [
{
"name": "movies",
}
]
}
```
The name value must adhere to the following restrictions:


The configuration for [additional OAuth Scopes and user permissions](/concepts/oauth-scopes-and-user-permissions#additional-oauth-scopes) extending [oAuthScopes configuration](#oauthscopes).

## `additionalOAuthScopes.name`
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
## `additionalOAuthScopes.name`
## `additionalOAuthScopes.*.name`

Comment on lines 395 to 397
## `additionalOAuthScopes.manage`

A list of "manage-only" [OAuth Scopes](https://docs.commercetools.com/api/scopes) required by the Custom Application and associated with the `Manage` permission scoped to the respective permission group.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
## `additionalOAuthScopes.manage`
A list of "manage-only" [OAuth Scopes](https://docs.commercetools.com/api/scopes) required by the Custom Application and associated with the `Manage` permission scoped to the respective permission group.
## `additionalOAuthScopes.*.manage`
A list of "manage-only" [OAuth Scopes](https://docs.commercetools.com/api/scopes) required by the Custom Application and associated with the `Manage<GroupName>` permission.

Comment on lines 374 to 376
## `additionalOAuthScopes.view`

A list of "view-only" [OAuth Scopes](https://docs.commercetools.com/api/scopes) required by the Custom Application and associated with the `View` permission scoped to the respective permission group.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
## `additionalOAuthScopes.view`
A list of "view-only" [OAuth Scopes](https://docs.commercetools.com/api/scopes) required by the Custom Application and associated with the `View` permission scoped to the respective permission group.
## `additionalOAuthScopes.*.view`
A list of "view-only" [OAuth Scopes](https://docs.commercetools.com/api/scopes) required by the Custom Application and associated with the `View<GroupName>` permission.

@@ -27,6 +29,36 @@ The `PERMISSIONS` variable contains a `View` and `Manage` properties, with the v

You can then use the `PERMISSIONS` variable to reference the permission in the application code.

<Info>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<Info>
<Info>
This feature is available from version `21.21.0` onwards.

@@ -2,12 +2,14 @@
title: Permissions
---

As we learned in [OAuth Scopes and user permissions](/concepts/oauth-scopes-and-user-permissions), each Custom Application has a unique pair of user permissions at its disposal: "view" and "manage."
As we learned in [OAuth Scopes and user permissions](/concepts/oauth-scopes-and-user-permissions), each Custom Application has a unique pair of default user permissions at its disposal: "view" and "manage."
Copy link
Member

Choose a reason for hiding this comment

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

I think we can simply mention the additional groups here in the intro.

Suggested change
As we learned in [OAuth Scopes and user permissions](/concepts/oauth-scopes-and-user-permissions), each Custom Application has a unique pair of default user permissions at its disposal: "view" and "manage."
As we learned in [OAuth Scopes and user permissions](/concepts/oauth-scopes-and-user-permissions), each Custom Application has a unique pair of default user permissions at its disposal: "view" and "manage." Additionally, more granular permission groups can be used to cover more strict business requirements.


The values of the user permissions are derived from the application `entryPointUriPath`.

When developing a Custom Application you might want to enforce these user permissions in some parts of your application. For example, performing certain actions like creating, updating, or deleting a resource should only be possible if the user has "manage" permission.

Furthermore, more granular additional permissions can optionally be used, for example, to allow the team access to only certain parts or functionality of the Custom Application.
Copy link
Member

Choose a reason for hiding this comment

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

Can be removed, see suggestion for the intro section.

Suggested change
Furthermore, more granular additional permissions can optionally be used, for example, to allow the team access to only certain parts or functionality of the Custom Application.

@@ -27,6 +29,36 @@ The `PERMISSIONS` variable contains a `View` and `Manage` properties, with the v

You can then use the `PERMISSIONS` variable to reference the permission in the application code.

<Info>

To leverage the optional, more granular permissions, a distinctive name has to be introduced for each of the permission groups.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
To leverage the optional, more granular permissions, a distinctive name has to be introduced for each of the permission groups.
When using additional permission groups, the unique group names should be provided to the `entryPointUriPathToPermissionKeys` function to generate the correct permission keys.
The group names can be exported and referenced also int he Custom Application config file.

Comment on lines 41 to 51
export const teamA = "team-a";

export const teamB = "team-b";

export const PERMISSIONS = entryPointUriPathToPermissionKeys(
entryPointUriPath,
[teamA, teamB]
);
Copy link
Member

Choose a reason for hiding this comment

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

Nit: maybe we can define the names as an constants object.

Suggested change
export const teamA = "team-a";
export const teamB = "team-b";
export const PERMISSIONS = entryPointUriPathToPermissionKeys(
entryPointUriPath,
[teamA, teamB]
);
export const groupNames = {
teamA: 'team-a',
teamB: 'team-b',
};
export const PERMISSIONS = entryPointUriPathToPermissionKeys(
entryPointUriPath,
[groupNames.teamA, groupNames.teamB]
);

@@ -2,7 +2,7 @@
title: Permissions
---

As we learned in [OAuth Scopes and user permissions](/concepts/oauth-scopes-and-user-permissions), each Custom Application has a unique pair of user permissions at its disposal: "view" and "manage."
As we learned in [OAuth Scopes and user permissions](/concepts/oauth-scopes-and-user-permissions), each Custom Application has a unique pair of default user permissions at its disposal: "view" and "manage". Additionally, more granular permission groups can be used to cover more strict business requirements.
Copy link
Contributor

Choose a reason for hiding this comment

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

🚫 [vale] reported by reviewdog 🐶
[Google.Quotes] Commas and periods go inside quotation marks.

Copy link
Contributor

@CarlosCortizasCT CarlosCortizasCT left a comment

Choose a reason for hiding this comment

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

💯

@@ -42,7 +81,7 @@ Each Custom Application gets a **unique pair** of user permissions: "view" and "

<Info>

The permission names are unique to each Custom Application and they derive from the `entryPointUriPath`, based on the following format: `{View,Manage}<EntryPointUriPath>`.
The permission names are unique to each Custom Application and, by default, they derive from the `entryPointUriPath`, based on the following format: `{View,Manage}<EntryPointUriPath>`.
Copy link
Contributor

Choose a reason for hiding this comment

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

We have this sentence above:

Each Custom Application gets a unique pair of user permissions: "view" and "manage."

I'm wondering if we should update that because a Custom Application using additionalOAuthScopes will not only get one pair of user permissions.

Copy link
Member

Choose a reason for hiding this comment

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

Good point, we should maybe rephrase that section yes.

Copy link
Contributor

@Rhotimee Rhotimee left a comment

Choose a reason for hiding this comment

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

Looks good.

Copy link
Member

@emmenko emmenko left a comment

Choose a reason for hiding this comment

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

Went through the docs again and left some more suggestions.

With that, I think we should have all the important info documented.

@@ -30,6 +30,45 @@ Notice here how the OAuth Scopes are grouped by the two fields `view` and `manag

This grouping determines the **mapping and relation between OAuth Scopes and user permissions**.

# Permission groups
Copy link
Member

Choose a reason for hiding this comment

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

Nit: I would make it a subsection

Suggested change
# Permission groups
## Permission groups

Comment on lines 35 to 39
<Info>

This feature is available from version `21.21.0` onwards.

</Info>
Copy link
Member

Choose a reason for hiding this comment

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

I think this should be placed where we mention the additional groups, as otherwise it seems like all permission groups are something new.


</Info>

Defining `oAuthScopes` in the Custom Application config yields the default permision group which allows using permissions limited to 1 unique pair (view/manage) specific to the Custom Application. The default permission pair can cover access control needs of Custom Applications intended to be used by one team.
Copy link
Member

Choose a reason for hiding this comment

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

I would start the introduction of this section by explaining what the group is and that there is a default one.

Suggested change
Defining `oAuthScopes` in the Custom Application config yields the default permision group which allows using permissions limited to 1 unique pair (view/manage) specific to the Custom Application. The default permission pair can cover access control needs of Custom Applications intended to be used by one team.
Every Custom Application has a **default permission group** with a pair of view and manage permissions. This group maps to the OAuth Scopes specified in the [oAuthScopes](/api-reference/application-config#oauthscopes) field of the Custom Application config.

Comment on lines 45 to 47
For more granular permissions [additional OAuth Scopes](https://docs.commercetools.com/api/scopes) can be requested as part of various additional permission groups.

These additional OAuth Scopes must be specified in your Custom Application config, using the [`additionalOAuthScopes` field](/api-reference/application-config#additionaloauthscopes).
Copy link
Member

Choose a reason for hiding this comment

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

Here I would then mention the version requirement:

Suggested change
For more granular permissions [additional OAuth Scopes](https://docs.commercetools.com/api/scopes) can be requested as part of various additional permission groups.
These additional OAuth Scopes must be specified in your Custom Application config, using the [`additionalOAuthScopes` field](/api-reference/application-config#additionaloauthscopes).
To enable such use cases, you can define additional permission groups that have different access requirements. See [additionalOAuthScopes](/api-reference/application-config#additionaloauthscopes) field in the Custom Application config.
<Info>
This feature is available from version `21.21.0` onwards.
</Info>


Defining `oAuthScopes` in the Custom Application config yields the default permision group which allows using permissions limited to 1 unique pair (view/manage) specific to the Custom Application. The default permission pair can cover access control needs of Custom Applications intended to be used by one team.

However, in certain cases more granular access control is needed. For example, if multiple teams accross the organization have access to a Custom Application but only one team is allowed to manage discount codes, the default permission pair is not enough.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
However, in certain cases more granular access control is needed. For example, if multiple teams accross the organization have access to a Custom Application but only one team is allowed to manage discount codes, the default permission pair is not enough.
However, you might need more granular access control to fulfil specific business requirements. For example, if your Custom Application manages products, discounts and orders, you might want only a group of users to manage products and discounts while another group of users handles orders.<br />
In this kind of scenario a single permission group (the default one) is not enough as you would need multiple permission groups fulfil the access requirements.

Comment on lines 49 to 69
In the following example, permission group named `team-a` allows to manage orders but not manage discount codes, while permission group named `team-b` allows both.

```json title="custom-application-config.json" highlightLines="6-17"
{
"oAuthScopes": {
"view": ["view_products", "view_customers"],
"manage": ["manage_products"]
},
"additionalOAuthScopes": [
{
"name": "team-a",
"view": [],
"manage": ["manage_orders"]
},
{
"name": "team-b",
"view": [],
"manage": ["manage_orders", "manage_discount_codes"]
}
]
}
```
Copy link
Member

Choose a reason for hiding this comment

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

Nit: I would suggest to avoid using "team-x" in the group name, as it gives the impression that this maps to a team name.

Let's use something else

Suggested change
In the following example, permission group named `team-a` allows to manage orders but not manage discount codes, while permission group named `team-b` allows both.
```json title="custom-application-config.json" highlightLines="6-17"
{
"oAuthScopes": {
"view": ["view_products", "view_customers"],
"manage": ["manage_products"]
},
"additionalOAuthScopes": [
{
"name": "team-a",
"view": [],
"manage": ["manage_orders"]
},
{
"name": "team-b",
"view": [],
"manage": ["manage_orders", "manage_discount_codes"]
}
]
}
```
In the following example, we are defining two additional permission groups. The group `delivery` allows users to manage incoming orders while the group `promotion` enables users to work on discount and promotion campaigns.
```json title="custom-application-config.json" highlightLines="6-17"
{
"oAuthScopes": {
"view": ["view_products", "view_customers"],
"manage": ["manage_products"]
},
"additionalOAuthScopes": [
{
"name": "delivery",
"view": [],
"manage": ["manage_orders"]
},
{
"name": "promotion",
"view": [],
"manage": ["manage_orders", "manage_discount_codes"]
}
]
}

@@ -42,7 +81,7 @@ Each Custom Application gets a **unique pair** of user permissions: "view" and "

<Info>

The permission names are unique to each Custom Application and they derive from the `entryPointUriPath`, based on the following format: `{View,Manage}<EntryPointUriPath>`.
The permission names are unique to each Custom Application and, by default, they derive from the `entryPointUriPath`, based on the following format: `{View,Manage}<EntryPointUriPath>`.
Copy link
Member

Choose a reason for hiding this comment

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

Good point, we should maybe rephrase that section yes.

Comment on lines 43 to 51
export const groupNames = {
teamA: 'team-a',
teamB: 'team-b',
};

export const PERMISSIONS = entryPointUriPathToPermissionKeys(
entryPointUriPath,
[groupNames.teamA, groupNames.teamB]
);
Copy link
Member

Choose a reason for hiding this comment

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

See other suggestion about the group names

Suggested change
export const groupNames = {
teamA: 'team-a',
teamB: 'team-b',
};
export const PERMISSIONS = entryPointUriPathToPermissionKeys(
entryPointUriPath,
[groupNames.teamA, groupNames.teamB]
);
export const groupNames = {
delivery: 'delivery',
promotion: 'promotion',
};
export const PERMISSIONS = entryPointUriPathToPermissionKeys(
entryPointUriPath,
['delivery', 'promotion']
);

Also, if we provide a TS example, we need to make sure to use the as const for the groupNames, so that we can pass the list using variable references

export const groupNames = {
  delivery: 'delivery',
  promotion: 'promotion',
} as const;

export const PERMISSIONS = entryPointUriPathToPermissionKeys(
  entryPointUriPath,
  [groupNames.delivery, groupNames.promotion]
);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! That's a great catch!
❓ I'm still wondering how to approach the TS snippet. Is your point to integrate @commercetools-docs/gatsby-theme-code-examples as part of this PR?

Copy link
Member

Choose a reason for hiding this comment

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

No that should probably be a follow up.

Comment on lines 54 to 61
In this scenario the `PERMISSIONS` variable contains a `View`, `Manage`, `ViewTeamA`, `ManageTeamA`, `ViewTeamB` and `ManageTeamB` properties, with the values being the computed values based on the `entryPointUriPath` and the provided permission group names:

* `PERMISSIONS.View`: maps to `ViewChannels`.
* `PERMISSIONS.Manage`: maps to `ManageChannels`.
* `PERMISSIONS.ViewTeamA`: maps to `ViewChannelsTeamA`.
* `PERMISSIONS.ManageTeamA`: maps to `ManageChannelsTeamA`.
* `PERMISSIONS.ViewTeamB`: maps to `ViewChannelsTeamB`.
* `PERMISSIONS.ManageTeamB`: maps to `ManageChannelsTeamB`.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
In this scenario the `PERMISSIONS` variable contains a `View`, `Manage`, `ViewTeamA`, `ManageTeamA`, `ViewTeamB` and `ManageTeamB` properties, with the values being the computed values based on the `entryPointUriPath` and the provided permission group names:
* `PERMISSIONS.View`: maps to `ViewChannels`.
* `PERMISSIONS.Manage`: maps to `ManageChannels`.
* `PERMISSIONS.ViewTeamA`: maps to `ViewChannelsTeamA`.
* `PERMISSIONS.ManageTeamA`: maps to `ManageChannelsTeamA`.
* `PERMISSIONS.ViewTeamB`: maps to `ViewChannelsTeamB`.
* `PERMISSIONS.ManageTeamB`: maps to `ManageChannelsTeamB`.
In this scenario the `PERMISSIONS` variable contains a `View`, `Manage`, `ViewDelivery`, `ManageDelivery`, `ViewPromotion` and `ManagePromotion` properties, with the values being the computed values based on the `entryPointUriPath` and the provided permission group names:
* `PERMISSIONS.View`: maps to `ViewChannels`.
* `PERMISSIONS.Manage`: maps to `ManageChannels`.
* `PERMISSIONS.ViewDelivery`: maps to `ViewChannelsDelivery`.
* `PERMISSIONS.ManageDelivery`: maps to `ManageChannelsDelivery`.
* `PERMISSIONS.ViewPromotion`: maps to `ViewChannelsPromotion`.
* `PERMISSIONS.ManagePromotion`: maps to `ManageChannelsPromotion`.


Every Custom Application has a **default permission group** with a pair of view and manage permissions. This group maps to the OAuth Scopes specified in the [oAuthScopes](/api-reference/application-config#oauthscopes) field of the Custom Application config.

However, you might need more granular access control to fulfil specific business requirements. For example, if your Custom Application manages products, discounts and orders, you might want only a group of users to manage products and discounts while another group of users handles orders.<br />
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ [vale] reported by reviewdog 🐶
[Google.OxfordComma] Use the Oxford comma in 'For example, if your Custom Application manages products, discounts and'.


The default permission group is always defined, even when not adding additional groups.

When additional groups are defined, the default group can be left "empty", without specifying any OAuth Scopes.
Copy link
Contributor

Choose a reason for hiding this comment

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

🚫 [vale] reported by reviewdog 🐶
[Google.Quotes] Commas and periods go inside quotation marks.

Copy link
Member

@emmenko emmenko left a comment

Choose a reason for hiding this comment

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

🤗

Comment on lines 2 to 4
date: 2022-12-15
title: Custom Applications multiple permissions
description: Introducing more granular permissions for Custom Applications.
Copy link
Member

Choose a reason for hiding this comment

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

💯


The Application Kit packages have been released with a minor version `v21.21.0`.

Custom Applications now enable optional configuration for defining more granular [OAuth Scopes and user permissions](/concepts/oauth-scopes-and-user-permissions#permission-groups) to cover more strict business requirements.
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for keeping it concise! 🤗

I would maybe elaborate a bit more and point to the updated parts of the documentation.

Suggested change
Custom Applications now enable optional configuration for defining more granular [OAuth Scopes and user permissions](/concepts/oauth-scopes-and-user-permissions#permission-groups) to cover more strict business requirements.
Custom Applications now allow to define more granular OAuth Scopes and user permissions to cover more strict business requirements. You can create [multiple permission groups](/concepts/oauth-scopes-and-user-permissions#permission-groups) and [assign different OAuth Scopes](/concepts/oauth-scopes-and-user-permissions#oauth-scopes) to them. These permission groups can be then [assigned to teams](/merchant-center/managing-custom-applications#assigning-team-permissions) in a more granular way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, updated 🙂

@@ -323,11 +323,13 @@ The configuration for [OAuth Scopes and user permissions](/concepts/oauth-scopes

You can have "view-only" or "manage-only" OAuth Scopes and leave the other list field empty, as long as at least one OAuth Scope is specified.

Alternatively, if at least one additional permission group is configured in `[additionalOAuthScopes](#additionaloauthscopes)`, both "view-only" or "manage-only" OAuth Scopes list fields can be left empty.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Alternatively, if at least one additional permission group is configured in `[additionalOAuthScopes](#additionaloauthscopes)`, both "view-only" or "manage-only" OAuth Scopes list fields can be left empty.
Alternatively, if at least one additional permission group is configured in [additionalOAuthScopes](#additionaloauthscopes), both "view-only" or "manage-only" OAuth Scopes list fields can be left empty.

Copy link
Contributor

Choose a reason for hiding this comment

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

@kark, can you apply this one as well?

Copy link
Contributor

@Anshuman71 Anshuman71 left a comment

Choose a reason for hiding this comment

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

Looks good technically. Please review and merge the suggestions.


export const PERMISSIONS = entryPointUriPathToPermissionKeys(
entryPointUriPath,
['delivery', 'promotion']
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
['delivery', 'promotion']
[groupNames.delivery, groupNames.promotion]

Let's use the constant values for consistency.

Copy link
Member

Choose a reason for hiding this comment

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

We can't use the variables here as otherwise the type inference does not work.

Comment on lines 35 to 40
Every Custom Application has a **default permission group** with a pair of view and manage permissions. This group maps to the OAuth Scopes specified in the [oAuthScopes](/api-reference/application-config#oauthscopes) field of the Custom Application config.

However, you might need more granular access control to fulfil specific business requirements. For example, if your Custom Application manages products, discounts, and orders, you might want only a group of users to manage products and discounts while another group of users handles orders.<br />
In this kind of scenario a single permission group (the default one) is not enough as you would need multiple permission groups fulfil the access requirements.

To enable such use cases, you can define additional permission groups that have different access requirements. See [additionalOAuthScopes](/api-reference/application-config#additionaloauthscopes) field in the Custom Application config.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Every Custom Application has a **default permission group** with a pair of view and manage permissions. This group maps to the OAuth Scopes specified in the [oAuthScopes](/api-reference/application-config#oauthscopes) field of the Custom Application config.
However, you might need more granular access control to fulfil specific business requirements. For example, if your Custom Application manages products, discounts, and orders, you might want only a group of users to manage products and discounts while another group of users handles orders.<br />
In this kind of scenario a single permission group (the default one) is not enough as you would need multiple permission groups fulfil the access requirements.
To enable such use cases, you can define additional permission groups that have different access requirements. See [additionalOAuthScopes](/api-reference/application-config#additionaloauthscopes) field in the Custom Application config.
Every Custom Application has a **default permission group** with a pair of view and manage permissions. This group maps to the OAuth Scopes specified in the [oAuthScopes](/api-reference/application-config#oauthscopes) field of the Custom Application config.
However, you might need more granular access control to fulfill specific business requirements. For example, suppose your Custom Application manages products, discounts, and orders. And you want a group of users to only manage products and discounts while another group handles orders.<br />
In this scenario, more than one permission group (the default one) is needed to fulfill the access requirements.
You can define additional permission groups with different access requirements to enable such use cases. See [additionalOAuthScopes](/api-reference/application-config#additionaloauthscopes) field in the Custom Application config.

Choose a reason for hiding this comment

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

@Anshuman71 could you please rework your suggestion for the paragraph starting with: 'However, you might need more..'. 🙏 It is not so easy to read and there is a sentence starting with 'And'.


</Info>

In the following example, we are defining two additional permission groups. The group `delivery` allows users to manage incoming orders while the group `promotion` enables users to work on discount and promotion campaigns.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
In the following example, we are defining two additional permission groups. The group `delivery` allows users to manage incoming orders while the group `promotion` enables users to work on discount and promotion campaigns.
In the following example, we're defining two additional permission groups. The group `delivery` allows users to manage incoming orders, while the group `promotion` enables users to work on discount and promotion campaigns.

Comment on lines 73 to 77
The default permission group is always defined, even when adding additional groups.

When additional groups are defined, the default group can be left "empty," without specifying any OAuth Scopes.

Even so, remember that the "view-only" user permission must be enabled to allow access to the Custom Application.
Copy link
Contributor

@Anshuman71 Anshuman71 Dec 5, 2022

Choose a reason for hiding this comment

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

Suggested change
The default permission group is always defined, even when adding additional groups.
When additional groups are defined, the default group can be left "empty," without specifying any OAuth Scopes.
Even so, remember that the "view-only" user permission must be enabled to allow access to the Custom Application.
The default permission group is always defined, even when adding additional groups.
When additional groups are defined, the default group can be left empty without specifying any OAuth Scopes.
But still, at least one "view-only" user permission must be enabled to access the Custom Application.

Copy link
Member

Choose a reason for hiding this comment

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

Hmm here we're actually mixing things up a bit. The first part about defining the permission groups is about the Custom Application configuration while the "view-only" part is about assigning team permissions.

Having the two points in one sentence makes is look like they are strictly related when configuring the app.

Maybe you can try rephrasing this again in case the original version wasn't clear enough?

Copy link
Contributor

Choose a reason for hiding this comment

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

@emmenko, thanks for highlighting that. I've rephrased it for clarity.


* When assigning "view"-only permission to a Team, only the `view_` OAuth Scopes are used to authorize API requests.
* When assigning "manage" permission to a Team, both `view_` and `manage_` OAuth Scopes are used to authorize API requests.

<Info>

The permission names are unique to each Custom Application and they derive from the `entryPointUriPath`, based on the following format: `{View,Manage}<EntryPointUriPath>`.
The permission names are unique to each Custom Application and, by default, they derive from the `entryPointUriPath`, based on the following format: `{View,Manage}<EntryPointUriPath>`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
The permission names are unique to each Custom Application and, by default, they derive from the `entryPointUriPath`, based on the following format: `{View,Manage}<EntryPointUriPath>`.
The permission names are unique to each Custom Application, and, by default, they derive from the `entryPointUriPath`, based on the following format: `{View,Manage}<EntryPointUriPath>`.

@@ -2,7 +2,7 @@
title: Permissions
---

As we learned in [OAuth Scopes and user permissions](/concepts/oauth-scopes-and-user-permissions), each Custom Application has a unique pair of user permissions at its disposal: "view" and "manage."
As we learned in [OAuth Scopes and user permissions](/concepts/oauth-scopes-and-user-permissions), each Custom Application has a unique pair of default user permissions at its disposal: "view" and "manage." Additionally, more granular permission groups can be used to cover more strict business requirements.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
As we learned in [OAuth Scopes and user permissions](/concepts/oauth-scopes-and-user-permissions), each Custom Application has a unique pair of default user permissions at its disposal: "view" and "manage." Additionally, more granular permission groups can be used to cover more strict business requirements.
As we learned in [OAuth Scopes and user permissions](/concepts/oauth-scopes-and-user-permissions), each Custom Application has a unique pair of default user permissions at its disposal: "view" and "manage." Additionally, you can use more granular permission groups to cover strict business requirements.


This feature is available from version `21.21.0` onwards.

When using additional permission groups, the unique group names should be provided to the `entryPointUriPathToPermissionKeys` function to generate the correct permission keys.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
When using additional permission groups, the unique group names should be provided to the `entryPointUriPathToPermissionKeys` function to generate the correct permission keys.
When using additional permission groups, you must also provide the unique group to the `entryPointUriPathToPermissionKeys` function to generate the correct permission keys.

);
```

In this scenario the `PERMISSIONS` variable contains a `View`, `Manage`, `ViewDelivery`, `ManageDelivery`, `ViewPromotion` and `ManagePromotion` properties, with the values being the computed values based on the `entryPointUriPath` and the provided permission group names:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
In this scenario the `PERMISSIONS` variable contains a `View`, `Manage`, `ViewDelivery`, `ManageDelivery`, `ViewPromotion` and `ManagePromotion` properties, with the values being the computed values based on the `entryPointUriPath` and the provided permission group names:
In this scenario, the `PERMISSIONS` variable contains a `View`, `Manage`, `ViewDelivery`, `ManageDelivery`, `ViewPromotion` and `ManagePromotion` properties, with the values being the computed values based on the `entryPointUriPath` and the provided permission group names:

Comment on lines 12 to 16
The Application Kit packages have been released with a minor version `v21.21.0`.

Custom Applications now allow to define more granular OAuth Scopes and user permissions to cover more strict business requirements. You can create [multiple permission groups](/concepts/oauth-scopes-and-user-permissions#permission-groups) and [assign different OAuth Scopes](/concepts/oauth-scopes-and-user-permissions#oauth-scopes) to them. These permission groups can be then [assigned to teams](/merchant-center/managing-custom-applications#assigning-team-permissions) in a more granular way.

As always, if you have questions or feedback, you can open a [GitHub Discussion](https://github.com/commercetools/merchant-center-application-kit/discussions) or a [GitHub Issue](https://github.com/commercetools/merchant-center-application-kit/issues).
Copy link
Contributor

@Anshuman71 Anshuman71 Dec 5, 2022

Choose a reason for hiding this comment

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

Suggested change
The Application Kit packages have been released with a minor version `v21.21.0`.
Custom Applications now allow to define more granular OAuth Scopes and user permissions to cover more strict business requirements. You can create [multiple permission groups](/concepts/oauth-scopes-and-user-permissions#permission-groups) and [assign different OAuth Scopes](/concepts/oauth-scopes-and-user-permissions#oauth-scopes) to them. These permission groups can be then [assigned to teams](/merchant-center/managing-custom-applications#assigning-team-permissions) in a more granular way.
As always, if you have questions or feedback, you can open a [GitHub Discussion](https://github.com/commercetools/merchant-center-application-kit/discussions) or a [GitHub Issue](https://github.com/commercetools/merchant-center-application-kit/issues).
The Application Kit packages have been released with a minor version, `v21.21.0`.
Custom Applications now allow defining more granular OAuth Scopes and user permissions to cover more specific business requirements. You can create [multiple permission groups](/concepts/oauth-scopes-and-user-permissions#permission-groups) and [assign different OAuth Scopes](/concepts/oauth-scopes-and-user-permissions#oauth-scopes) to them. These permission groups can then be [assigned to teams](/merchant-center/managing-custom-applications#assigning-team-permissions) in a more granular way.
As always, if you have questions or feedback, you can open a [GitHub Discussion](https://github.com/commercetools/merchant-center-application-kit/discussions) or a [GitHub Issue](https://github.com/commercetools/merchant-center-application-kit/issues).

Comment on lines 432 to 436
<Info>

Using `manage_` OAuth Scopes always imply the corresponding `view_` OAuth Scope.

</Info>
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
<Info>
Using `manage_` OAuth Scopes always imply the corresponding `view_` OAuth Scope.
</Info>

We can skip this callout, as it's already shared above.

Copy link
Member

@emmenko emmenko left a comment

Choose a reason for hiding this comment

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

Thanks for the review! 🙌

Comment on lines 73 to 77
The default permission group is always defined, even when adding additional groups.

When additional groups are defined, the default group can be left "empty," without specifying any OAuth Scopes.

Even so, remember that the "view-only" user permission must be enabled to allow access to the Custom Application.
Copy link
Member

Choose a reason for hiding this comment

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

Hmm here we're actually mixing things up a bit. The first part about defining the permission groups is about the Custom Application configuration while the "view-only" part is about assigning team permissions.

Having the two points in one sentence makes is look like they are strictly related when configuring the app.

Maybe you can try rephrasing this again in case the original version wasn't clear enough?

Copy link
Contributor

@Anshuman71 Anshuman71 left a comment

Choose a reason for hiding this comment

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

Final changes. All good otherwise.

@@ -323,11 +323,13 @@ The configuration for [OAuth Scopes and user permissions](/concepts/oauth-scopes

You can have "view-only" or "manage-only" OAuth Scopes and leave the other list field empty, as long as at least one OAuth Scope is specified.

Alternatively, if at least one additional permission group is configured in `[additionalOAuthScopes](#additionaloauthscopes)`, both "view-only" or "manage-only" OAuth Scopes list fields can be left empty.
Copy link
Contributor

Choose a reason for hiding this comment

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

@kark, can you apply this one as well?


Every Custom Application has a **default permission group** with a pair of view and manage permissions. This group maps to the OAuth Scopes specified in the [oAuthScopes](/api-reference/application-config#oauthscopes) field of the Custom Application config.

However, you might need more granular access control to fulfill specific business requirements. For example, suppose your Custom Application manages products, discounts, and orders. And you want a group of users to only manage products and discounts while another group handles orders.<br />
Copy link
Contributor

@Anshuman71 Anshuman71 Dec 6, 2022

Choose a reason for hiding this comment

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

@kark, another one

Suggested change
However, you might need more granular access control to fulfill specific business requirements. For example, suppose your Custom Application manages products, discounts, and orders. And you want a group of users to only manage products and discounts while another group handles orders.<br />
However, you might need more granular access control to fulfill specific business requirements. Suppose your Custom Application manages products, discounts, and orders, and you want a group of users to only manage products and discounts while another group handles orders. <br />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants