Skip to content

Commit 2ad4850

Browse files
committed
Merge from Master
2 parents 1d46ba3 + 846ea60 commit 2ad4850

16 files changed

Lines changed: 126 additions & 35 deletions

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ Sample .NET Core reference application, powered by Microsoft, based on a simplif
33
**Note for Pull Requests**: We accept pull request from the community. When doing it, please do it onto the DEV branch which is the consolidated work-in-progress branch. Do not request it onto Master, if possible.
44

55
> ### DISCLAIMER
6-
> **IMPORTANT:** The current state of this sample application is **BETA**, consider it version a 0.1 foundational version, therefore, many areas could be improved and change significantly while refactoring current code and implementing new features. **Feedback with improvements and pull requests from the community will be highly appreciated and accepted.**
6+
> **IMPORTANT:** The current state of this sample application is **BETA**, consider it version a 0.1 foundational version, therefore, many areas could be improved and change significantly while refactoring current code and implementing new features. **Feedback with improvements and pull requests from the community will be highly appreciated and accepted.**
77
>
88
> This reference application proposes a simplified microservice oriented architecture implementation to introduce technologies like .NET Core with Docker containers through a comprehensive application. The chosen domain is an eShop/eCommerce but simply because it is a well-know domain by most people/developers.
9-
However, this sample application should not be considered as an "eCommerce reference model", at all. The implemented business domain might not be ideal from an eCommerce business point of view. It is neither trying to solve all the problems in a large, scalable and mission-critical distributed system. It is just a bootstrap for developers to easily get started in the world of Docker containers and microservices with .NET Core.
10-
> <p>For example, the next step (still not covered in eShopOnContainers) after understanding Docker containers and microservices development with .NET Core, is to select a microservice cluster/orchestrator like Docker Swarm, Kubernetes or DC/OS (in Azure Container Service) or Azure Service Fabric which in most of the cases will require additional partial changes to your application's configuration (although the present architecture should work on most orchestrators with small changes).
9+
However, this sample application should not be considered as an "eCommerce reference model", at all. The implemented business domain might not be ideal from an eCommerce business point of view. It is neither trying to solve all the problems in a large, scalable and mission-critical distributed system. It is just a bootstrap for developers to easily get started in the world of Docker containers and microservices with .NET Core.
10+
> <p>For example, the next step (still not covered in eShopOnContainers) after understanding Docker containers and microservices development with .NET Core, is to select a microservice cluster/orchestrator like Docker Swarm, Kubernetes or DC/OS (in Azure Container Service) or Azure Service Fabric which in most of the cases will require additional partial changes to your application's configuration (although the present architecture should work on most orchestrators with small changes).
1111
> Additional steps would be to move your databases to HA cloud services, or to implement your EventBus with Azure Service Bus or any other production ready Service Bus in the market.
1212
> <p> In the future we might fork this project and make multiple versions targeting specific microservice cluster/orchestrators plus using additional cloud infrastructure. <p>
1313
> <img src="img/exploring-to-production-ready.png">
1414
> Read the planned <a href='https://github.com/dotnet/eShopOnContainers/wiki/01.-Roadmap-and-Milestones-for-future-releases'>Roadmap and Milestones for future releases of eShopOnContainers</a> within the Wiki for further info about possible new implementations and provide feedback at the <a href='https://github.com/dotnet/eShopOnContainers/issues'>ISSUES section</a> if you'd like to see any specific scenario implemented or improved. Also, feel free to discuss on any current issue.
1515
16-
**Architecture overview**: This reference application is cross-platform either at the server and client side, thanks to .NET Core services capable of running on Linux or Windows containers depending on your Docker host, and to Xamarin for mobile apps running on Android, iOS or Windows/UWP plus any browser for the client web apps.
17-
The architecture proposes a simplified microservice oriented architecture implementation with multiple autonomous microservices (each one owning its own data/db) and implementing different approaches within each microservice (simple CRUD vs. DDD/CQRS patterns) using Http as the current communication protocol.
16+
**Architecture overview**: This reference application is cross-platform either at the server and client side, thanks to .NET Core services capable of running on Linux or Windows containers depending on your Docker host, and to Xamarin for mobile apps running on Android, iOS or Windows/UWP plus any browser for the client web apps.
17+
The architecture proposes a simplified microservice oriented architecture implementation with multiple autonomous microservices (each one owning its own data/db) and implementing different approaches within each microservice (simple CRUD vs. DDD/CQRS patterns) using Http as the current communication protocol.
1818
<p>
19-
It also supports asynchronous communication for data updates propagation across multiple services based on Integration Events and an Event Bus plus other features defined at the <a href='https://github.com/dotnet/eShopOnContainers/wiki/01.-Roadmap-and-Milestones-for-future-releases'>roadmap</a>.
19+
It also supports asynchronous communication for data updates propagation across multiple services based on Integration Events and an Event Bus plus other features defined at the <a href='https://github.com/dotnet/eShopOnContainers/wiki/01.-Roadmap-and-Milestones-for-future-releases'>roadmap</a>.
2020
<p>
2121
<img src="img/eshop_logo.png">
2222
<img src="img/eShopOnContainers_Architecture_Diagram.png">
@@ -43,7 +43,7 @@ You can download them and start reviewing these Guides/eBooks here:
4343
| Architecting & Developing | Containers Lifecycle & CI/CD | App patterns with Xamarin.Forms |
4444
| ------------ | ------------| ------------|
4545
| <a href='https://aka.ms/microservicesebook'><img src="img/ebook_arch_dev_microservices_containers_cover.png"> </a> | <a href='https://aka.ms/dockerlifecycleebook'> <img src="img/ebook_containers_lifecycle.png"> </a> | <a href='https://aka.ms/xamarinpatternsebook'> <img src="img/xamarin-enterprise-patterns-ebook-cover-small.png"> </a> |
46-
| <sup> <a href='https://aka.ms/microservicesebook'>**Download** (First Edition)</a> </sup> | <sup> <a href='https://aka.ms/dockerlifecycleebook'>**Download** (First Edition from late 2016) </a> </sup> | <sup> <a href='https://aka.ms/xamarinpatternsebook'>**Download** (Preview Edition) </a> </sup> |
46+
| <sup> <a href='https://aka.ms/microservicesebook'>**Download** (First Edition)</a> </sup> | <sup> <a href='https://aka.ms/dockerlifecycleebook'>**Download** (First Edition from late 2016) </a> </sup> | <sup> <a href='https://aka.ms/xamarinpatternsebook'>**Download** (First Edition) </a> </sup> |
4747

