-
Notifications
You must be signed in to change notification settings - Fork 10
[Breaking] removing support for Bearer scheme and adding FunctionsBearer #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# Change log | ||
Change log stars with version 3.1.3 | ||
|
||
## 4.1.0 | ||
- ### [Breaking] Removing support for `Bearer` scheme and adding `FunctionsBearer` | ||
Recent security updates in the Azure Functions runtime are clashing with the use of the default, well known `Bearer` scheme.<br/> | ||
One of the effects of this change is the portal not able to interact with the functions app to retrieve runtime information and in some cases not able to retrieve functions information. | ||
In the past this was not an issue and application was able to replace the default `Bearer` configuration to enable the functionality provided by this package.<br/> | ||
Starting from this version, using the default `AddJwtBearer` with no custom name, will produce an error. You will have 2 options: you can switch your app to use `AddJwtFunctionsBearer` method without providing any name which will map your configuration to the `FunctionsBearer` scheme, or you can use `AddJwtBearer("<your-custom-scheme>", ...)` to specify something different. | ||
|
||
## 4.0.1 | ||
Deprecating `DarkLoop.Azure.Functions.Authorize` package in favor of `DarkLoop.Azure.Functions.Authorization.InProcess` package.<br/> | ||
The functionality remains the same, it's just a way to keep package naming in sync. | ||
|
||
## 4.0.0 | ||
Starting from 4.0.0, support for Azure Functions V4 Isolated mode with ASPNET Core integration is added. | ||
The package is now split into two separate packages, one for each mode. | ||
|
||
The package for Azure Functions V3+ In-Proc mode is now called `DarkLoop.Azure.Functions.Authorization.InProcess` and the package for Azure Functions V4 Isolated mode with ASPNET Core integration is called `DarkLoop.Azure.Functions.Authorize.Isolated`. | ||
|
||
- ### .NET 6 support | ||
Starting with version 4.0.0, the package is now targeting .NET 6.0. This means that the package is no longer compatible with .NET 5 or lower. If you are using .NET 5 or lower, you should use version 3.1.3 of the package. | ||
|
||
- ### DarkLoop.Azure.Functions.Authorize v4.0.0 | ||
This package is published but is now deprecated in favor of `DarkLoop.Azure.Functions.Authorization.InProcess`. All it's functionality remains the same. It's just a way to keep package naming in sync. | ||
|
||
- ### Introducing IFunctionsAuthorizationProvider interface | ||
The `IFunctionsAuthorizationProvider` interface is introduced to allow for custom authorization filter provisioning to the framework. | ||
By default the framework relies on decorating the function or type with `[FunctionAuthorize]`. You could skip this decoration and provide the middleware with an authorization filter sourced from your own mechanism, for example a database. | ||
At this moment this can be done only with Isolated mode even when the interface is defined in the shared package.<br/> | ||
Support for In-Process will be added in a future version, once source generators are introduced, as the in-process framework relies on Invocation Filters to enable authorization. | ||
Replacing the service in the application services would break the authorization for in-process mode at this point. | ||
|
||
## 3.1.3 | ||
3.1.3 and lower versions only support Azure Functions V3 In-Proc mode. Starting from 4.0.0, support for Azure Functions V4 Isolated mode with ASPNET Core integration is added. | ||
- ### Support for disabling `FunctionAuthorize` effect at the application level. | ||
Adding support for disabling the effect of `[FunctionAuthorize]` attribute at the application level. | ||
This is useful when wanting to disable authorization for a specific environment, such as local development. | ||
|
||
When configuring services, you can now configure `FunctionsAuthorizationOptions`. | ||
```csharp | ||
builder.Services.Configure<FunctionsAuthorizationOptions>(options => | ||
options.DisableAuthorization = Configuration.GetValue<bool>("AuthOptions:DisableAuthorization")); | ||
``` | ||
|
||
Optionally you can bind it to configuration to rely on providers like User Secrets or Azure App Configuration to disable and re-enable without having to restart your application: | ||
```csharp | ||
builder.Services.Configure<FunctionsAuthorizationOptions>( | ||
Configuration.GetSection("FunctionsAuthorization")); | ||
``` | ||
|
||
For function apps targeting .NET 7 or greater, you can also use `AuthorizationBuilder` to set this value: | ||
```csharp | ||
builder.Services | ||
.AddAuthorizationBuilder() | ||
.DisableAuthorization(Configuration.GetValue<bool>("AuthOptions:DisableAuthorization")); | ||
``` | ||
|
||
It's always recommended to encapsulate this logic within checks for environments to ensure that if the configuration setting is unintentionally moved to a non-desired environment, it would not affect security of our HTTP triggered functions. This change adds a helper method to identify if you are running the function app in the local environment: | ||
```csharp | ||
if (builder.IsLocalAuthorizationContext()) | ||
{ | ||
builder.Services.Configure<FunctionsAuthorizationOptions>( | ||
options => options.AuthorizationDisabled = true); | ||
} | ||
``` | ||
|
||
If you want to output warnings emitted by the library remember to set the log level to `Warning` or lower for `Darkloop` category in your `host.json` file: | ||
|
||
```json | ||
{ | ||
"logging": { | ||
"logLevel": { | ||
"DarkLoop": "Warning" | ||
} | ||
} | ||
} | ||
``` | ||
|
||
Thanks to [BenjaminWang1031](https://github.com/BenjaminWang1031) for the suggestion to add this functionality. | ||
|
||
- #### Remove Functions bult-in JwtBearer configuration by default | ||
Azure Functions recently [added configuration](https://github.com/Azure/azure-functions-host/pull/9678) for issuer and audience validation for the default authentication flows, not the one supported by this package through `FunctionAuthorizeAttribute`, which interferes with token validation when using our own Bearer scheme token configuration. | ||
In prior versions, this package has functionality to clear Functions built-in configuration, but it was not enabled by default when using `AddJwtBearer(Action<JwtBearerOptions> configure, bool removeBuiltInConfig = false)`. Since the use of this package is commonly used for custom JWT token, the default value of `removeBuiltInConfig` is now `true`. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,8 @@ | |
} | ||
}, | ||
"logLevel": { | ||
"Darkloop": "Information" | ||
"Darkloop": "Information", | ||
"Microsoft": "Information" | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.