You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: guides/v1.0/get-started/authentication/gs-authentication.md
+57Lines changed: 57 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -118,6 +118,63 @@ Authorization is granted to either an administrator (or an integration) defined
118
118
<p>Similarly, self is a special access used if you already have an authenticated session with the system. Self access enables a user to access resources they own. For example, <code>GET /V1/customers/me</code> fetches the logged-in customer's details. This is typically useful for JavaScript-based widgets. </p>
Individual fields that are defined as extension attributes can be restricted, based on existing permissions. This feature allows extension developers to restrict access to data.
124
+
125
+
126
+
The following [code sample](https://github.corp.ebay.com/magento2/magento2ce/blob/develop/app/code/Magento/CatalogInventory/etc/extension_attributes.xml) defines `stock_item` as an extension attribute of the `CatalogInventory` module. `CatalogInventory` is treated as a “3rd-party extension”. Access to the inventory data is restricted because the quantity of in-stock item may be competitive information.
In this example, the `stock_item` attribute is restricted to only the users who have the `Magento_CatalogInventory::cataloginventory` permission. As a result, an anonymous or unauthenticated user issuing a `GET http://store/rest/V1/products/<sku>` request will receive product information similar to the following:
141
+
142
+
<pre>
143
+
{
144
+
"sku": “tshirt1”,
145
+
“price”: “20.00”,
146
+
“description”: “New JSmith design”,
147
+
“extension_attributes”: {
148
+
“logo size”: “small”
149
+
},
150
+
“custom_attributes”: {
151
+
“artist”: “James Smith”
152
+
}
153
+
}
154
+
</pre>
155
+
156
+
However, an authenticated user with the permission `Magento_CatalogInventory::cataloginventory` receives the additional `stock_item` field:
157
+
158
+
<pre>
159
+
{
160
+
"sku": “tshirt1”,
161
+
“price”: “20.00”,
162
+
“description”: “New JSmith design”,
163
+
“extension_attributes”: {
164
+
“logo size”: “small”,
165
+
“stock_item” : {
166
+
“status” : “in_stock”
167
+
“quantity”: 70
168
+
}
169
+
},
170
+
“custom_attributes”: {
171
+
“artist”: “James Smith”
172
+
}
173
+
}
174
+
</pre>
175
+
176
+
This only works for extension attributes (those attributes defined in an `extension_attributes.xml` file). There are no permission restrictions on the rest of the returned data. For example, there is no way to restrict `custom_attributes`.
177
+
121
178
<h3id="webapi-clients">Web API clients and authentication methods</h3>
122
179
<p>You use a client, such as a mobile application or an external batch job, to access Magento services using web APIs.</p>
123
180
<p>Each type of client has a preferred authentication method. To authenticate, use the authentication method for your preferred client:</p>
0 commit comments