4848
Send feedback to [dotnet-architecture-ebooks-feedback@service.microsoft.com](dotnet-architecture-ebooks-feedback@service.microsoft.com)
4949
<p>
@@ -66,7 +66,7 @@ Finally, those microservices are consumed by multiple client web and mobile apps
6666
<b>*MVC Application (ASP.NET Core)*</b>: Its an MVC application where you can find interesting scenarios on how to consume HTTP-based microservices from C# running in the server side, as it is a typical ASP.NET Core MVC application. Since it is a server-side application, access to other containers/microservices is done within the internal Docker Host network with its internal name resolution.
6767
<img src="img/eshop-webmvc-app-screenshot.png">
6868
<br>
69-
<b>*SPA (Single Page Application)*</b>: Providing similar "eShop business functionality" but developed with Angular 2, Typescript and slightly using ASP.NET Core MVC. This is another approach for client web applications to be used when you want to have a more modern client behavior which is not behaving with the typical browser round-trip on every action but behaving like a Single-Page-Application which is more similar to a desktop app usage experience. The consumption of the HTTP-based microservices is done from TypeScript/JavaScript in the client browser, so the client calls to the microservices come from out of the Docker Host internal network (Like from your network or even from the Internet).
69+
<b>*SPA (Single Page Application)*</b>: Providing similar "eShop business functionality" but developed with Angular 2, Typescript and slightly using ASP.NET Core MVC. This is another approach for client web applications to be used when you want to have a more modern client behavior which is not behaving with the typical browser round-trip on every action but behaving like a Single-Page-Application which is more similar to a desktop app usage experience. The consumption of the HTTP-based microservices is done from TypeScript/JavaScript in the client browser, so the client calls to the microservices come from out of the Docker Host internal network (Like from your network or even from the Internet).
7070
<img src="img/eshop-webspa-app-screenshot.png">
7171
<br>
7272
<b>*Xamarin Mobile App (For iOS, Android and Windows/UWP)*</b>: It is a client mobile app supporting the most common mobile OS platforms (iOS, Android and Windows/UWP). In this case, the consumption of the microservices is done from C# but running on the client devices, so out of the Docker Host internal network (Like from your network or even the Internet).
@@ -76,19 +76,19 @@ Finally, those microservices are consumed by multiple client web and mobile apps
7676
## Setting up your development environment for eShopOnContainers
7777
### Visual Studio 2017 and Windows based
7878
This is the more straightforward way to get started:
79-
https://github.com/dotnet/eShopOnContainers/wiki/02.-Setting-eShopOnContainer-solution-up-in-a-Visual-Studio-2017-environment
79+
https://github.com/dotnet-architecture/eShopOnContainers/wiki/02.-Setting-eShopOnContainers-in-a-Visual-Studio-2017-environment
8080

