Skip to content

Commit

Permalink
Add more Token validation configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
kbeaugrand committed Jun 29, 2022
1 parent 5337635 commit e8668a7
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/AzureIoTHub.Portal/Server/ConfigHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public abstract class ConfigHandler
internal const string OIDCValidateAudienceKey = "OIDC:ValidateAudience";
internal const string OIDCValidateLifetimeKey = "OIDC:ValidateLifetime";
internal const string OIDCValidateIssuerSigningKeyKey = "OIDC:ValidateIssuerSigningKey";
internal const string OIDCValidateActorKey = "OIDC:ValidateActor";
internal const string OIDCValidateTokenReplayKey = "OIDC:ValidateTokenReplay";

internal const string IsLoRaFeatureEnabledKey = "LoRaFeature:Enabled";

Expand Down Expand Up @@ -79,6 +81,10 @@ internal static ConfigHandler Create(IWebHostEnvironment env, IConfiguration con

internal abstract bool OIDCValidateIssuerSigningKey { get; }

internal abstract bool OIDCValidateActor { get; }

internal abstract bool OIDCValidateTokenReplay { get; }

internal abstract bool IsLoRaEnabled { get; }

internal abstract string StorageAccountBlobContainerName { get; }
Expand Down
4 changes: 4 additions & 0 deletions src/AzureIoTHub.Portal/Server/DevelopmentConfigHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ internal DevelopmentConfigHandler(IConfiguration config)

internal override bool OIDCValidateIssuerSigningKey => this.config.GetValue(OIDCValidateIssuerSigningKeyKey, true);

internal override bool OIDCValidateActor => this.config.GetValue(OIDCValidateActorKey, false);

internal override bool OIDCValidateTokenReplay => this.config.GetValue(OIDCValidateTokenReplayKey, false);

internal override bool IsLoRaEnabled => bool.Parse(this.config[IsLoRaFeatureEnabledKey] ?? "true");

internal override string StorageAccountBlobContainerName => this.config[StorageAccountBlobContainerNameKey];
Expand Down
4 changes: 4 additions & 0 deletions src/AzureIoTHub.Portal/Server/ProductionConfigHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ internal ProductionConfigHandler(IConfiguration config)

internal override bool OIDCValidateIssuerSigningKey => this.config.GetValue(OIDCValidateIssuerSigningKeyKey, true);

internal override bool OIDCValidateActor => this.config.GetValue(OIDCValidateActorKey, false);

internal override bool OIDCValidateTokenReplay => this.config.GetValue(OIDCValidateTokenReplayKey, false);

internal override bool IsLoRaEnabled => bool.Parse(this.config[IsLoRaFeatureEnabledKey] ?? "true");

internal override string StorageAccountBlobContainerName => this.config[StorageAccountBlobContainerNameKey];
Expand Down
2 changes: 2 additions & 0 deletions src/AzureIoTHub.Portal/Server/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ public void ConfigureServices(IServiceCollection services)
opts.TokenValidationParameters.ValidateAudience = configuration.OIDCValidateAudience;
opts.TokenValidationParameters.ValidateLifetime = configuration.OIDCValidateLifetime;
opts.TokenValidationParameters.ValidateIssuerSigningKey = configuration.OIDCValidateIssuerSigningKey;
opts.TokenValidationParameters.ValidateActor = configuration.OIDCValidateActor;
opts.TokenValidationParameters.ValidateTokenReplay = configuration.OIDCValidateTokenReplay;
});

_ = services.AddSingleton(configuration);
Expand Down

0 comments on commit e8668a7

Please sign in to comment.