Skip to content

Commit

Permalink
Merging hotfix 0.3.13
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm360 committed Jan 25, 2022
2 parents 42227b9 + cad1475 commit 2d011d4
Show file tree
Hide file tree
Showing 26 changed files with 245 additions and 35 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/unstable-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ on:
push:
branches:
- dev
- 'hotfix/**'
- 'release/**'

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion src/EthernaSSO.Domain/EthernaSSO.Domain.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<ItemGroup>
<PackageReference Include="Etherna.DomainEvents" Version="1.3.0" />
<PackageReference Include="EthernaSSL" Version="0.1.0-alpha.18" />
<PackageReference Include="EthernaACR" Version="0.3.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Etherna" Version="0.3.0-alpha.7" />
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="5.0.12" />
<PackageReference Include="MongODM.Core" Version="0.23.0-alpha.74" />
Expand Down
16 changes: 15 additions & 1 deletion src/EthernaSSO.Domain/ISharedDbContext.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
using Etherna.MongODM.Core;
// Copyright 2021-present Etherna Sagl
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using Etherna.MongODM.Core;
using Etherna.MongODM.Core.Repositories;
using Etherna.SSOServer.Domain.Models.UserAgg;

Expand Down
16 changes: 15 additions & 1 deletion src/EthernaSSO.Domain/Models/UserAgg/UserSharedInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
using Microsoft.AspNetCore.Identity;
// Copyright 2021-present Etherna Sagl
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using Microsoft.AspNetCore.Identity;
using Nethereum.Util;
using System;
using System.Collections.Generic;
Expand Down
2 changes: 1 addition & 1 deletion src/EthernaSSO.Domain/Models/UserBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using Etherna.ACR.Helpers;
using Etherna.Authentication;
using Etherna.MongODM.Core.Attributes;
using Etherna.SSL.Helpers;
using Etherna.SSOServer.Domain.Helpers;
using Etherna.SSOServer.Domain.Models.UserAgg;
using Microsoft.AspNetCore.Identity;
Expand Down
2 changes: 1 addition & 1 deletion src/EthernaSSO.Persistence/EthernaSSO.Persistence.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