8181
### CLI and Windows based
82-
For those who prefer the CLI on Windows, using dotnet CLI, docker CLI and VS Code for Windows:
82+
For those who prefer the CLI on Windows, using dotnet CLI, docker CLI and VS Code for Windows:
8383
https://github.com/dotnet/eShopOnContainers/wiki/03.-Setting-the-eShopOnContainers-solution-up-in-a-Windows-CLI-environment-(dotnet-CLI,-Docker-CLI-and-VS-Code)
8484

8585
### CLI and Mac based
86-
For those who prefer the CLI on a Mac, using dotnet CLI, docker CLI and VS Code for Mac
86+
For those who prefer the CLI on a Mac, using dotnet CLI, docker CLI and VS Code for Mac
8787
(Instructions still TBD, but similar to Windows CLI):
8888
https://github.com/dotnet/eShopOnContainers/wiki/04.-Setting-eShopOnContainer-solution-up-in-a-Mac,-VS-Code-and-CLI-environment--(dotnet-CLI,-Docker-CLI-and-VS-Code)
8989

9090
> ### Note on tested Docker Containers/Images
91-
> Most of the development and testing of this project was (as of early March 2017) done <b> on Docker Linux containers</b> running in development machines with "Docker for Windows" and the default Hyper-V Linux VM (MobiLinuxVM) installed by "Docker for Windows".
91+
> Most of the development and testing of this project was (as of early March 2017) done <b> on Docker Linux containers</b> running in development machines with "Docker for Windows" and the default Hyper-V Linux VM (MobiLinuxVM) installed by "Docker for Windows".
9292
The <b>Windows Containers scenario is currently being implemented/tested yet</b>. The application should be able to run on Windows Nano Containers based on different Docker base images, as well, as the .NET Core services have also been tested running on plain Windows (with no Docker).
9393
The app was also partially tested on "Docker for Mac" using a development MacOS machine with .NET Core and VS Code installed, which is still a scenario using Linux containers running on the VM setup in the Mac by the "Docker for Windows" setup. But further testing and feedback on Mac environments and Windows Containers, from the community, will be appreciated.
9494

@@ -118,4 +118,4 @@ You can create new issues at the issues section, do pull requests and/or send em
118118
119119
## Questions
120120
[QUESTION] Answer +1 if the solution is working for you (Through VS2017 or CLI environment):
121-
https://github.com/dotnet/eShopOnContainers/issues/107
121+
https://github.com/dotnet/eShopOnContainers/issues/107
34.4 KB
Binary file not shown.
Binary file not shown.
12.9 KB
Loading

