Skip to content

Commit 23c25b9

Browse files
authored
Merge pull request #9 from fmichellonet/features/throws_to_abort_http
- Rude http request abort. - Better exception message
2 parents 5b02884 + 0694da5 commit 23c25b9

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/AzureFunctions.Extensions.OpenIDConnect/AuthorizeFilter.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using Microsoft.AspNetCore.Authorization;
1+
using System;
2+
using Microsoft.AspNetCore.Authorization;
23

34
namespace AzureFunctions.Extensions.OpenIDConnect
45
{
@@ -64,12 +65,14 @@ private async Task Unauthorized(HttpContext httpContext, CancellationToken cance
6465
{
6566
httpContext.Response.StatusCode = (int)HttpStatusCode.Unauthorized;
6667
await httpContext.Response.WriteAsync(string.Empty, cancellationToken);
68+
throw new UnauthorizedAccessException();
6769
}
6870

6971
private async Task Forbidden(HttpContext httpContext, AuthorizationFailure failure, CancellationToken cancellationToken)
7072
{
7173
httpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden;
7274
await httpContext.Response.WriteAsync(failure.FailedRequirements.ToString(), cancellationToken);
75+
throw new UnauthorizedAccessException();
7376
}
7477
}
7578
}

src/AzureFunctions.Extensions.OpenIDConnect/Configuration/ServicesConfigurationExtensions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public static void AddOpenIDConnect(this IServiceCollection services, Action<Con
3232

3333
if (!builder.IsValid)
3434
{
35-
throw new ArgumentException("Be sure to configure Token Validation and Configuration Manager");
35+
throw new ArgumentException("Be sure to configure Token Validation and Configuration Manager (for example issuer url)");
3636
}
3737

3838
// These are created as a singletons, so that only one instance of each

0 commit comments

Comments
 (0)