diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000..e0ff17a32 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,67 @@ +# How to contribute to eShopOnContainers + +This repo is a reference and learning resource and everyone is invited to contribute, however not all PRs will be accepted into the main branch (**`dev`**). + +There's a general development strategy that's driven by @CESARDELATORRE, who chooses, or defines criteria for choosing, the issues to include in the codebase, given a bunch of constraints and other guidelines. + +However you can always get in touch with him, if you want to implement some general-interest feature in your repo and have it referenced from the [documentation](https://docs.microsoft.com/dotnet/standard/microservices-architecture/) or the [Microservices eBook](https://aka.ms/microservicesebook/). + +## Coding Standards + +There are no explicit coding standards so pay attention to the general coding style, that's (mostly) used everywhere. + +However, there's only one **REALLY** important rule: **use spaces for indenting** 😉. + +## Development Process + +In order to help manage community contributions and avoid conflicts, there's a [Development project](https://github.com/dotnet-architecture/eShopOnContainers/projects/3) in this repo, to track assignments to any significant development effort. + +Great but... **what's "significant"**? + +That's not too easy to define and there are no clear criteria right now but, probably, changing "a couple" lines of code in one file would not qualify while changing "a bunch" of files would. + +We'll all be learning in the process so we'll figure it out somehow. + +### General Steps + +1. Issues are managed as usual with the regular issues list, just like any other repo. + +2. Once an issue is marked as a bug, enhancement, new feature or whatever needs development work, it will be labeled as a **backlog-item** and included as the last item in the Backlog project column. + +3. Community members can propose themselves to code an issue. + +4. @CESARDELATORRE/collaborators will prioritize the backlog items and arrange them in the **Backlog** column, so that the items in the top of the list are implemented first. + +5. @CESARDELATORRE/collaborators will review the issues and select the ones approved to begin development with, and move them to the **Approved** column. + +6. Issues in the **Approved** column can be assigned to a **collaborator** or to a **community member** who would then begin working on the issue and submit a PR as usual. + +## Tests + +There's not a tests policy in the project at this moment, but it'll be greatly appreciated if you include them within the [updated test structure](./test/readme.md). + +## Forks and Branches + +All contributions must be submitted as a [Pull Request (PR)](https://help.github.com/articles/about-pull-requests/) so you need to [fork this repo](https://help.github.com/articles/fork-a-repo/) on your GitHub account. + +The main branches are **`dev`** and **`master`**: + +- **`dev`**: Contains the latest code **and it is the branch actively developed**. +**All PRs must be against `dev` branch to be considered**. This branch is developed using .NET Core 2.x + +- **`master`**: Synced from time to time from **`dev`**. It contains "stable" code. +(**Keep in mind "stable" does not mean PRODUCTION-READY!**) + +- Any other branch is considered temporary and could be deleted at any time. Do not submit any PR to them! + +## DISCLAIMER - This is not a PRODUCTION-READY TEMPLATE for microservices +eShopOnContainers is a reference application to **showcase architectural patterns** for developing microservices applications on .NET Core. **IT IS NOT A PRODUCTION-READY TEMPLATE** to start real-world application. In fact, the application is in a **permanent beta state**, as it’s also used to test new potentially interesting technologies as they show up. + +Since this is a learning resource, some design decisions have favored simplicity to convey a pattern, over production-grade robustness. + +## Suggestions + +We hope this helps us all to work better and avoid some of the problems/frustrations of working in such a large community. + +We'd also appreciate any comments or ideas to improve this. + diff --git a/src/Services/Identity/Identity.API/Configuration/Config.cs b/src/Services/Identity/Identity.API/Configuration/Config.cs index b780d420f..e28d7f9d2 100644 --- a/src/Services/Identity/Identity.API/Configuration/Config.cs +++ b/src/Services/Identity/Identity.API/Configuration/Config.cs @@ -58,7 +58,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration "marketing", "webshoppingagg", "orders.signalrhub" - } + }, }, new Client { @@ -124,6 +124,8 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration "webshoppingagg", "orders.signalrhub" }, + AccessTokenLifetime = 60*60*2, // 2 hours + IdentityTokenLifetime= 60*60*2 // 2 hours }, new Client { @@ -248,7 +250,6 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration "webshoppingagg" } } - }; } } diff --git a/src/Services/Identity/Identity.API/Startup.cs b/src/Services/Identity/Identity.API/Startup.cs index 255bb82b5..789047657 100644 --- a/src/Services/Identity/Identity.API/Startup.cs +++ b/src/Services/Identity/Identity.API/Startup.cs @@ -80,30 +80,34 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API var migrationsAssembly = typeof(Startup).GetTypeInfo().Assembly.GetName().Name; // Adds IdentityServer - services.AddIdentityServer(x => x.IssuerUri = "null") - .AddSigningCredential(Certificate.Get()) - .AddAspNetIdentity() - .AddConfigurationStore(options => + services.AddIdentityServer(x => + { + x.IssuerUri = "null"; + x.Authentication.CookieLifetime = TimeSpan.FromHours(2); + }) + .AddSigningCredential(Certificate.Get()) + .AddAspNetIdentity() + .AddConfigurationStore(options => + { + options.ConfigureDbContext = builder => builder.UseSqlServer(connectionString, + sqlServerOptionsAction: sqlOptions => + { + sqlOptions.MigrationsAssembly(migrationsAssembly); + //Configuring Connection Resiliency: https://docs.microsoft.com/en-us/ef/core/miscellaneous/connection-resiliency + sqlOptions.EnableRetryOnFailure(maxRetryCount: 15, maxRetryDelay: TimeSpan.FromSeconds(30), errorNumbersToAdd: null); + }); + }) + .AddOperationalStore(options => { options.ConfigureDbContext = builder => builder.UseSqlServer(connectionString, - sqlServerOptionsAction: sqlOptions => - { - sqlOptions.MigrationsAssembly(migrationsAssembly); - //Configuring Connection Resiliency: https://docs.microsoft.com/en-us/ef/core/miscellaneous/connection-resiliency - sqlOptions.EnableRetryOnFailure(maxRetryCount: 15, maxRetryDelay: TimeSpan.FromSeconds(30), errorNumbersToAdd: null); - }); + sqlServerOptionsAction: sqlOptions => + { + sqlOptions.MigrationsAssembly(migrationsAssembly); + //Configuring Connection Resiliency: https://docs.microsoft.com/en-us/ef/core/miscellaneous/connection-resiliency + sqlOptions.EnableRetryOnFailure(maxRetryCount: 15, maxRetryDelay: TimeSpan.FromSeconds(30), errorNumbersToAdd: null); + }); }) - .AddOperationalStore(options => - { - options.ConfigureDbContext = builder => builder.UseSqlServer(connectionString, - sqlServerOptionsAction: sqlOptions => - { - sqlOptions.MigrationsAssembly(migrationsAssembly); - //Configuring Connection Resiliency: https://docs.microsoft.com/en-us/ef/core/miscellaneous/connection-resiliency - sqlOptions.EnableRetryOnFailure(maxRetryCount: 15, maxRetryDelay: TimeSpan.FromSeconds(30), errorNumbersToAdd: null); - }); - }) - .Services.AddTransient(); + .Services.AddTransient(); var container = new ContainerBuilder(); container.Populate(services); diff --git a/src/Services/Ordering/Ordering.BackgroundTasks/Tasks/Base/BackgroundTask.cs b/src/Services/Ordering/Ordering.BackgroundTasks/Tasks/Base/BackgroundTask.cs deleted file mode 100644 index 6611fc3ab..000000000 --- a/src/Services/Ordering/Ordering.BackgroundTasks/Tasks/Base/BackgroundTask.cs +++ /dev/null @@ -1,81 +0,0 @@ -using Microsoft.Extensions.Hosting; -using System; -using System.Threading; -using System.Threading.Tasks; - -namespace Ordering.BackgroundTasks.Tasks.Base -{ - // Copyright(c) .NET Foundation.All rights reserved. - // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - - /// - /// Base class for implementing a long running . - /// IMPORTANT: This base class is implemented in .NET Core 2.1 - Since this microservice is still in .NET Core 2.0, we're using the class within the project - /// When .NET Core 2.1 is released, this class should be removed and you should use the use implemented by the framework - /// https://github.com/aspnet/Hosting/blob/712c992ca827576c05923e6a134ca0bec87af4df/src/Microsoft.Extensions.Hosting.Abstractions/BackgroundService.cs - /// - /// - public abstract class BackgroundService : IHostedService, IDisposable - { - private Task _executingTask; - - private readonly CancellationTokenSource _stoppingCts = new CancellationTokenSource(); - - /// - /// This method is called when the starts. The implementation should return a task that represents - /// the lifetime of the long running operation(s) being performed. - /// - /// Triggered when is called. - /// A that represents the long running operations. - protected abstract Task ExecuteAsync(CancellationToken stoppingToken); - - /// - /// Triggered when the application host is ready to start the service. - /// - /// Indicates that the start process has been aborted. - public virtual Task StartAsync(CancellationToken cancellationToken) - { - // Store the task we're executing - _executingTask = ExecuteAsync(_stoppingCts.Token); - - // If the task is completed then return it, this will bubble cancellation and failure to the caller - if (_executingTask.IsCompleted) - { - return _executingTask; - } - - // Otherwise it's running - return Task.CompletedTask; - } - - /// - /// Triggered when the application host is performing a graceful shutdown. - /// - /// Indicates that the shutdown process should no longer be graceful. - public virtual async Task StopAsync(CancellationToken cancellationToken) - { - // Stop called without start - if (_executingTask == null) - { - return; - } - - try - { - // Signal cancellation to the executing method - _stoppingCts.Cancel(); - } - finally - { - // Wait until the task completes or the stop token triggers - await Task.WhenAny(_executingTask, Task.Delay(Timeout.Infinite, cancellationToken)); - } - - } - - public virtual void Dispose() - { - _stoppingCts.Cancel(); - } - } -} diff --git a/src/Services/Ordering/Ordering.BackgroundTasks/Tasks/GracePeriodManagerTask.cs b/src/Services/Ordering/Ordering.BackgroundTasks/Tasks/GracePeriodManagerTask.cs index c89b8cbf3..fbf92f978 100644 --- a/src/Services/Ordering/Ordering.BackgroundTasks/Tasks/GracePeriodManagerTask.cs +++ b/src/Services/Ordering/Ordering.BackgroundTasks/Tasks/GracePeriodManagerTask.cs @@ -1,10 +1,10 @@ using Dapper; using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Ordering.BackgroundTasks.Configuration; using Ordering.BackgroundTasks.IntegrationEvents; -using Ordering.BackgroundTasks.Tasks.Base; using System; using System.Collections.Generic; using System.Data.SqlClient; diff --git a/src/Services/Ordering/Ordering.Domain/AggregatesModel/OrderAggregate/OrderStatus.cs b/src/Services/Ordering/Ordering.Domain/AggregatesModel/OrderAggregate/OrderStatus.cs index bc07635ae..1716cc32d 100644 --- a/src/Services/Ordering/Ordering.Domain/AggregatesModel/OrderAggregate/OrderStatus.cs +++ b/src/Services/Ordering/Ordering.Domain/AggregatesModel/OrderAggregate/OrderStatus.cs @@ -1,8 +1,7 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate { using global::Ordering.Domain.Exceptions; - using Seedwork; - using SeedWork; + using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork; using System; using System.Collections.Generic; using System.Linq; diff --git a/src/Web/WebMVC/Startup.cs b/src/Web/WebMVC/Startup.cs index 9c1c0a3b8..fe1f5de21 100644 --- a/src/Web/WebMVC/Startup.cs +++ b/src/Web/WebMVC/Startup.cs @@ -238,7 +238,7 @@ namespace Microsoft.eShopOnContainers.WebMVC options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; options.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme; }) - .AddCookie() + .AddCookie(setup=>setup.ExpireTimeSpan = TimeSpan.FromHours(2)) .AddOpenIdConnect(options => { options.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; @@ -257,7 +257,7 @@ namespace Microsoft.eShopOnContainers.WebMVC options.Scope.Add("marketing"); options.Scope.Add("locations"); options.Scope.Add("webshoppingagg"); - options.Scope.Add("orders.signalrhub"); + options.Scope.Add("orders.signalrhub"); }); return services;