Skip to content

Commit b46feda

Browse files
committed
rename authorisation to authorization
1 parent b2dd70f commit b46feda

Some content is hidden

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

43 files changed

+295
-295
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ A quick list of Ocelot's capabilities for more information see the [documentatio
3030
* Kubernetes
3131
* WebSockets
3232
* Authentication
33-
* Authorisation
33+
* Authorization
3434
* Rate Limiting
3535
* Caching
3636
* Retry policies / QoS

docs/features/authentication.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Authentication
22
==============
33

4-
In order to authenticate Routes and subsequently use any of Ocelot's claims based features such as authorisation or modifying the request with values from the token. Users must register authentication services in their Startup.cs as usual but they provide a scheme (authentication provider key) with each registration e.g.
4+
In order to authenticate Routes and subsequently use any of Ocelot's claims based features such as authorization or modifying the request with values from the token. Users must register authentication services in their Startup.cs as usual but they provide a scheme (authentication provider key) with each registration e.g.
55

66
.. code-block:: csharp
77
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
Authorisation
1+
Authorization
22
=============
33

4-
Ocelot supports claims based authorisation which is run post authentication. This means if you have a route you want to authorise you can add the following to you Route configuration.
4+
Ocelot supports claims based authorization which is run post authentication. This means if you have a route you want to authorize you can add the following to you Route configuration.
55

66
.. code-block:: json
77
88
"RouteClaimsRequirement": {
99
"UserType": "registered"
1010
}
1111
12-
In this example when the authorisation middleware is called Ocelot will check to seeif the user has the claim type UserType and if the value of that claim is registered. If it isn't then the user will not be authorised and the response will be 403 forbidden.
12+
In this example when the authorization middleware is called Ocelot will check to seeif the user has the claim type UserType and if the value of that claim is registered. If it isn't then the user will not be authorized and the response will be 403 forbidden.
1313

1414

1515

docs/features/claimstransformation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Claims Transformation
33

44
Ocelot allows the user to access claims and transform them into headers, query string parameters, other claims and change downstream paths. This is only available once a user has been authenticated.
55

6-
After the user is authenticated we run the claims to claims transformation middleware. This allows the user to transform claims before the authorisation middleware is called. After the user is authorised first we call the claims to headers middleware, thenthe claims to query string parameters middleware, and Finally the claims to downstream pathmiddleware.
6+
After the user is authenticated we run the claims to claims transformation middleware. This allows the user to transform claims before the authorization middleware is called. After the user is authorized first we call the claims to headers middleware, thenthe claims to query string parameters middleware, and Finally the claims to downstream pathmiddleware.
77

88
The syntax for performing the transforms is the same for each process. In the Route configuration a json dictionary is added with a specific name either AddClaimsToRequest, AddHeadersToRequest, AddQueriesToRequest, or ChangeDownstreamPathTemplate.
99

docs/features/errorcodes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Http Error Status Codes
33

44
Ocelot will return HTTP status error codes based on internal logic in certain siturations:
55
- 401 if the authentication middleware runs and the user is not authenticated.
6-
- 403 if the authorisation middleware runs and the user is unauthenticated, claim value not authroised, scope not authorised, user doesnt have required claim or cannot find claim.
6+
- 403 if the authorization middleware runs and the user is unauthenticated, claim value not authroised, scope not authorized, user doesnt have required claim or cannot find claim.
77
- 503 if the downstream request times out.
88
- 499 if the request is cancelled by the client.
99
- 404 if unable to find a downstream route.

docs/features/middlewareinjection.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ The user can set functions against the following.
3131

3232
* AuthenticationMiddleware - This overrides Ocelots authentication middleware.
3333

34-
* PreAuthorisationMiddleware - This allows the user to run pre authorisation logic and then call Ocelot's authorisation middleware.
34+
* PreAuthorizationMiddleware - This allows the user to run pre authorization logic and then call Ocelot's authorization middleware.
3535

36-
* AuthorisationMiddleware - This overrides Ocelots authorisation middleware.
36+
* AuthorizationMiddleware - This overrides Ocelots authorization middleware.
3737

3838
* PreQueryStringBuilderMiddleware - This allows the user to manipulate the query string on the http request before it is passed to Ocelots request creator.
3939

