Skip to content

Commit

Permalink
Merge pull request #1658 from SimonCropp/remove-redundant-casts
Browse files Browse the repository at this point in the history
remove redundant casts
  • Loading branch information
josephdecock authored Dec 10, 2024
2 parents 9dd9ca7 + b86c551 commit 2b8ac55
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/EntityFramework.Storage/Entities/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class Client
public int RefreshTokenUsage { get; set; } = (int)TokenUsage.OneTimeOnly;
public bool UpdateAccessTokenClaimsOnRefresh { get; set; }
public int RefreshTokenExpiration { get; set; } = (int)TokenExpiration.Absolute;
public int AccessTokenType { get; set; } = (int)0; // AccessTokenType.Jwt;
public int AccessTokenType { get; set; } = 0; // AccessTokenType.Jwt;
public bool EnableLocalLogin { get; set; } = true;
public List<ClientIdPRestriction> IdentityProviderRestrictions { get; set; }
public bool IncludeJwtId { get; set; }
Expand Down
13 changes: 6 additions & 7 deletions src/EntityFramework.Storage/Extensions/ModelBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public static void ConfigurePersistedGrantContext(this ModelBuilder modelBuilder
grant.Property(x => x.Data).HasMaxLength(50000).IsRequired();

grant.HasKey(x => x.Id);

grant.HasIndex(x => x.Key).IsUnique();
grant.HasIndex(x => new { x.SubjectId, x.ClientId, x.Type });
grant.HasIndex(x => new { x.SubjectId, x.SessionId, x.Type });
Expand Down Expand Up @@ -310,18 +310,18 @@ public static void ConfigureResourcesContext(this ModelBuilder modelBuilder, Con
apiClaim.ToTable(storeOptions.ApiResourceClaim).HasKey(x => x.Id);

apiClaim.Property(x => x.Type).HasMaxLength(200).IsRequired();

apiClaim.HasIndex(x => new { x.ApiResourceId, x.Type }).IsUnique();
});

modelBuilder.Entity<ApiResourceScope>((System.Action<EntityTypeBuilder<ApiResourceScope>>)(apiScope =>
modelBuilder.Entity<ApiResourceScope>(apiScope =>
{
apiScope.ToTable((TableConfiguration)storeOptions.ApiResourceScope).HasKey(x => x.Id);
apiScope.ToTable(storeOptions.ApiResourceScope).HasKey(x => x.Id);

apiScope.Property(x => x.Scope).HasMaxLength(200).IsRequired();

apiScope.HasIndex(x => new { x.ApiResourceId, x.Scope }).IsUnique();
}));
});

modelBuilder.Entity<ApiResourceProperty>(property =>
{
Expand All @@ -332,7 +332,6 @@ public static void ConfigureResourcesContext(this ModelBuilder modelBuilder, Con
property.HasIndex(x => new { x.ApiResourceId, x.Key }).IsUnique();
});


modelBuilder.Entity<ApiScope>(scope =>
{
scope.ToTable(storeOptions.ApiScope).HasKey(x => x.Id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,17 +277,17 @@ internal async Task<KeyContainer> CreateAndStoreNewKeyAsync(SigningAlgorithmOpti
if (alg.IsRsaKey)
{
var rsa = CryptoHelper.CreateRsaSecurityKey(_options.KeyManagement.RsaKeySize);

container = alg.UseX509Certificate ?
new X509KeyContainer(rsa, alg.Name, now, _options.KeyManagement.KeyRetirementAge, iss) :
(KeyContainer)new RsaKeyContainer(rsa, alg.Name, now);
new RsaKeyContainer(rsa, alg.Name, now);
}
else if (alg.IsEcKey)
{
var ec = CryptoHelper.CreateECDsaSecurityKey(CryptoHelper.GetCurveNameFromSigningAlgorithm(alg.Name));
// X509 certs don't currently work with EC keys.
container = //_options.KeyManagement.WrapKeysInX509Certificate ? //new X509KeyContainer(ec, alg, now, _options.KeyManagement.KeyRetirementAge, iss) :
(KeyContainer) new EcKeyContainer(ec, alg.Name, now);
new EcKeyContainer(ec, alg.Name, now);
}
else
{
Expand Down

0 comments on commit 2b8ac55

Please sign in to comment.