src/Mobile/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
#eShopOnContainers
1+
# eShopOnContainers
22

33
eShopOnContainers is a reference app whose imagined purpose is to serve the mobile workforce of a fictitious company that sells products. The app allow to manage the catalog, view products, manage the basket and the orders.
44

55
<img src="Images/eShopOnContainers_Architecture_Diagram.png" alt="eShopOnContainers" Width="800" />
66

7-
###Supported platforms: iOS, Android and Windows
7+
### Supported platforms: iOS, Android and Windows
88

9-
###The app architecture consists of two parts:
9+
### The app architecture consists of two parts:
1010
1. A Xamarin.Forms mobile app for iOS, Android and Windows.
1111
2. Several .NET Web API microservices deployed as Docker containers.
1212

@@ -34,7 +34,7 @@ This project exercises the following platforms, frameworks or features:
3434
* Entity Framework
3535
* Identity Server 4
3636

37-
##Three platforms
37+
## Three platforms
3838
The app targets **three** platforms:
3939

4040
* iOS
@@ -45,7 +45,7 @@ The app targets **three** platforms:
4545

4646
As of 07/03/2017, eShopOnContainers features **89.2% code share** (7.2% iOS / 16.7% Android / 8.7% Windows).
4747

48-
##Licenses
48+
## Licenses
4949

5050
This project uses some third-party assets with a license that requires attribution:
5151

@@ -155,4 +155,4 @@ In the configuration window of the machine, go to the Compatibility section and
155155
<img src="Images/set-compatibility-vs-sml.png" alt="Migrate to a physical computer with a different processor version" Width="600" />
156156

157157
## Copyright and license
158-
* Code and documentation copyright 2017 Microsoft Corp. Code released under the [MIT license](https://opensource.org/licenses/MIT).
158+
* Code and documentation copyright 2017 Microsoft Corp. Code released under the [MIT license](https://opensource.org/licenses/MIT).

src/Mobile/eShopOnContainers/eShopOnContainers.Core/GlobalSettings.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ public class GlobalSetting
66
public const string MockTag = "Mock";
77
public const string DefaultEndpoint = "http://13.88.8.119";
88

9-
109
private string _baseEndpoint;
1110
private static readonly GlobalSetting _instance = new GlobalSetting();
1211

@@ -31,6 +30,10 @@ public string BaseEndpoint
3130
}
3231
}
3332

33+
public string ClientId { get { return "xamarin"; }}
34+
35+
public string ClientSecret { get { return "secret"; }}
36+
3437
public string AuthToken { get; set; }
3538

3639
public string RegisterWebsite { get; set; }
@@ -47,6 +50,8 @@ public string BaseEndpoint
4750

4851
public string UserInfoEndpoint { get; set; }
4952

53+
public string TokenEndpoint { get; set; }
54+
5055
public string LogoutEndpoint { get; set; }
5156

5257
public string IdentityCallback { get; set; }
@@ -61,6 +66,7 @@ private void UpdateEndpoint(string baseEndpoint)
6166
BasketEndpoint = string.Format("{0}:5103", baseEndpoint);
6267
IdentityEndpoint = string.Format("{0}:5105/connect/authorize", baseEndpoint);
6368
UserInfoEndpoint = string.Format("{0}:5105/connect/userinfo", baseEndpoint);
69+
TokenEndpoint = string.Format("{0}:5105/connect/token", baseEndpoint);
6470
LogoutEndpoint = string.Format("{0}:5105/connect/endsession", baseEndpoint);
6571
IdentityCallback = string.Format("{0}:5105/xamarincallback", baseEndpoint);
6672
LogoutCallback = string.Format("{0}:5105/Account/Redirecting", baseEndpoint);
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using Newtonsoft.Json;
2+
3+
namespace eShopOnContainers.Core.Models.Token
4+
{
5+
public class UserToken
6+
{
7+
[JsonProperty("id_token")]
8+
public string IdToken { get; set; }
9+
10+
[JsonProperty("access_token")]
11+
public string AccessToken { get; set; }
12+
13+
[JsonProperty("expires_in")]
14+
public int ExpiresIn { get; set; }
15+
16+
[JsonProperty("token_type")]
17+
public string TokenType { get; set; }
18+
19+
[JsonProperty("refresh_token")]
20+
public string RefreshToken { get; set; }
21+
}
22+
}
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
namespace eShopOnContainers.Core.Services.Identity
1+
using eShopOnContainers.Core.Models.Token;
2+
using System.Threading.Tasks;
3+
4+
namespace eShopOnContainers.Core.Services.Identity
25
{
36
public interface IIdentityService
47
{
58
string CreateAuthorizationRequest();
69
string CreateLogoutRequest(string token);
10+
Task<UserToken> GetTokenAsync(string code);
711
}
812
}

