| 1 | # Data-Plane Http OAuth2 |
| 2 | |
| 3 | This extension can be used when there's a data endpoint that requires OAuth2 authentication through the |
| 4 | [*client credentials flow*](https://auth0.com/docs/get-started/authentication-and-authorization-flow/client-credentials-flow) |
| 5 | It applies on both on **source** and **sink** side of the data transfer, when the data address containes the `oauth2` |
| 6 | related properties, the extension will request a token and add it as a `Bearer` in the `Authorization` header. |
| 7 | |
| 8 | Please note that this extension doesn't currently support neither expiration nor refresh tokens, as they are not |
| 9 | mandatory specifications that are up to the OAuth2 server implementation used. |
| 10 | |
| 11 | ## How to use it |
| 12 | |
| 13 | The extension works for all the `HttpData` addresses that contain the "oauth2" properties (defined in |
| 14 | [Oauth2DataAddressSchema](../../../spi/common/oauth2-spi/src/main/java/org/eclipse/edc/iam/oauth2/spi/Oauth2DataAddressSchema.java)). |
| 15 | It supports [both types of client credential](https://connect2id.com/products/server/docs/guides/oauth-client-authentication#credential-types): |
| 16 | shared secret and private-key based. |
| 17 | |
| 18 | ### Common properties |
| 19 | |
| 20 | - `oauth2:tokenUrl`: the url where the token will be requested |
| 21 | - `oauth2:scope`: (optional) the requested scope |
| 22 | |
| 23 | ### Private-key based client credential |
| 24 | |
| 25 | This type of client credential is used when the `HttpData` address contains the `oauth2:privateKeyName` property. This type of client |
| 26 | credential is considered as more secured as described [here](https://connect2id.com/products/server/docs/guides/oauth-client-authentication#private-key-auth-is-more-secure). |
| 27 | The mandatory for working with type of client credentials are: |
| 28 | |
| 29 | - `oauth2:privateKeyName`: the name of the private key used to sign the JWT sent to the Oauth2 server |
| 30 | `oauth2:validity`: the validity of the JWT token sent to the Oauth2 server (in seconds) |
| 31 | |
| 32 | ### Shared secret client credential |
| 33 | |
| 34 | This type of client credential is used when the `HttpData` address DOES not contain the `oauth2:privateKeyName` property. |
| 35 | The mandatory for working with type of client credentials are: |
| 36 | |
| 37 | - `oauth2:clientId`: the client id |
| 38 | - `oauth2:clientSecret`: (deprecated) shared secret for authenticating to the Oauth2 server |
| 39 | - `oauth2:clientSecretKey`: the key with which the shared secret for authenticating to the Oauth2 server is stored into the `Vault` |
| 40 | |