Skip to content

Commit 20f2861

Browse files
rework page
1 parent 624499f commit 20f2861

File tree

1 file changed

+131
-130
lines changed

1 file changed

+131
-130
lines changed

content/extensions/ui-extensions.md

Lines changed: 131 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -174,106 +174,82 @@ To delete a UI extension, you must have a valid PIM API token and the UUID of th
174174
--header "Authorization: Bearer $PIM_API_TOKEN"
175175
```
176176

177-
## Concepts
177+
<!-- UI extensions fields ? -->
178178

179-
### Type
179+
## Types
180180

181181
UI extensions are categorized by type, which determines their capabilities. Select the type that best suits your requirements:
182182
+ action
183183
+ iframe
184184
+ link
185185

186-
#### Link
186+
### Link
187187
A **link** UI extension is crafted to open your external content in a new tab.
188188

189-
#### Iframe
190-
An **iframe** UI extension allows to open your external content inside the PIM thanks to an iframe.
191-
192-
An iframe (inline frame) is an HTML element that allows you to embed another HTML document within the current document. It is commonly used to display content from another source, such as a webpage, video, or interactive content, without leaving the current page.
193-
194-
For more detailed information, you can refer to the [Mozilla Developer Network (MDN) documentation on iframes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe).
195-
196-
To configure an `iframe` UI extension, mandatory fields are `name`, `position`, `type`, and `configuration`. Inside `configuration`, mandatory options are `default_label`, `secret` and `url`.
197-
198-
**Ensuring security of embedded iframes**
199-
200-
* Properly configure [Content Security Policy (CSP)](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP) headers to control the sources from which content can be loaded.
201-
202-
::: warning
203-
Please note that if these headers are misconfigured, iframe functionality may not work as intended.
204-
:::
205-
206-
* Add a secret to your extension. This secret will be used to generate a JWT token when the iframe is loaded by the PIM system.
189+
To create a `link` UI extension, mandatory fields are `name`, `position`, `type`, and `configuration`. Inside `configuration`, mandatory options are `default_label` and `url`.
207190

208-
**Receiving the JWT Token via ```postMessage```**
191+
#### Url Placeholders
192+
The Url of a **link** UI extension can be based on the context thanks to a placeholder pattern.
209193

210-
First, from your iframe, you must request for the JWT by doing a PostMessage with a payload containing ```type: 'request_jwt'```
194+
For example, you can configure a UI extension with the following url `https://www.google.com/search?q=%name%&tbm=shop&gl=us`. When the link is clicked, `%name%` will be replaced with the context attribute values.
211195

212-
Example :
213-
```js
214-
window.parent.postMessage(
215-
{
216-
type: 'request_jwt'
217-
},
218-
"*"
219-
);
220-
```
196+
Valid placeholders attributes are:
197+
- `uuid` (for products), `code` (for product models) and other attribute of type `identifier`
198+
- all text attributes. Links will use the value related to the current locale or channel.
221199

222-
the PIM will then answer with a postMessage containing the JWT token. The message will be structured as follows:
200+
You can add a placeholder anywhere in your url as soon as they're surrounded by `%` symbol.
223201

224-
```json
225-
{
226-
"type": "JWT_TOKEN",
227-
"token": "jwt_value"
228-
}
229-
```
202+
Examples:
203+
- `https://www.google.com/search?q=%name%`
204+
- `https://yourwebsite.com/%sku%`
230205

231-
* The JWT token in the token field is generated using SHA256 encryption based on the secret you provided.
206+
### Iframe
207+
An **iframe** UI extension allows to open your external content inside the PIM thanks to an iframe.
232208

