Skip to content

Commit

Permalink
merge hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm360 committed Mar 11, 2024
2 parents 0359c58 + c83ce4d commit d00c533
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/EthernaSSO.Domain/EthernaSSO.Domain.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
<PackageReference Include="Etherna.Authentication.AspNetCore" Version="0.3.3" />
<PackageReference Include="Etherna.DomainEvents" Version="1.4.0" />
<PackageReference Include="EthernaACR" Version="0.3.10" />
<PackageReference Include="MongODM.Core" Version="0.24.0-alpha.98" />
<PackageReference Include="Nethereum.Accounts" Version="4.18.0" />
<PackageReference Include="MongODM.Core" Version="0.24.0-alpha.101" />
<PackageReference Include="Nethereum.Accounts" Version="4.19.0" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions src/EthernaSSO.Services/EthernaSSO.Services.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Duende.IdentityServer.AspNetIdentity" Version="6.3.7" />
<PackageReference Include="Duende.IdentityServer.AspNetIdentity" Version="7.0.1" />
<PackageReference Include="Etherna.DomainEvents.AspNetCore" Version="1.4.0" />
<PackageReference Include="MongODM.Hangfire" Version="0.24.0-alpha.98" />
<PackageReference Include="MongODM.Hangfire" Version="0.24.0-alpha.101" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using Etherna.MongODM.Core.Exceptions;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Serilog;
using System;
using System.Collections.Generic;

Expand All @@ -25,7 +26,11 @@ public sealed class HideUnauthorizedExceptionFilterAttribute : ExceptionFilterAt
public override void OnException(ExceptionContext context)
{
ArgumentNullException.ThrowIfNull(context, nameof(context));

// Log exception.
Log.Warning(context.Exception, "API exception");

// Handle exception.
switch (context.Exception)
{
case ArgumentException _:
Expand Down
5 changes: 5 additions & 0 deletions src/EthernaSSO/Attributes/SimpleExceptionFilterAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using Etherna.MongODM.Core.Exceptions;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Serilog;
using System;
using System.Collections.Generic;

Expand All @@ -25,7 +26,11 @@ public sealed class SimpleExceptionFilterAttribute : ExceptionFilterAttribute
public override void OnException(ExceptionContext context)
{
ArgumentNullException.ThrowIfNull(context, nameof(context));

// Log exception.
Log.Warning(context.Exception, "API exception");

// Handle exception.
switch (context.Exception)
{
case ArgumentException _:
Expand Down
40 changes: 40 additions & 0 deletions src/EthernaSSO/Configs/IdentityServer/IdServerConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ public static class IdResourcesDef
private readonly string ethernaGateway_Webapp_ClientId;
private readonly string ethernaGateway_Webapp_Secret;

private readonly string ethernaGatewayCli_BaseUrl;
private readonly string ethernaGatewayCli_ClientId;

private readonly string ethernaIndex_BaseUrl;
private readonly string ethernaIndex_Sso_ClientId;
private readonly string ethernaIndex_Sso_Secret;
Expand Down Expand Up @@ -139,6 +142,9 @@ public IdServerConfig(IConfiguration configuration)
ethernaGateway_Webapp_ClientId = configuration["IdServer:Clients:EthernaGateway:Clients:Webapp:ClientId"] ?? throw new ServiceConfigurationException();
ethernaGateway_Webapp_Secret = configuration["IdServer:Clients:EthernaGateway:Clients:Webapp:Secret"] ?? throw new ServiceConfigurationException();

ethernaGatewayCli_BaseUrl = configuration["IdServer:Clients:EthernaGatewayCli:BaseUrl"] ?? throw new ServiceConfigurationException();
ethernaGatewayCli_ClientId = configuration["IdServer:Clients:EthernaGatewayCli:ClientId"] ?? throw new ServiceConfigurationException();

ethernaIndex_BaseUrl = configuration["IdServer:Clients:EthernaIndex:BaseUrl"] ?? throw new ServiceConfigurationException();
ethernaIndex_Sso_ClientId = configuration["IdServer:Clients:EthernaIndex:Clients:SsoServer:ClientId"] ?? throw new ServiceConfigurationException();
ethernaIndex_Sso_Secret = configuration["IdServer:Clients:EthernaIndex:Clients:SsoServer:Secret"] ?? throw new ServiceConfigurationException();
Expand Down Expand Up @@ -334,6 +340,40 @@ public IdServerConfig(IConfiguration configuration)
// Allow token refresh.
AllowOfflineAccess = true
},

//gateway cli
new Client
{
ClientId = ethernaGatewayCli_ClientId,
ClientName = "Etherna Gateway CLI",
RequireClientSecret = false,

AllowedGrantTypes = GrantTypes.Code,

//where to redirect to after login
RedirectUris = { ethernaGatewayCli_BaseUrl },

//where to redirect to after logout
PostLogoutRedirectUris = { ethernaGatewayCli_BaseUrl },

AllowedCorsOrigins = { ethernaGatewayCli_BaseUrl },

AlwaysIncludeUserClaimsInIdToken = true,
AllowedScopes =
{
//identity
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile,
IdResourcesDef.EtherAccounts.Name,

//resource
ApiScopesDef.UserInteractEthernaGateway.Name,
},

// Allow token refresh.
AllowOfflineAccess = true,
RefreshTokenUsage = TokenUsage.OneTimeOnly //because client have not secret
},

//index (sso client)
new Client
Expand Down
14 changes: 5 additions & 9 deletions src/EthernaSSO/EthernaSSO.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,12 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="8.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer" Version="5.1.0" />
<PackageReference Include="Microsoft.TypeScript.MSBuild" Version="5.3.3"> <!--Installed only to hide warning-->
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="MongODM" Version="0.24.0-alpha.98" />
<PackageReference Include="MongODM.AspNetCore.UI" Version="0.24.0-alpha.98" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.0" />
<PackageReference Include="MongODM" Version="0.24.0-alpha.101" />
<PackageReference Include="MongODM.AspNetCore.UI" Version="0.24.0-alpha.101" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.1" />
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.3.0" />
<PackageReference Include="Serilog.Exceptions" Version="8.4.0" />
<PackageReference Include="Serilog.Sinks.Elasticsearch" Version="9.0.3" />
Expand Down
5 changes: 5 additions & 0 deletions src/EthernaSSO/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@
}
},

"EthernaGatewayCli": {
"BaseUrl": "http://127.0.0.1:11430",
"ClientId": "ethernaGatewayCliId"
},

"EthernaIndex": {
"Clients": {
"SsoServer": {
Expand Down
6 changes: 3 additions & 3 deletions src/EthernaSSO/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="Moq" Version="4.20.70" />
<PackageReference Include="xunit" Version="2.6.5" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6">
<PackageReference Include="xunit" Version="2.7.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down

0 comments on commit d00c533

Please sign in to comment.