Skip to content

Commit 8ffa67c

Browse files
committed
Updated docs
1 parent a7cac1c commit 8ffa67c

File tree

1 file changed

+32
-16
lines changed

1 file changed

+32
-16
lines changed

README.md

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,22 @@
22

33
## Aims
44

5-
**Umbraco Authorized Services** is an Umbraco package designed to reduce the effort needed to integrate third party services that require authentication and authorization via an OAuth flow into Umbraco solutions. It's based on the premise that working with these services requires a fair bit of plumbing code to handle creating an authorized connection. This is necessary before the developer working with the service can get to actually using the provided API to implement the business requirements.
5+
**Umbraco Authorized Services** is an Umbraco package designed to reduce the effort needed to integrate third party services that require authentication and authorization via an OAuth or API key based flow into Umbraco solutions. It's based on the premise that working with these services requires a fair bit of plumbing code to handle creating an authorized connection. This is necessary before the developer working with the service can get to actually using the provided API to implement the business requirements.
66

77
Having worked with a few OAuth integrations across different providers, as would be expected, there are quite a few similarities to the flow that needs to be implemented. Steps include:
88

99
- Redirecting to an authentication endpoint.
10-
- Handling the response including an authentication code and exchanging it for an access token.
10+
- Handling the response including an authentication code (or an oauth token and verifier code) and exchanging it for an access token.
1111
- Securely storing the token.
1212
- Including the token in API requests.
1313
- Serializing requests and deserializing the API responses.
1414
- Handling cases where the token has expired and obtaining a new one via a refresh token.
1515

16+
For API key based flows, the integration steps include:
17+
18+
- Use an API key stored in the settings file or persisted into the database to serialize requests and deserialize the API responses.
19+
- Use provisioning options for passing the key to the API.
20+
1621
There are though also differences, across request and response structures and variations in the details of the flow itself.
1722

1823
The idea of the package is to try to implement a single, best practice implementation of working with OAuth that can be customized, via configuration or code, for particular providers.
@@ -23,7 +28,7 @@ For the solution developer, the Umbraco Authorized Services offers two primary f
2328

2429
Firstly there's an tree available in the _Settings_ section of the backoffice, called _Authorized Services_. The tree shows the list of services based on the details provided in configuration.
2530

26-
Each tree entry has a management screen where an administrator can authenticate with an app that has been setup with the service. The status of each service, in terms of whether the authentication and authorization flow has been completed and an access token stored, is shown on this screen.
31+
Each tree entry has a management screen where an administrator can authenticate with an app that has been setup with the service. The status of each service, in terms of whether the authentication and authorization flow has been completed and an access token (or API key) stored, is shown on this screen.
2732