src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Identity/IdentityService.cs

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,33 @@
11
using IdentityModel.Client;
22
using System;
33
using System.Collections.Generic;
4+
using System.Net;
5+
using System.Threading.Tasks;
6+
using eShopOnContainers.Core.Services.RequestProvider;
7+
using eShopOnContainers.Core.Models.Token;
48

59
namespace eShopOnContainers.Core.Services.Identity
610
{
711
public class IdentityService : IIdentityService
812
{
13+
private readonly IRequestProvider _requestProvider;
14+
15+
public IdentityService(IRequestProvider requestProvider)
16+
{
17+
_requestProvider = requestProvider;
18+
}
19+
920
public string CreateAuthorizationRequest()
1021
{
1122
// Create URI to authorization endpoint
1223
var authorizeRequest = new AuthorizeRequest(GlobalSetting.Instance.IdentityEndpoint);
1324

1425
// Dictionary with values for the authorize request
1526
var dic = new Dictionary<string, string>();
16-
dic.Add("client_id", "xamarin");
17-
dic.Add("client_secret", "secret");
18-
dic.Add("response_type", "code id_token token");
27+
dic.Add("client_id", GlobalSetting.Instance.ClientId);
28+
dic.Add("client_secret", GlobalSetting.Instance.ClientSecret);
29+
dic.Add("response_type", "code id_token");
1930
dic.Add("scope", "openid profile basket orders locations offline_access");
20-
2131
dic.Add("redirect_uri", GlobalSetting.Instance.IdentityCallback);
2232
dic.Add("nonce", Guid.NewGuid().ToString("N"));
2333

@@ -31,7 +41,7 @@ public string CreateAuthorizationRequest()
3141

3242
public string CreateLogoutRequest(string token)
3343
{
34-
if(string.IsNullOrEmpty(token))
44+
if (string.IsNullOrEmpty(token))
3545
{
3646
return string.Empty;
3747
}
@@ -41,5 +51,12 @@ public string CreateLogoutRequest(string token)
4151
token,
4252
GlobalSetting.Instance.LogoutCallback);
4353
}
54+
55+
public async Task<UserToken> GetTokenAsync(string code)
56+
{
57+
string data = string.Format("grant_type=authorization_code&code={0}&redirect_uri={1}", code, WebUtility.UrlEncode(GlobalSetting.Instance.IdentityCallback));
58+
var token = await _requestProvider.PostAsync<UserToken>(GlobalSetting.Instance.TokenEndpoint, data, GlobalSetting.Instance.ClientId, GlobalSetting.Instance.ClientSecret);
59+
return token;
60+
}
4461
}
4562
}

src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/RequestProvider/IRequestProvider.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ public interface IRequestProvider
88

99
Task<TResult> PostAsync<TResult>(string uri, TResult data, string token = "", string header = "");
1010

11+
Task<TResult> PostAsync<TResult>(string uri, string data, string clientId, string clientSecret);
12+
1113
Task DeleteAsync(string uri, string token = "");
1214
}
1315
}

0 commit comments

Comments
 (0)