Skip to content
This repository was archived by the owner on Aug 1, 2021. It is now read-only.

Commit 300f194

Browse files
Merge pull request #195 from brunohbrito/dev
ASP.NET Core 3.1
2 parents 6040cb5 + 134e742 commit 300f194

23 files changed

Lines changed: 239 additions & 74 deletions

api-light.dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
FROM mcr.microsoft.com/dotnet/core/aspnet:3.0-buster-slim AS base
1+
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
22
WORKDIR /app
33
EXPOSE 80
44
EXPOSE 443
55

6-
FROM mcr.microsoft.com/dotnet/core/sdk:3.0-buster AS build
6+
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
77
WORKDIR /src
88
COPY ["src/Backend/JPProject.Admin.Api/JPProject.Admin.Api.csproj", "Backend/JPProject.Admin.Api/"]
99
RUN dotnet restore "Backend/JPProject.Admin.Api/JPProject.Admin.Api.csproj"

azure-pipelines.pr.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ jobs:
1616
pool:
1717
vmImage: 'ubuntu-latest'
1818
steps:
19+
- task: UseDotNet@2
20+
displayName: 'Install .net core 3.1'
21+
inputs:
22+
packageType: 'sdk'
23+
version: '3.1.100'
24+
1925
- task: DotNetCoreCLI@2
2026
displayName: '.NET Core - Restore'
2127
inputs:

azure-pipelines.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ jobs:
1616
pool:
1717
vmImage: 'ubuntu-latest'
1818
steps:
19+
- task: UseDotNet@2
20+
displayName: 'Install .net core 3.1'
21+
inputs:
22+
packageType: 'sdk'
23+
version: '3.1.100'
24+
1925
- task: DotNetCoreCLI@2
2026
displayName: '.NET Core - Restore'
2127
inputs:

build/build.bat

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11

22
echo Restore nuget dep's
3-
dotnet build "../src/Backend/JPProject.Admin.Api"
3+
dotnet build "../src/Backend/Jp.UserManagement"
4+
dotnet build "../src/Frontend/Jp.UI.SSO"
5+
6+
CLS
7+
echo Build UserManagement
8+
start /d "../src/Frontend/Jp.UserManagement" npm install
49

510
echo Build AdminUi
611
start /d "../src/Frontend/Jp.AdminUI" npm install

build/docker-compose.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
version: "3"
2+
3+
services:
4+
5+
#############################
6+
# Database
7+
#############################
8+
jpdatabase:
9+
image: mysql
10+
container_name: jp-internal-db
11+
command: --default-authentication-plugin=mysql_native_password
12+
restart: always
13+
environment:
14+
MYSQL_ROOT_PASSWORD: root
15+
MYSQL_USER: jp
16+
MYSQL_DATABASE: jpproject
17+
MYSQL_PASSWORD: 10203040
18+
19+
#############################
20+
# Server SSO
21+
#############################
22+
jpproject-sso:
23+
image: bhdebrito/jpproject-sso:3.1.0
24+
container_name: jpproject-sso
25+
depends_on:
26+
- jpdatabase
27+
environment:
28+
ASPNETCORE_ENVIRONMENT: Development
29+
ASPNETCORE_URLS: http://+:5001
30+
CUSTOMCONNSTR_SSOConnection: "server=jpdatabase,port=3306;database=jpproject;user=jp;password=10203040"
31+
ApplicationSettings:EnableExternalProviders: "false" # Because Auth url is http://jpproject (modified by host to point to 127.0.0.1), then Google and Facebook reject it.
32+
ApplicationSettings:DatabaseType: MySql
33+
ApplicationSettings:DefaultUser: bruno
34+
ApplicationSettings:DefaultPass: Pa$$word123
35+
ApplicationSettings:DefaultEmail: bhdebrito@gmail.com
36+
ApplicationSettings:UserManagementURL: http://localhost:4200
37+
ApplicationSettings:IS4AdminUi: http://localhost:4300
38+
ApplicationSettings:ResourceServerURL: http://localhost:5002
39+
CertificateOptions:Type: Temporary
40+
41+
#############################
42+
# Management API
43+
#############################
44+
jpproject-api:
45+
image: bhdebrito/jpproject-api:3.1.0
46+
container_name: jpproject-api
47+
depends_on:
48+
- jpdatabase
49+
environment:
50+
ASPNETCORE_ENVIRONMENT: "Development"
51+
ASPNETCORE_URLS: http://+
52+
CUSTOMCONNSTR_SSOConnection: "server=jpdatabase,port=3306;database=jpproject;user=jp;password=10203040"
53+
ApplicationSettings:Authority: "http://jpproject-sso:5001"
54+
ApplicationSettings:DatabaseType: MySql
55+
56+
#############################
57+
# User management UI
58+
#############################
59+
jpproject-users:
60+
image: bhdebrito/jpproject-user-management-ui:3.0.2
61+
container_name: jpproject-users
62+
depends_on:
63+
- jpproject-api
64+
- jpproject-sso
65+
66+
#############################
67+
# Admin Ui
68+
#############################
69+
jpproject-admin-ui:
70+
image: bhdebrito/jpproject-admin-ui:3.0.2
71+
container_name: jpproject-admin-ui
72+
depends_on:
73+
- jpproject-api
74+
- jpproject-sso
75+
76+
77+
#############################
78+
# Reverse proxy
79+
#############################
80+
reverse-proxy:
81+
image: bhdebrito/jpproject-reverse-proxy:3.1.0
82+
container_name: jpproject-reverse-proxy
83+
ports:
84+
- '5001:5001'
85+
- '5002:5002'
86+
- '4200:4200'
87+
- '4300:4300'
88+
depends_on:
89+
- 'jpproject-api'
90+
- 'jpproject-users'
91+
- 'jpproject-sso'
92+
- 'jpproject-admin-ui'