2833
![Backoffice settings screen](https://2904150615-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeCauR3aomRsx2gdckuDO%2Fuploads%2Fgit-blob-d8f49355a2c62920863e5653f7ad97e135fbc7cb%2Fauthorized-services-tree.png?alt=media)
2934

@@ -70,7 +75,7 @@ Details of services available need to be applied to the Umbraco web application'
7075
"<serviceAlias>": {
7176
"DisplayName": "",
7277
"AuthenticationMethod": "OAuth2AuthorizationCode|OAuth2ClientCredentials|OAuth1|ApiKey",
73-
"ClientCredentialsProvision": "",
78+
"ClientCredentialsProvision": "AuthHeader|RequestBody",
7479
"ApiHost": "",
7580
"IdentityHost": "",
7681
"TokenHost": "",
@@ -88,19 +93,21 @@ Details of services available need to be applied to the Umbraco web application'
8893
},
8994
"AuthorizationUrlRequiresRedirectUrl": true|false,
9095
"RequestTokenPath": "",
96+
"RequestTokenMethod": "GET|POST",
9197
"RequestAuthorizationPath": "",
92-
"JsonSerializer": "",
93-
"RequestTokenFormat": "",
98+
"JsonSerializer": "Default|JsonNet|SystemTextJson",
99+
"RequestTokenFormat": "Querystring|FormUrlEncoded",
94100
"AuthorizationRequestRequiresAuthorizationHeaderWithBasicToken": true|false,
95101
"ApiKey": "",
96102
"ApiKeyProvision": {
97-
"Method": "",
103+
"Method": "HttpHeader|QueryString",
98104
"Key": ""
99105
},
100106
"ClientId": "",
101107
"ClientSecret": "",
102108
"UseProofKeyForCodeExchange": true|false,
103109
"Scopes": "",
110+
"IncludeScopesInAuthorizationRequest": true|false,
104111
"AccessTokenResponseKey": "access_token",
105112
"RefreshTokenResponseKey": "refresh_token",
106113
"ExpiresInResponseKey": "expires_in",
@@ -204,7 +211,7 @@ An enum value that controls how the request to retrieve an access token is forma
204211

205212
###### RequestAuthorizationPath
206213

207-
Required in `OAuth1a` flows for building the service authorization URL.
214+
Required in `OAuth1` flows for building the service authorization URL.
208215

209216
###### JsonSerializer
210217

@@ -230,10 +237,12 @@ For `ApiKey` authentication methods, options for passing the API key need to be
230237
###### ClientId *
231238

232239
This value will be retrieved from the registered service app.
240+
For `OAuth1` flows it matches the `consumer key` value from the registered service app.
233241

234242
###### ClientSecret *
235243

236244
This value will be retrieved from the registered service app. As the name suggests, it should be kept secret and so is probably best not added directly to `appSettings.json` and checked into source control.
245+
For `OAuth1` flows it matches the `consumer secret` value from the registered service app.
237246

238247
###### UseProofKeyForCodeExchange *
239248

@@ -248,6 +257,9 @@ compare it with the previously sent `code_challenge`.
248257

249258
This value will be configured on the service app and retrieved from there. Best practice is to define only the set of permissions that the integration will need. For GitHub, the single scope needed to retrieve details about a repository's contributors is `repo`.
250259

260+
###### IncludeScopesInAuthorizationRequest
261+
Specifies whether the provided scopes should be included in the authorization request body (e.g. `Microsoft`).
262+
251263
###### AccessTokenResponseKey
252264

253265
The expected key for retrieving an access token from a response. If not provided the default `access_token` is assumed.
@@ -387,6 +399,10 @@ Responsible for creating an HTTP client used for making authorization requests t
387399

388400
Responsible for creating a dictionary of parameters provided in the request to retrieve an access token from an authorization code. Implemented by `AuthorizationParametersBuilder`.
389401

402+
#### IAuthorizationPayloadBuilder
403+
404+
Responsible for generating the authorization payload used between the authorization and access token requests. Implemented by `AuthorizationPayloadBuilder`.
405+
390406
#### IAuthorizationRequestSender
391407

392408
Responsible for sending the request to retrieve access tokens. Implemented by `AuthorizationRequestSender`, which depends on `IAuthorizationClientFactory`.
@@ -403,6 +419,10 @@ Responsible for building the URL used to instigate the authentication and author
403419

404420
Responsible for creating a request to an authorized service, providing the content and access token. Implemented by `AuthorizedRequestBuilder`.
405421

422+
#### IExchangeTokenParametersBuilder
423+
424+
Responsible for defining the operations building the dictionary of parameters used in exchange token authorization requests. Implemented by `ExchangeTokenParametersBuilder`.
425+
406426
#### IAuthorizedServiceCaller
407427

408428
Responsible for making requests to the authorized services for the purposes of accessing business functionality. This is used by Umbraco solution developers and is described in detail above. Implemented by `AuthorizedServiceCaller`.
@@ -431,14 +451,10 @@ builder.Services.AddUnique<ISecretEncryptor, AesSecretEncryptor>();
431451

432452
Responsible for instantiating a new strongly typed `Token` instance from the service response. Implemented by `TokenFactory`.
433453

434-
#### ITokenStorage
435-
436-
Responsible for storing tokens. Implemented by `InMemoryTokenStorage` and `DatabaseTokenStorage`.
437-
438-
#### IAuthorizedServiceCache
454+
#### IKeyStorage
439455

440-
Responsible for caching data payload. Implemented by `AuthorizedServiceAuthorizationPayloadCache` to store the authorization payload.
456+
Responsible for storing API keys. Implemented by `DatabaseKeyStorage`.
441457

442-
#### IAuthorizedServiceAuthorizationPayloadBuilder
458+
#### ITokenStorage | IOAuth1TokenStorage | IOAuth2TokenStorage
443459

444-
Responsible for generating the authorization payload used between the authorization and access token requests. Implemented by `AuthorizedServiceAuthorizationPayloadBuilder`.
460+
Responsible for storing tokens. Implemented by `InMemoryTokenStorage`, `DatabaseOAuth1TokenStorage` and `DatabaseOAuth2TokenStorage`.

0 commit comments

Comments
 (0)