docs/features/requestid.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ Below is an example of the logging when set at Debug level for a normal request.
4444
requestId: asdf, previousRequestId: no previous request id, message: downstream template is {downstreamRoute.Data.Route.DownstreamPath},
4545
dbug: Ocelot.RateLimit.Middleware.ClientRateLimitMiddleware[0]
4646
requestId: asdf, previousRequestId: no previous request id, message: EndpointRateLimiting is not enabled for Ocelot.Values.PathTemplate,
47-
dbug: Ocelot.Authorisation.Middleware.AuthorisationMiddleware[0]
48-
requestId: 1234, previousRequestId: asdf, message: /posts/{postId} route does not require user to be authorised,
47+
dbug: Ocelot.Authorization.Middleware.AuthorizationMiddleware[0]
48+
requestId: 1234, previousRequestId: asdf, message: /posts/{postId} route does not require user to be authorized,
4949
dbug: Ocelot.DownstreamUrlCreator.Middleware.DownstreamUrlCreatorMiddleware[0]
5050
requestId: 1234, previousRequestId: asdf, message: downstream url is {downstreamUrl.Data.Value},
5151
dbug: Ocelot.Request.Middleware.HttpRequestBuilderMiddleware[0]

docs/features/websockets.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ Unfortunately a lot of Ocelot's features are non websocket specific such as head
102102
9. Claims Transformation
103103
10. Caching
104104
11. Authentication - If anyone requests it we might be able to do something with basic authentication.
105-
12. Authorisation
105+
12. Authorization
106106

107107
I'm not 100% sure what will happen with this feature when it get's into the wild so please make sure you test thoroughly!
108108

docs/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Thanks for taking a look at the Ocelot documentation. Please use the left hand n
2626
features/servicefabric
2727
features/kubernetes
2828
features/authentication
29-
features/authorisation
29+
features/authorization
3030
features/websockets
3131
features/administration
3232
features/ratelimiting

samples/OcelotGraphQL/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Ocelot using GraphQL example
22

