Skip to content

Commit a7cac1c

Browse files
committed
Merge branch 'develop' into feature/docs
2 parents b6c0072 + 5cec448 commit a7cac1c

File tree

78 files changed

+17498
-479
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+17498
-479
lines changed

README.md

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,15 @@ Install-Package Umbraco.AuthorizedServices
4545
dotnet add package Umbraco.AuthorizedServices
4646
```
4747

48-
4948
### App Creation
5049

5150
Services that this package are intended to support will offer an OAuth authentication and authorization flow against an "app" that the developer will need to create with the service. From this various information will be available, including for example a "client ID" and "client secret" that will need to be applied in configuration.
5251

52+
When creating the app it will usually be necessary to configure a call back URL. You should use the following:
53+
54+
- For OAuth2: `/umbraco/api/AuthorizedServiceResponse/HandleOAuth2IdentityResponse`
55+
- For OAuth1: `/umbraco/api/AuthorizedServiceResponse/HandleOAuth1IdentityResponse`
56+
5357
### Configuring a Service
5458

5559
Details of services available need to be applied to the Umbraco web application's configuration, which, if using the `appSettings.json` file, will look as follows. Other sources such as environment variables can also be used, as per standard .NET configuration.
@@ -212,7 +216,7 @@ An enum value that defines the JSON serializer to use when creating requests and
212216

213217
###### AuthorizationRequestRequiresAuthorizationHeaderWithBasicToken
214218

215-
This flag indicates whether the basic token should be included in the request for access token. If true, a base64 encoding of <clientId>:<clientSecret> will be added to
219+
This flag indicates whether the basic token should be included in the request for access token. If true, a base64 encoding of <clientId>:<clientSecret> will be added to
216220
the authorization header.
217221

218222
###### API Key
@@ -279,7 +283,7 @@ To make a call to an authorized service, you first need to obtain an instance of
279283
If making a request where all information is provided via the path and querystring, such as GET requests, the following method should be invoked:
280284

281285
```csharp
282-
Task<TResponse> SendRequestAsync<TResponse>(string serviceAlias, string path, HttpMethod httpMethod);
286+
Task<Attempt<TResponse?>> SendRequestAsync<TResponse>(string serviceAlias, string path, HttpMethod httpMethod);
283287
```
284288

285289
The parameters for the request are as follows:
@@ -294,7 +298,7 @@ There is also a type parameter:
294298
If you need to provide data in the request, as is usually the case for POST or PUT requests that required the creation or update of a resource, an overload is available:
295299

296300
```csharp
297-
Task<TResponse> SendRequestAsync<TRequest, TResponse>(string serviceAlias, string path, HttpMethod httpMethod, TRequest? requestContent = null)
301+
Task<Attempt<TResponse>> SendRequestAsync<TRequest, TResponse>(string serviceAlias, string path, HttpMethod httpMethod, TRequest? requestContent = null)
298302
where TRequest : class;
299303
```
300304

@@ -309,16 +313,16 @@ And additional type parameter:
309313
If you need to work with the raw JSON response, there are equivalent methods for both of these that omit the deserialization step:
310314

311315
```csharp
312-
Task<string> SendRequestRawAsync(string serviceAlias, string path, HttpMethod httpMethod);
316+
Task<Attempt<string?>> SendRequestRawAsync(string serviceAlias, string path, HttpMethod httpMethod);
313317

314-
Task<string> SendRequestRawAsync<TRequest>(string serviceAlias, string path, HttpMethod httpMethod, TRequest? requestContent = null)
318+
Task<<Attempt<string?>> SendRequestRawAsync<TRequest>(string serviceAlias, string path, HttpMethod httpMethod, TRequest? requestContent = null)
315319
where TRequest : class;
316320
```
317321

318322
Finally, there are convenience extension methods available for each of the common HTTP verbs, allowing you to simplify the requests and omit the `HttpMethod` parameter, e.g.
319323

320324
```csharp
321-
Task<TResponse> GetRequestAsync<TResponse>(string serviceAlias, string path);
325+
Task<Attempt<TResponse?>> GetRequestAsync<TResponse>(string serviceAlias, string path);
322326
```
323327

324328
## Providers
@@ -337,6 +341,40 @@ The branching strategy in this repository follows a "gitflow" model:
337341

338342
The following details are those useful for those contributing to development of the package, and for anyone interested in the how it has been implemented. For anyone using the package too, and finding the existing configuration options aren't sufficient to specify a particular service, there may be scope to provide a custom implementation for particular components.
339343

344+
### Flow Diagrams
345+
346+
The following diagrams indicate some of the key authentication and authorization flows supported by the package, along with the components involved.
347+
348+
#### OAuth2 Display of Service Status and Authorization Link
349+
350+
This diagram shows the steps involved with finding and displaying the status of a service in the backoffice, along with how the authorization URL that the user is presented with to initiate the authorization process is generated.
351+
352+
![OAuth2 Display of Service Status](./docs/images/oauth2-display-service-status.png)
353+
354+
#### OAuth2 Authorization Flow
355+
356+
This diagram shows the steps and components involved in the authorization flow for the OAuth2 protocol.
357+
358+
![OAuth2 Authorization Flow](./docs/images/oauth2-authorization-flow.png)
359+
360+
#### OAuth1 Display of Service Status and Authorization Link
361+
362+
This diagram shows the steps involved with finding and displaying the status of a service in the backoffice, along with how the authorization URL that the user is presented with to initiate the authorization process is generated.
363+
364+
![OAuth1 Display of Service Status](./docs/images/oauth1-display-service-status.png)
365+
366+
#### OAuth1 Authorization Flow
367+
368+
This diagram shows the steps and components involved in the authorization flow for the OAuth1 protocol.
369+
370+
![OAuth1 Authorization Flow](./docs/images/oauth1-authorization-flow.png)
371+
372+
#### Calling an Authorized Service
373+
374+
The following diagram shows the steps and components involved in making a request to an external service. It shows the three methods available: OAuth2, OAuth1 and API key.
375+
376+
![OAuth2 Authorization Flow](./docs/images/call-authorized-service.png)
377+
340378
### Component Description
341379

342380
Note that there has been a deliberate decision taken in designing the package to use a number of components, each responsible for a small part of the authentication and authorization flow. In this way, there's more scope for an implementor to replace specific parts of the implementation should they need to.

0 commit comments

Comments
 (0)