namespace Etherna.SSOServer.Persistence.Settings
{
public class DbSeedSettings
public class SsoDbSeedSettings
{
public string FirstAdminUsername { get; set; } = default!;
public string FirstAdminPassword { get; set; } = default!;
Expand Down
16 changes: 15 additions & 1 deletion src/EthernaSSO.Persistence/SharedDbContext.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
using Etherna.DomainEvents;
// Copyright 2021-present Etherna Sagl
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using Etherna.DomainEvents;
using Etherna.MongoDB.Driver;
using Etherna.MongODM.Core;
using Etherna.MongODM.Core.Repositories;
Expand Down
4 changes: 2 additions & 2 deletions src/EthernaSSO.Persistence/SsoDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ public class SsoDbContext : DbContext, IEventDispatcherDbContext, ISsoDbContext
private const string ModelMapsNamespace = "Etherna.SSOServer.Persistence.ModelMaps.Sso";

// Fields.
private readonly DbSeedSettings seedSettings;
private readonly SsoDbSeedSettings seedSettings;
private readonly IServiceProvider serviceProvider;

// Constructor.
public SsoDbContext(
IEventDispatcher eventDispatcher,
DbSeedSettings seedSettings,
SsoDbSeedSettings seedSettings,
IServiceProvider serviceProvider)
{
EventDispatcher = eventDispatcher;
Expand Down
2 changes: 1 addition & 1 deletion src/EthernaSSO.Services/Domain/UserService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using Etherna.ACR.Helpers;
using Etherna.MongoDB.Bson;
using Etherna.MongoDB.Driver.Linq;
using Etherna.MongODM.Core.Exceptions;
using Etherna.MongODM.Core.Repositories;
using Etherna.SSL.Helpers;
using Etherna.SSOServer.Domain;
using Etherna.SSOServer.Domain.Helpers;
using Etherna.SSOServer.Domain.Models;
Expand Down
2 changes: 1 addition & 1 deletion src/EthernaSSO.Services/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using Etherna.ACR;
using Etherna.DomainEvents;
using Etherna.DomainEvents.AspNetCore;
using Etherna.SSL;
using Etherna.SSOServer.Services.Domain;
using Etherna.SSOServer.Services.Tasks;
using Microsoft.Extensions.DependencyInjection;
Expand Down
4 changes: 2 additions & 2 deletions src/EthernaSSO/Areas/Admin/Pages/Invitations/Index.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using Etherna.ACR.Helpers;
using Etherna.ACR.Services;
using Etherna.MongoDB.Driver.Linq;
using Etherna.SSL.Helpers;
using Etherna.SSL.Services;
using Etherna.SSOServer.Configs;
using Etherna.SSOServer.Domain;
using Etherna.SSOServer.Domain.Models;
Expand Down
4 changes: 2 additions & 2 deletions src/EthernaSSO/Areas/Admin/Pages/_ViewImports.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
*@

@using Microsoft.AspNetCore.Identity
@using Etherna.SSL
@using Etherna.SSL.Pages.SharedModels
@using Etherna.ACR
@using Etherna.ACR.Pages.SharedModels
@using Etherna.SSOServer.Areas.Admin
@using Etherna.SSOServer.Areas.Admin.Pages
@using Etherna.SSOServer.Configs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using Etherna.ACR.Helpers;
using Etherna.MongoDB.Driver.Linq;
using Etherna.SSL.Helpers;
using Etherna.SSOServer.Areas.Api.DtoModels;
using Etherna.SSOServer.Domain;
using Etherna.SSOServer.Domain.Helpers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using Etherna.SSL.Services;
using Etherna.ACR.Services;
using Etherna.SSOServer.Configs;
using Etherna.SSOServer.Domain.Models;
using Microsoft.AspNetCore.Authorization;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using Etherna.SSL.Services;
using Etherna.ACR.Services;
using Etherna.SSOServer.Domain;
using Etherna.SSOServer.Domain.Models;
using Microsoft.AspNetCore.Identity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using Etherna.SSL.Helpers;
using Etherna.SSL.Services;
using Etherna.ACR.Helpers;
using Etherna.ACR.Services;
using Etherna.SSOServer.Domain;
using Etherna.SSOServer.Domain.Models;
using Etherna.SSOServer.Services.Views.Emails;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
using Etherna.SSOServer.Domain.Models;
// Copyright 2021-present Etherna Sagl
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using Etherna.SSOServer.Domain.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using System;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
using Microsoft.AspNetCore.Authorization;
// Copyright 2021-present Etherna Sagl
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using Microsoft.AspNetCore.Authorization;

namespace Etherna.SSOServer.Configs.Authorization
{
Expand Down
2 changes: 1 addition & 1 deletion src/EthernaSSO/Configs/IdentityServer/IdServerConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using Etherna.ACR.Exceptions;
using Etherna.Authentication;
using Etherna.SSL.Exceptions;
using IdentityServer4;
using IdentityServer4.Models;
using Microsoft.Extensions.Configuration;
Expand Down
111 changes: 111 additions & 0 deletions src/EthernaSSO/Configs/SystemStore/PersistedGrantRepository.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
// Copyright 2021-present Etherna Sagl
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using Etherna.MongoDB.Bson.Serialization;
using Etherna.MongoDB.Bson.Serialization.Conventions;
using Etherna.MongoDB.Driver;
using Etherna.MongoDB.Driver.Linq;
using Etherna.MongODM.Core.Options;
using IdentityServer4.Extensions;
using IdentityServer4.Models;
using IdentityServer4.Stores;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Etherna.SSOServer.Configs.SystemStore
{
public class PersistedGrantRepository : IPersistedGrantStore
{
// Consts.
public const string KeyIndexName = "keys_unique";

// Fields.
private readonly IMongoCollection<PersistedGrant> collection;

// Constructor.
public PersistedGrantRepository(DbContextOptions options, string name)
{
if (options is null)
throw new ArgumentNullException(nameof(options));

// Register class map. (see: https://etherna.atlassian.net/browse/ESSO-140)
BsonClassMap.RegisterClassMap<PersistedGrant>(cm =>
{
cm.AutoMap();
cm.MapIdProperty(x => x.Key);
});

// Register discriminator convention. Default from MongODM doesn't work without DbContext.
BsonSerializer.RegisterDiscriminatorConvention(typeof(PersistedGrant),
StandardDiscriminatorConvention.Hierarchical);

// Initialize MongoDB driver.
var client = new MongoClient(options.ConnectionString);
var database = client.GetDatabase(options.DbName);
collection = database.GetCollection<PersistedGrant>(name);
}

// Methods.
public async Task<IEnumerable<PersistedGrant>> GetAllAsync(PersistedGrantFilter filter)
{
if (filter is null)
throw new ArgumentNullException(nameof(filter));
filter.Validate();

var cursor = await collection.FindAsync(BuildMongoFilterHelper(filter));
return await cursor.ToListAsync();
}

public Task<PersistedGrant> GetAsync(string key) =>
collection.AsQueryable()
.SingleOrDefaultAsync(x => x.Key == key);

public Task RemoveAllAsync(PersistedGrantFilter filter)
{
if (filter is null)
throw new ArgumentNullException(nameof(filter));
filter.Validate();

return collection.DeleteManyAsync(BuildMongoFilterHelper(filter));
}

public Task RemoveAsync(string key) =>
collection.DeleteOneAsync(x => x.Key == key);

public Task StoreAsync(PersistedGrant grant) =>
collection.ReplaceOneAsync(x => x.Key == grant.Key, grant, new ReplaceOptions { IsUpsert = true });

// Helpers.
private FilterDefinition<PersistedGrant> BuildMongoFilterHelper(PersistedGrantFilter sourceFilter)
{
var fieldFilters = new List<FilterDefinition<PersistedGrant>>();

if (!string.IsNullOrWhiteSpace(sourceFilter.ClientId))
fieldFilters.Add(Builders<PersistedGrant>.Filter.Eq(x => x.ClientId, sourceFilter.ClientId));

if (!string.IsNullOrWhiteSpace(sourceFilter.SessionId))
fieldFilters.Add(Builders<PersistedGrant>.Filter.Eq(x => x.SessionId, sourceFilter.SessionId));

if (!string.IsNullOrWhiteSpace(sourceFilter.SubjectId))
fieldFilters.Add(Builders<PersistedGrant>.Filter.Eq(x => x.SubjectId, sourceFilter.SubjectId));

if (!string.IsNullOrWhiteSpace(sourceFilter.Type))
fieldFilters.Add(Builders<PersistedGrant>.Filter.Eq(x => x.Type, sourceFilter.Type));

return Builders<PersistedGrant>.Filter.And(fieldFilters);
}
}
}
4 changes: 2 additions & 2 deletions src/EthernaSSO/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using Etherna.SSL.Exceptions;
using Etherna.SSL.Filters;
using Etherna.ACR.Exceptions;
using Etherna.ACR.Filters;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
Expand Down
Loading

0 comments on commit 2d011d4

Please sign in to comment.