33
Loads of people keep asking me if Ocelot will every support GraphQL, in my mind Ocelot and GraphQL are two different things that can work together.
4-
I would not try and implement GraphQL in Ocelot instead I would either have Ocelot in front of GraphQL to handle things like authorisation / authentication or I would
4+
I would not try and implement GraphQL in Ocelot instead I would either have Ocelot in front of GraphQL to handle things like authorization / authentication or I would
55
bring in the awesome [graphql-dotnet](https://github.com/graphql-dotnet/graphql-dotnet) library and use it in a [DelegatingHandler](http://ocelot.readthedocs.io/en/latest/features/delegatinghandlers.html). This way you could have Ocelot and GraphQL without the extra hop to GraphQL. This same is an example of how to do that.
66

77
## Example

src/Ocelot/Authorisation/ClaimValueNotAuthorisedError.cs

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/Ocelot/Authorisation/Middleware/AuthorisationMiddlewareMiddlewareExtensions.cs

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/Ocelot/Authorisation/ScopeNotAuthorisedError.cs

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
namespace Ocelot.Authorization
2+
{
3+
using Ocelot.Errors;
4+
using System.Net;
5+
6+
public class ClaimValueNotAuthorizedError : Error
7+
{
8+
public ClaimValueNotAuthorizedError(string message)
9+
: base(message, OcelotErrorCode.ClaimValueNotAuthorizedError, 403)
10+
{
11+
}
12+
}
13+
}

src/Ocelot/Authorisation/ClaimsAuthoriser.cs renamed to src/Ocelot/Authorization/ClaimsAuthorizer.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace Ocelot.Authorisation
1+
namespace Ocelot.Authorization
22
{
33
using Ocelot.Infrastructure.Claims.Parser;
44
using Ocelot.DownstreamRouteFinder.UrlMatcher;
@@ -8,16 +8,16 @@
88
using System.Security.Claims;
99
using System.Text.RegularExpressions;
1010

11-
public class ClaimsAuthoriser : IClaimsAuthoriser
11+
public class ClaimsAuthorizer : IClaimsAuthorizer
1212
{
1313
private readonly IClaimsParser _claimsParser;
1414

15-
public ClaimsAuthoriser(IClaimsParser claimsParser)
15+
public ClaimsAuthorizer(IClaimsParser claimsParser)
1616
{
1717
_claimsParser = claimsParser;
1818
}
1919

20-
public Response<bool> Authorise(
20+
public Response<bool> Authorize(
2121
ClaimsPrincipal claimsPrincipal,
2222
Dictionary<string, string> routeClaimsRequirement,
2323
List<PlaceholderNameAndValue> urlPathPlaceholderNameAndValues
@@ -45,10 +45,10 @@ List<PlaceholderNameAndValue> urlPathPlaceholderNameAndValues
4545
{
4646
// match
4747
var actualValue = matchingPlaceholders[0].Value;
48-
var authorised = values.Data.Contains(actualValue);
49-
if (!authorised)
48+
var authorized = values.Data.Contains(actualValue);
49+
if (!authorized)
5050
{
51-
return new ErrorResponse<bool>(new ClaimValueNotAuthorisedError(
51+
return new ErrorResponse<bool>(new ClaimValueNotAuthorizedError(
5252
$"dynamic claim value for {variableName} of {string.Join(", ", values.Data)} is not the same as required value: {actualValue}"));
5353
}
5454
}
@@ -57,23 +57,23 @@ List<PlaceholderNameAndValue> urlPathPlaceholderNameAndValues
5757
// config error
5858
if (matchingPlaceholders.Length == 0)
5959
{
60-
return new ErrorResponse<bool>(new ClaimValueNotAuthorisedError(
60+
return new ErrorResponse<bool>(new ClaimValueNotAuthorizedError(
6161
$"config error: requires variable claim value: {variableName} placeholders does not contain that variable: {string.Join(", ", urlPathPlaceholderNameAndValues.Select(p => p.Name))}"));
6262
}
6363
else
6464
{
65-
return new ErrorResponse<bool>(new ClaimValueNotAuthorisedError(
65+
return new ErrorResponse<bool>(new ClaimValueNotAuthorizedError(
6666
$"config error: requires variable claim value: {required.Value} but placeholders are ambiguous: {string.Join(", ", urlPathPlaceholderNameAndValues.Where(p => p.Name.Equals(variableName)).Select(p => p.Value))}"));
6767
}
6868
}
6969
}
7070
else
7171
{
7272
// static claim
73-
var authorised = values.Data.Contains(required.Value);
74-
if (!authorised)
73+
var authorized = values.Data.Contains(required.Value);
74+
if (!authorized)
7575
{
76-
return new ErrorResponse<bool>(new ClaimValueNotAuthorisedError(
76+
return new ErrorResponse<bool>(new ClaimValueNotAuthorizedError(
7777
$"claim value: {string.Join(", ", values.Data)} is not the same as required value: {required.Value} for type: {required.Key}"));
7878
}
7979
}

src/Ocelot/Authorisation/IClaimsAuthoriser.cs renamed to src/Ocelot/Authorization/IClaimsAuthorizer.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
using Ocelot.Responses;
33
using System.Security.Claims;
44

5-
namespace Ocelot.Authorisation
5+
namespace Ocelot.Authorization
66
{
77
using System.Collections.Generic;
88

9-
public interface IClaimsAuthoriser
9+
public interface IClaimsAuthorizer
1010
{
11-
Response<bool> Authorise(
11+
Response<bool> Authorize(
1212
ClaimsPrincipal claimsPrincipal,
1313
Dictionary<string, string> routeClaimsRequirement,
14-
List<PlaceholderNameAndValue> urlPathPlaceholderNameAndValues
14+
List<PlaceholderNameAndValue> urlPathPlaceholderNameAndValues
1515
);
1616
}
17-
}
17+
}
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
using Ocelot.Responses;
22
using System.Security.Claims;
33

4-
namespace Ocelot.Authorisation
4+
namespace Ocelot.Authorization
55
{
66
using System.Collections.Generic;
77

8-
public interface IScopesAuthoriser
8+
public interface IScopesAuthorizer
99
{
10-
Response<bool> Authorise(ClaimsPrincipal claimsPrincipal, List<string> routeAllowedScopes);
10+
Response<bool> Authorize(ClaimsPrincipal claimsPrincipal, List<string> routeAllowedScopes);
1111
}
12-
}
12+
}

0 commit comments

Comments
 (0)