Skip to content

Commit

Permalink
Merge branch 'dev' into gfi-duplicate-log-key-id
Browse files Browse the repository at this point in the history
  • Loading branch information
jennyf19 authored Jan 5, 2025
2 parents a1a4054 + fd9be46 commit 27daa29
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 76 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/aot-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
fetch-depth: 1

- name: Setup .NET 9.0.x
uses: actions/setup-dotnet@v4.1.0
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x

Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ jobs:
with:
fetch-depth: 2

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
Expand Down
33 changes: 16 additions & 17 deletions .github/workflows/dotnetcore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
uses: actions/[email protected]

- name: Setup .NET 9.x
uses: actions/setup-dotnet@v4.1.0
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.x

Expand All @@ -49,28 +49,27 @@ jobs:
- name: Create code coverage report
run: |
dotnet tool install -g dotnet-reportgenerator-globaltool --version 5.4.1
reportgenerator -reports:./**/coverage.cobertura.xml -targetdir:CodeCoverage -reporttypes:'MarkdownSummaryGithub;Cobertura'
reportgenerator -reports:./**/coverage.cobertura.xml -targetdir:CodeCoverage -reporttypes:'MarkdownSummaryGithub;Cobertura' -filefilters:'+src/**/*.cs'
- name: Write coverage to job summary
shell: bash
run: |
cat CodeCoverage/SummaryGithub.md >> $GITHUB_STEP_SUMMARY
# Temporarily disable commenting the coverage report
# echo "COMMENT_CONTENT_ENV_VAR<<EOF" >> $GITHUB_ENV
# echo $(cat CodeCoverage/SummaryGithub.md) >> $GITHUB_ENV
# echo "EOF" >> $GITHUB_ENV
echo "COMMENT_CONTENT_ENV_VAR<<EOF" >> $GITHUB_ENV
echo $(cat CodeCoverage/SummaryGithub.md) >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
# - name: Comment coverage in PR
# uses: actions/github-script@v7
# id: comment
# with:
# script: |
# github.rest.issues.createComment({
# issue_number: context.issue.number,
# owner: context.repo.owner,
# repo: context.repo.repo,
# body: process.env.COMMENT_CONTENT_ENV_VAR
# })
- name: Comment coverage in PR
uses: actions/github-script@v7
id: comment
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: process.env.COMMENT_CONTENT_ENV_VAR
})
# Run baseline package validation
- name: Pack
Expand Down
58 changes: 0 additions & 58 deletions src/Microsoft.IdentityModel.JsonWebTokens/JsonWebToken.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ public partial class JsonWebToken : SecurityToken
{
internal const string ClassName = "Microsoft.IdentityModel.JsonWebTokens.JsonWebToken";

private ClaimsIdentity _claimsIdentity;
private bool _wasClaimsIdentitySet;

private string _act;
private string _authenticationTag;
private string _ciphertext;
Expand Down Expand Up @@ -629,61 +626,6 @@ public Claim GetClaim(string key)
/// </summary>
internal IReadOnlyCollection<string> PayloadClaimNames => Payload._jsonClaims.Keys;

internal ClaimsIdentity ClaimsIdentity
{
get
{
if (!_wasClaimsIdentitySet)
{
_wasClaimsIdentitySet = true;
string actualIssuer = ActualIssuer ?? Issuer;

foreach (Claim claim in Claims)
{
string claimType = claim.Type;
if (claimType == ClaimTypes.Actor)
{
if (_claimsIdentity.Actor != null)
throw LogHelper.LogExceptionMessage(new InvalidOperationException(LogHelper.FormatInvariant(LogMessages.IDX14112, LogHelper.MarkAsNonPII(JwtRegisteredClaimNames.Actort), claim.Value)));

#pragma warning disable CA1031 // Do not catch general exception types
try
{
JsonWebToken actorToken = new JsonWebToken(claim.Value);
_claimsIdentity.Actor = ActorClaimsIdentity;
}
catch
{

}
#pragma warning restore CA1031 // Do not catch general exception types
}

if (claim.Properties.Count == 0)
{
_claimsIdentity.AddClaim(new Claim(claimType, claim.Value, claim.ValueType, actualIssuer, actualIssuer, _claimsIdentity));
}
else
{
Claim newClaim = new Claim(claimType, claim.Value, claim.ValueType, actualIssuer, actualIssuer, _claimsIdentity);

foreach (var kv in claim.Properties)
newClaim.Properties[kv.Key] = kv.Value;

_claimsIdentity.AddClaim(newClaim);
}
}
}

return _claimsIdentity;
}

set
{
_claimsIdentity = value;
}
}

/// <summary>
/// Try to get a <see cref="Claim"/> representing the { key, 'value' } pair corresponding to the provided <paramref name="key"/>.
/// The value is obtained from the Payload.
Expand Down

0 comments on commit 27daa29

Please sign in to comment.