233-
For more information on how JWT tokens are structured and used, you can refer to the associated [RFC 7519](https://datatracker.ietf.org/doc/html/rfc7519).
209+
An iframe (inline frame) is an HTML element that allows you to embed another HTML document within the current document. It is commonly used to display content from another source, such as a webpage, video, or interactive content, without leaving the current page.
234210

235-
**JWT Token Structure**
211+
For more detailed information, you can refer to the [Mozilla Developer Network (MDN) documentation on iframes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe).
236212

237-
The JWT token consists of three main parts: the header, the body (payload), and the signature.
213+
To configure an `iframe` UI extension, mandatory fields are `name`, `position`, `type`, and `configuration`. Inside `configuration`, mandatory options are `default_label`, `secret` and `url`.
238214

239-
*Header*
215+
#### Default query parameters
216+
To help identify the **iframe** caller (insecure) and context, several parameters are sent by default as SearchParameters in the GET query.
240217

241-
* The header typically contains information about the token type and the signing algorithm. In this case, it will look like:
218+
For example, when `url` is `https://customerwebsite.com/iframe/`, the called URL is `https://customerwebite.com/iframe/?position=pim.product.tab&user[username]=julia`
242219

243-
```json
244-
{
245-
"typ": "JWT",
246-
"alg": "HS256"
247-
}
248-
```
220+
For all positions, parameters relative to the connected user and the extension position are sent:
221+
- `user[username]`
222+
- `user[email]`
223+
- `user[ui_locale]`
224+
- `user[catalog_locale]` except for `pim.product-grid.action-bar`
225+
- `user[catalog_scope]` except for `pim.product-grid.action-bar`
226+
- `position`
249227

250-
*Payload*
228+
::: warning
229+
**Important security notice**
251230

252-
* The payload contains the claims. The JWT token’s will look like this:
231+
When using iframes, please be aware of the following:
253232

254-
```json
255-
{
256-
"jti": "c1b6b9f1-8486-4f9e-9f96-8d1b40fccb65",
257-
"iat": 1743410036.116152,
258-
"exp": 1743413636.116162,
259-
"userId": "1"
260-
}
261-
```
233+
<!-- still relevant ? I find it contradicorty with the JWT -->
234+
+ **Data confidentiality**: We do not implement any security measures to verify the identity of the caller accessing the URL.
262235

263-
* ```jti``` The unique identifier for the token.
264-
* ```iat``` The issued at time.
265-
* ```exp``` The expiration time of the token.
266-
* ```userId``` The PIM user identifier (in this case, ```1```).
236+
<!-- To me, what it means is unclear -->
237+
+ **Access control**: Anyone with access to this link can view the content of the webpage, regardless of the parameters included.
267238

268-
*A signature*
239+
For sensitive data, we recommend implementing [additional security measures](#ensuring-security-of-embedded-iframes) to protect your information.
240+
:::
269241

270-
* The signature is used to verify that the token is valid and has not been tampered with. It is generated by combining the encoded header and payload, and then signing them with the secret key. The resulting signature might look like:
271-
```9WBB7ayP8UnFrOlMrI9NzTj3kxaiXOWJzElyacEKt48```
242+
For `pim.product.tab` position, these parameters are sent:
243+
- `product[uuid]`
244+
- `product[identifier]`
272245

273-
**Verifying the Signature**
246+
For `pim.product-model.tab` and `pim.sub-product-model.header` position, this parameter is sent:
247+
- `product[code]`
274248

275-
To ensure that the JWT token was issued by Akeneo, you can verify the signature by re-encoding the header and payload and then signing them using the same secret key. This will allow you to confirm that the token is valid and has not been altered.
249+
For `pim.category.tab` position, this parameter is sent:
250+
- `category[code]`
276251

252+
#### Get PIM data from the iframe
277253

278254
**PostMessage**
279255

@@ -337,8 +313,88 @@ Example :
337313
```
338314
After receiving this *event*, the PIM will send a PostMessage *event*, similar to the one sent after the iframe loading.
339315

316+
#### Ensuring security of embedded iframes
317+
318+
To help ensuring the security of iframes we recommand using these two solutions:
319+
320+
* Properly configure [Content Security Policy (CSP)](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP) headers to control the sources from which content can be loaded.
321+
322+
::: warning
323+
Please note that if these headers are misconfigured, iframe functionality may not work as intended.
324+
:::
325+
326+
* Use your extension secret and ```postMessage``` to get and verify the signature of a JW token. This secret will be used to generate a JWT token when the iframe is loaded by the PIM system.
327+
328+
**Get a JW Token via ```postMessage```**
340329

341-
#### Action
330+
First, from your iframe, you must request for the JWT by doing a PostMessage with a payload containing ```type: 'request_jwt'```
331+
332+
Example :
333+
```js
334+
window.parent.postMessage(
335+
{
336+
type: 'request_jwt'
337+
},
338+
"*"
339+
);
340+
```
341+
342+
the PIM will then answer with a postMessage containing the JWT token. The message will be structured as follows:
343+
344+
```json
345+
{
346+
"type": "JWT_TOKEN",
347+
"token": "jwt_value"
348+
}
349+
```
350+
351+
* The JWT token in the token field is generated using SHA256 encryption based on the secret you provided.
352+
353+
For more information on how JWT tokens are structured and used, you can refer to the associated [RFC 7519](https://datatracker.ietf.org/doc/html/rfc7519).
354+
355+
**JWT Token Structure**
356+
357+
The JWT token consists of three main parts: the header, the body (payload), and the signature.
358+
359+
*Header*
360+
361+
* The header typically contains information about the token type and the signing algorithm. In this case, it will look like:
362+
363+
```json
364+
{
365+
"typ": "JWT",
366+
"alg": "HS256"
367+
}
368+
```
369+
370+
*Payload*
371+
372+
* The payload contains the claims. The JWT token’s will look like this:
373+
374+
```json
375+
{
376+
"jti": "c1b6b9f1-8486-4f9e-9f96-8d1b40fccb65",
377+
"iat": 1743410036.116152,
378+
"exp": 1743413636.116162,
379+
"userId": "1"
380+
}
381+
```
382+
383+
* ```jti``` The unique identifier for the token.
384+
* ```iat``` The issued at time.
385+
* ```exp``` The expiration time of the token.
386+
* ```userId``` The PIM user identifier (in this case, ```1```).
387+
388+
*A signature*
389+
390+
* The signature is used to verify that the token is valid and has not been tampered with. It is generated by combining the encoded header and payload, and then signing them with the secret key. The resulting signature might look like:
391+
```9WBB7ayP8UnFrOlMrI9NzTj3kxaiXOWJzElyacEKt48```
392+
393+
**Verifying the Signature**
394+
395+
To ensure that the JWT token was issued by Akeneo, you can verify the signature by re-encoding the header and payload and then signing them using the same secret key. This will allow you to confirm that the token is valid and has not been altered.
396+
397+
### Action
342398
An **action** UI extension is designed to perform external tasks in the background. Please note the following key points regarding its functionality:
343399

344400
+ **Single execution**: An action cannot be executed multiple times simultaneously. This ensures that tasks are processed in a controlled manner.
@@ -351,7 +407,6 @@ An **action** UI extension is designed to perform external tasks in the backgrou
351407
Here is a diagram illustrating the workflow:
352408
[![action-extension-schema.png](../img/extensions/ui-extensions/action-extension-schema.png)](../img/extensions/ui-extensions/action-extension-schema.png)
353409

354-
355410
Data sent within the POST body, formatted in JSON, contains :
356411
- A `data` object with different fields depending on the [position](#position).
357412
- A `context` object containing the configured `locale` and `channel`.
@@ -416,9 +471,9 @@ Examples :
416471
}
417472
```
418473

419-
### Position
474+
## Positions
420475

421-
**Extension Position**
476+
**Extension Positions**
422477

423478
Extension position determines where your extension appears within the Akeneo PIM interface. You can select from a variety of available positions, which vary depending on the specific extension type.
424479

@@ -434,10 +489,9 @@ Extension position determines where your extension appears within the Akeneo PIM
434489
* Consider the impact of the position on the overall user experience within the PIM.
435490

436491

437-
#### The following position can be added:
492+
### Positions list
438493

439494
![PIM Header.png](../img/extensions/ui-extensions/pim-header-with-extension.png)
440-
441495
#### pim.product.header
442496
This position refers to the header of a simple product or a variant edit page.
443497

@@ -448,7 +502,6 @@ This position refers to the header of a root model edit page.
448502
This position refers to the header of a sub model edit page.
449503

450504
![PIM Tab.png](../img/extensions/ui-extensions/pim-product-with-tab-extension.png)
451-
452505
#### pim.product.tab
453506
This position refers to the left panel of a simple product or a variant edit page.
454507

@@ -462,7 +515,6 @@ This position refers to the left panel of a sub model edit page.
462515
This position refers to the horizontal list of tabs on a category edit page.
463516

464517
![PIM Product Grid.png](../img/extensions/ui-extensions/pim-product-grid-with-bulk-trigger-action.png)
465-
466518
#### pim.product-grid.action-bar
467519
This position refers to the list of commands availables after selecting some products on the product grid.
468520

@@ -473,58 +525,7 @@ This position refers to the list of commands availables after selecting some pro
473525
#### pim.activity.navigation.tab
474526
This position refers to the activity PIM menu, adding UI extensions in this position will create a new section in the activity sub-navigation.
475527

476-
### Url
477-
All types of UI extensions must have a configured URL. However, the parameters that are sent—or can be sent—vary depending on the specific type of extension.
478-
#### Query parameters placeholders
479-
For [link](#link) UI extension, you can ask for specific values to construct the urls thanks to a specific placeholder pattern.
480-
481-
For example, you can configure a UI extension with the following url `https://www.google.com/search?q=%name%&tbm=shop&gl=us`, then we will dynamically put the value of the attribute code `name` when the user will click on the button.
482-
483-
Valid placeholders attributes are:
484-
- `uuid` (for products), `code` (for product models) and other attribute of type `identifier`
485-
- all text attributes. Links will use the value related to the current locale or channel.
486-
487-
You can add a placeholder anywhere in your url as soon as they're surrounded by `%` symbol.
488-
489-
Examples:
490-
- `https://www.google.com/search?q=%name%`
491-
- `https://yourwebsite.com/%sku%`
492-
493-
#### Fixed query parameters
494-
For an [iframe](#iframe) UI extension, with `pim.product.tab`, `pim.sub-product-model.tab`, `pim.product-model.tab` as [position](#position), several parameters are sent by default as SearchParameters in a GET query, so the server knows who is the connected user (insecure) and in which context the iframe is opened.
495-
496-
For example, when `url` is `https://customerwebsite.com/iframe/`, the called URL is `https://customerwebite.com/iframe/?paramA=valueA&paramB=valueB`
497-
498-
For all positions except `pim.product-grid.action-bar`, parameters relative to the connected user are sent:
499-
- `user[catalog_locale]`
500-
- `user[catalog_scope]`
501-
- `user[ui_locale]`
502-
- `user[username]`
503-
- `user[email]`
504-
505-
::: warning
506-
**Important security notice**
507-
508-
When using iframes, please be aware of the following:
509-
510-
+ **Data confidentiality**: We do not implement any security measures to verify the identity of the caller accessing the URL.
511-
512-
+ **Access control**: Anyone with access to this link can view the content of the webpage, regardless of the parameters included.
513-
514-
For sensitive data, we recommend implementing additional security measures to protect your information.
515-
:::
516-
517-
For `pim.product.tab` position, these parameters are sent:
518-
- `product[uuid]`
519-
- `product[identifier]`
520-
521-
For `pim.product-model.tab` position, this parameter is sent:
522-
- `product[code]`
523-
524-
For `pim.category.tab` position, this parameter is sent:
525-
- `category[code]`
526-
527-
## Available types by position
528+
### Available types by position
528529
Each position supports a specific subset of available types. The table below outlines the compatible types for all positions.
529530

530531
| Positions | Action | Iframe | Link |

0 commit comments

Comments
 (0)