-
Notifications
You must be signed in to change notification settings - Fork 120
Add issuer and expiration validation for API keys #6456
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
Add issuer and expiration validation for API keys #6456
Conversation
7ad32b8
to
9df6eae
Compare
...ts/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/Options/OptionsExtensions.ApiKey.cs
Outdated
Show resolved
Hide resolved
9df6eae
to
b08f3cc
Compare
b08f3cc
to
d465604
Compare
d465604
to
6549825
Compare
/backport to release/8.0 |
Started backporting to release/8.0: https://github.com/dotnet/dotnet-monitor/actions/runs/8791855621 |
/backport to release/7.x |
@jander-msft backporting to release/8.0 failed, the patch most likely resulted in conflicts. Please backport manually using one of the below commands, followed by PowerShell (Invoke-WebRequest "https://github.com/dotnet/dotnet-monitor/commit/e22a67d2d0b0cc46e5f137d3980fe9b16d61d0cc.patch").Content | git am --3way --ignore-whitespace --exclude="documentation/**.md" --keep-non-patch Bash curl -sSL "https://github.com/dotnet/dotnet-monitor/commit/e22a67d2d0b0cc46e5f137d3980fe9b16d61d0cc.patch" | git am --3way --ignore-whitespace --exclude="documentation/**.md" --keep-non-patch
$ git am --3way --ignore-whitespace --exclude="documentation/**.md" --keep-non-patch changes.patch
Applying: Add issuer and expiration validation for API keys (#6456)
.git/rebase-apply/patch:103: trailing whitespace.
.git/rebase-apply/patch:1138: trailing whitespace.
.git/rebase-apply/patch:1154: trailing whitespace.
warning: 3 lines add whitespace errors.
Using index info to reconstruct a base tree...
M documentation/schema.json
M src/Microsoft.Diagnostics.Monitoring.Options/OptionsDisplayStrings.Designer.cs
M src/Microsoft.Diagnostics.Monitoring.Options/OptionsDisplayStrings.resx
M src/Microsoft.Diagnostics.Monitoring.WebApi/Auth/AuthConstants.cs
M src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/Options/OptionsExtensions.cs
M src/Tools/dotnet-monitor/Strings.Designer.cs
M src/Tools/dotnet-monitor/Strings.resx
Falling back to patching base and 3-way merge...
Auto-merging src/Tools/dotnet-monitor/Strings.resx
Auto-merging src/Tools/dotnet-monitor/Strings.Designer.cs
Auto-merging src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/Options/OptionsExtensions.cs
Auto-merging src/Microsoft.Diagnostics.Monitoring.WebApi/Auth/AuthConstants.cs
Auto-merging src/Microsoft.Diagnostics.Monitoring.Options/OptionsDisplayStrings.resx
CONFLICT (content): Merge conflict in src/Microsoft.Diagnostics.Monitoring.Options/OptionsDisplayStrings.resx
Auto-merging src/Microsoft.Diagnostics.Monitoring.Options/OptionsDisplayStrings.Designer.cs
Auto-merging documentation/schema.json
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Add issuer and expiration validation for API keys (#6456)
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Error: The process '/usr/bin/git' failed with exit code 128 |
Started backporting to release/7.x: https://github.com/dotnet/dotnet-monitor/actions/runs/8791858247 |
@jander-msft backporting to release/7.x failed, the patch most likely resulted in conflicts. Please backport manually using one of the below commands, followed by PowerShell (Invoke-WebRequest "https://github.com/dotnet/dotnet-monitor/commit/e22a67d2d0b0cc46e5f137d3980fe9b16d61d0cc.patch").Content | git am --3way --ignore-whitespace --exclude="documentation/**.md" --keep-non-patch Bash curl -sSL "https://github.com/dotnet/dotnet-monitor/commit/e22a67d2d0b0cc46e5f137d3980fe9b16d61d0cc.patch" | git am --3way --ignore-whitespace --exclude="documentation/**.md" --keep-non-patch
$ git am --3way --ignore-whitespace --exclude="documentation/**.md" --keep-non-patch changes.patch
Applying: Add issuer and expiration validation for API keys (#6456)
.git/rebase-apply/patch:103: trailing whitespace.
.git/rebase-apply/patch:1138: trailing whitespace.
.git/rebase-apply/patch:1154: trailing whitespace.
warning: 3 lines add whitespace errors.
Using index info to reconstruct a base tree...
M documentation/schema.json
M src/Microsoft.Diagnostics.Monitoring.Options/OptionsDisplayStrings.Designer.cs
M src/Microsoft.Diagnostics.Monitoring.Options/OptionsDisplayStrings.resx
M src/Microsoft.Diagnostics.Monitoring.WebApi/Auth/AuthConstants.cs
M src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/AuthenticationTests.cs
M src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/Options/OptionsExtensions.cs
M src/Tools/dotnet-monitor/Auth/ApiKey/JwtBearerPostConfigure.cs
M src/Tools/dotnet-monitor/Commands/GenerateApiKeyCommandHandler.cs
M src/Tools/dotnet-monitor/Strings.Designer.cs
M src/Tools/dotnet-monitor/Strings.resx
Falling back to patching base and 3-way merge...
Auto-merging src/Tools/dotnet-monitor/Strings.resx
CONFLICT (content): Merge conflict in src/Tools/dotnet-monitor/Strings.resx
Auto-merging src/Tools/dotnet-monitor/Strings.Designer.cs
CONFLICT (content): Merge conflict in src/Tools/dotnet-monitor/Strings.Designer.cs
Auto-merging src/Tools/dotnet-monitor/Commands/GenerateApiKeyCommandHandler.cs
Auto-merging src/Tools/dotnet-monitor/Auth/ApiKey/JwtBearerPostConfigure.cs
Auto-merging src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/Options/OptionsExtensions.cs
CONFLICT (content): Merge conflict in src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/Options/OptionsExtensions.cs
Auto-merging src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/AuthenticationTests.cs
CONFLICT (content): Merge conflict in src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/AuthenticationTests.cs
Auto-merging src/Microsoft.Diagnostics.Monitoring.WebApi/Auth/AuthConstants.cs
Auto-merging src/Microsoft.Diagnostics.Monitoring.Options/OptionsDisplayStrings.resx
CONFLICT (content): Merge conflict in src/Microsoft.Diagnostics.Monitoring.Options/OptionsDisplayStrings.resx
Auto-merging src/Microsoft.Diagnostics.Monitoring.Options/OptionsDisplayStrings.Designer.cs
Auto-merging documentation/schema.json
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Add issuer and expiration validation for API keys (#6456)
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Error: The process '/usr/bin/git' failed with exit code 128 |
Summary
Enable validation for the
iss
andexp
fields in the API key token. These fields are now required to be in the token when using API key authentication.The
generatekey
command will produce a token with theiss
field set tohttps://github.com/dotnet/dotnet-monitor/generatekey+MonitorApiKey
(this is an existing behavior) and theexp
field set to expire 7 days from when the token was generated (this is a new behavior). The expiration can be overridden with the--expiration
option.In the case where a customer is generating their own JWT keys to be used with .NET Monitor, they can override the expected issuer in configuration by setting
Authentication__MonitorApiKey__Issuer
to the value of the issuer that is expected. Setting this is optional; its default value ishttps://github.com/dotnet/dotnet-monitor/generatekey+MonitorApiKey
.This is a breaking change because both the
iss
andexp
fields are now required and validated. This will not cause disruption to most usage of the API key authentication as it is expected that customers will use thegeneratekey
command to create the appropriate settings and the key will have a lifetime of 7 days. Those customers who are creating their own API key must now set bothiss
andexp
in the key and configureAuthentication__MonitorApiKey__Issuer
within .NET Monitor for the tool to accept the API key.Release Notes Entry