Skip to content

Commit

Permalink
merge hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm360 committed May 25, 2022
2 parents d140921 + 2c02516 commit c57fe63
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/EthernaCredit.Services/EthernaCredit.Services.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<ItemGroup>
<PackageReference Include="Etherna.DomainEvents.AspNetCore" Version="1.3.1" />
<PackageReference Include="EthernaACR" Version="0.3.0" />
<PackageReference Include="EthernaServicesClient.AspNetCore" Version="0.3.0-alpha.38" />
<PackageReference Include="EthernaServicesClient.AspNetCore" Version="0.3.0-alpha.41" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Etherna" Version="0.3.0-alpha.7" />
</ItemGroup>

Expand Down
10 changes: 9 additions & 1 deletion src/EthernaCredit/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ public void ConfigureServices(IServiceCollection services)
});

// Configure authentication.
var allowUnsafeAuthorityConnection = false;
if (Configuration["SsoServer:AllowUnsafeConnection"] is not null)
allowUnsafeAuthorityConnection = bool.Parse(Configuration["SsoServer:AllowUnsafeConnection"]);

services.AddAuthentication(options =>
{
options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
Expand Down Expand Up @@ -175,6 +179,8 @@ public void ConfigureServices(IServiceCollection services)
options.Scope.Add("ether_accounts");
options.Scope.Add("role");

options.RequireHttpsMetadata = !allowUnsafeAuthorityConnection;

// Handle unauthorized call on api with 401 response. For users not logged in.
options.Events.OnRedirectToIdentityProvider = context =>
{
Expand All @@ -190,6 +196,8 @@ public void ConfigureServices(IServiceCollection services)
{
options.Audience = "ethernaCreditServiceInteract";
options.Authority = Configuration["SsoServer:BaseUrl"] ?? throw new ServiceConfigurationException();

options.RequireHttpsMetadata = !allowUnsafeAuthorityConnection;
});

// Configure authorization.
Expand Down Expand Up @@ -260,7 +268,7 @@ public void ConfigureServices(IServiceCollection services)
Configuration["SsoServer:Clients:SsoServer:ClientId"] ?? throw new ServiceConfigurationException(),
Configuration["SsoServer:Clients:SsoServer:Secret"] ?? throw new ServiceConfigurationException());

var clientCredentialTask = ethernaServiceClientBuilder.GetClientCredentialsTokenRequestAsync();
var clientCredentialTask = ethernaServiceClientBuilder.GetClientCredentialsTokenRequestAsync(!allowUnsafeAuthorityConnection);
clientCredentialTask.Wait();
var clientCredential = clientCredentialTask.Result;

Expand Down
1 change: 1 addition & 0 deletions src/EthernaCredit/appsettings.Development.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
},

"SsoServer": {
//"AllowUnsafeConnection": false,
"BaseUrl": "https://localhost:44379",
"Clients": {
"SsoServer": {
Expand Down

0 comments on commit c57fe63

Please sign in to comment.