build/jpproject-docker-windows.zip

-1.59 KB
Binary file not shown.

build/jpproject-docker.zip

1.68 KB
Binary file not shown.

build/update-host.bat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ ECHO.
55

66
SET NEWLINE=^& echo.
77
ECHO Carrying out requested modifications to your HOSTS file
8-
FIND /C /I "jpproject" %WINDIR%\system32\drivers\etc\hosts
8+
FIND /C /I "jpproject-sso" %WINDIR%\system32\drivers\etc\hosts
99
IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%>>%WINDIR%\system32\drivers\etc\hosts
10-
IF %ERRORLEVEL% NEQ 0 ECHO 127.0.0.1 jpproject>>%WINDIR%\system32\drivers\etc\hosts
10+
IF %ERRORLEVEL% NEQ 0 ECHO 127.0.0.1 jpproject-sso>>%WINDIR%\system32\drivers\etc\hosts
1111
ECHO Finished
1212
ECHO.
1313
EXIT
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
using Microsoft.AspNetCore.Authorization;
2+
3+
namespace JPProject.Admin.Api.Configuration.Authorization
4+
{
5+
public class AccountRequirement : IAuthorizationRequirement
6+
{
7+
}
8+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using Microsoft.AspNetCore.Authorization;
2+
using Microsoft.AspNetCore.Http;
3+
using System;
4+
using System.Threading.Tasks;
5+
6+
namespace JPProject.Admin.Api.Configuration.Authorization
7+
{
8+
public class AccountRequirementHandler : AuthorizationHandler<AccountRequirement>
9+
{
10+
private readonly IHttpContextAccessor _httpContextAccessor;
11+
12+
public AccountRequirementHandler(IHttpContextAccessor httpContextAccessor)
13+
{
14+
_httpContextAccessor = httpContextAccessor ?? throw new ArgumentNullException(nameof(httpContextAccessor));
15+
}
16+
protected override Task HandleRequirementAsync(
17+
AuthorizationHandlerContext context,
18+
AccountRequirement requirement)
19+
{
20+
21+
var httpMethod = _httpContextAccessor.HttpContext.Request.Method;
22+
23+
if (HttpMethods.IsGet(httpMethod) || HttpMethods.IsHead(httpMethod))
24+
{
25+
if (context.User.Identity.IsAuthenticated)
26+
{
27+
context.Succeed(requirement);
28+
return Task.CompletedTask;
29+
}
30+
}
31+
else
32+
{
33+
if (context.User.HasClaim("is4-rights", "manager") ||
34+
context.User.IsInRole("Administrator"))
35+
{
36+
context.Succeed(requirement);
37+
return Task.CompletedTask;
38+
}
39+
}
40+
context.Fail();
41+
return Task.CompletedTask;
42+
}
43+
}
44+
}

0 commit comments

Comments
 (0)