-
Notifications
You must be signed in to change notification settings - Fork 271
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #159 from DuendeSoftware/joe/angular-net8
Rebuild Angular sample with new template and .NET 8
- Loading branch information
Showing
92 changed files
with
14,026 additions
and
22,353 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"version": "0.2.0", | ||
"compounds": [ | ||
{ | ||
"name": "All", | ||
"configurations": ["API", "BFF"], | ||
"presentation": { | ||
"hidden": false, | ||
"group": "compunds", | ||
} | ||
}, | ||
], | ||
"configurations": [ | ||
{ | ||
"name": "API", | ||
"type": "coreclr", | ||
"request": "launch", | ||
"preLaunchTask": "build-api", | ||
"program": "${workspaceFolder}/Angular.Api/bin/Debug/net8.0/Angular.Api.dll", | ||
"args": [], | ||
"cwd": "${workspaceFolder}/Angular.Api", | ||
"env": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
}, | ||
"console": "externalTerminal", | ||
}, | ||
{ | ||
"name": "BFF", | ||
"type": "coreclr", | ||
"request": "launch", | ||
"preLaunchTask": "build-bff", | ||
"program": "${workspaceFolder}/Angular.Bff/bin/Debug/net8.0/Angular.Bff.dll", | ||
"args": [], | ||
"cwd": "${workspaceFolder}/Angular.Bff", | ||
"env": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
}, | ||
"console": "externalTerminal", | ||
}, | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "build", | ||
"type": "process", | ||
"command": "dotnet", | ||
"args": [ | ||
"build", | ||
"${workspaceFolder}/Angular.sln", | ||
"/property:GenerateFullPaths=true", | ||
"/consoleloggerparameters:NoSummary" | ||
], | ||
"problemMatcher": "$msCompile" | ||
}, | ||
{ | ||
"label": "build-api", | ||
"type": "process", | ||
"command": "dotnet", | ||
"args": [ | ||
"build", | ||
"${workspaceFolder}/Angular.Api/Angular.Api.csproj", | ||
"/property:GenerateFullPaths=true", | ||
"/consoleloggerparameters:NoSummary" | ||
], | ||
"problemMatcher": "$msCompile" | ||
}, | ||
{ | ||
"label": "build-bff", | ||
"type": "process", | ||
"command": "dotnet", | ||
"args": [ | ||
"build", | ||
"${workspaceFolder}/Angular.Bff/Angular.Bff.csproj", | ||
"/property:GenerateFullPaths=true", | ||
"/consoleloggerparameters:NoSummary" | ||
], | ||
"problemMatcher": "$msCompile" | ||
}, | ||
] | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
IdentityServer/v7/BFF/Angular/Angular.Api/Angular.Api.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<InvariantGlobalization>true</InvariantGlobalization> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.1" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using Angular.Api; | ||
|
||
var builder = WebApplication.CreateBuilder(args); | ||
|
||
builder.Services.AddAuthentication("token") | ||
.AddJwtBearer("token", options => | ||
{ | ||
options.Authority = "https://demo.duendesoftware.com"; | ||
options.Audience = "api"; | ||
|
||
options.MapInboundClaims = false; | ||
}); | ||
|
||
builder.Services.AddAuthorization(options => | ||
{ | ||
options.AddPolicy("ApiCaller", policy => | ||
{ | ||
policy.RequireClaim("scope", "api"); | ||
}); | ||
|
||
options.AddPolicy("InteractiveUser", policy => | ||
{ | ||
policy.RequireClaim("sub"); | ||
}); | ||
}); | ||
|
||
var app = builder.Build(); | ||
|
||
app.UseHttpsRedirection(); | ||
|
||
app.MapGroup("/todos") | ||
.ToDoGroup() | ||
.RequireAuthorization("ApiCaller", "InteractiveUser"); | ||
|
||
|
||
app.Run(); | ||
|
14 changes: 14 additions & 0 deletions
14
IdentityServer/v7/BFF/Angular/Angular.Api/Properties/launchSettings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/launchsettings.json", | ||
"profiles": { | ||
"https": { | ||
"commandName": "Project", | ||
"dotnetRunMessages": true, | ||
"launchBrowser": false, | ||
"applicationUrl": "https://localhost:7001", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
} | ||
} | ||
} |
76 changes: 76 additions & 0 deletions
76
IdentityServer/v7/BFF/Angular/Angular.Api/ToDoEndpointGroup.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
using Microsoft.AspNetCore.Http.Extensions; | ||
using System.Security.Claims; | ||
|
||
namespace Angular.Api; | ||
|
||
public static class TodoEndpointGroup | ||
{ | ||
private static readonly List<ToDo> data = new List<ToDo>() | ||
{ | ||
new ToDo { Id = ToDo.NewId(), Date = DateTimeOffset.UtcNow, Name = "Demo ToDo API", User = "2 (Bob Smith)" }, | ||
new ToDo { Id = ToDo.NewId(), Date = DateTimeOffset.UtcNow.AddHours(1), Name = "Stop Demo", User = "2 (Bob Smith)" }, | ||
new ToDo { Id = ToDo.NewId(), Date = DateTimeOffset.UtcNow.AddHours(4), Name = "Have Dinner", User = "1 (Alice Smith)" }, | ||
}; | ||
|
||
public static RouteGroupBuilder ToDoGroup(this RouteGroupBuilder group) | ||
{ | ||
// GET | ||
group.MapGet("/", () => data); | ||
group.MapGet("/{id}", (int id) => | ||
{ | ||
var item = data.FirstOrDefault(x => x.Id == id); | ||
}); | ||
|
||
// POST | ||
group.MapPost("/", (ToDo model, ClaimsPrincipal user, HttpContext context) => | ||
{ | ||
model.Id = ToDo.NewId(); | ||
model.User = $"{user.FindFirst("sub")?.Value} ({user.FindFirst("name")?.Value})"; | ||
|
||
data.Add(model); | ||
|
||
var url = new Uri($"{context.Request.GetEncodedUrl()}/{model.Id}"); | ||
|
||
return Results.Created(url, model); | ||
}); | ||
|
||
// PUT | ||
group.MapPut("/{id}", (int id, ToDo model, ClaimsPrincipal User) => | ||
{ | ||
var item = data.FirstOrDefault(x => x.Id == id); | ||
if (item == null) return Results.NotFound(); | ||
|
||
item.Date = model.Date; | ||
item.Name = model.Name; | ||
|
||
return Results.NoContent(); | ||
}); | ||
|
||
// DELETE | ||
group.MapDelete("/{id}", (int id) => | ||
{ | ||
var item = data.FirstOrDefault(x => x.Id == id); | ||
if (item == null) return Results.NotFound(); | ||
|
||
data.Remove(item); | ||
|
||
return Results.NoContent(); | ||
}); | ||
|
||
return group; | ||
} | ||
} | ||
|
||
public class ToDo | ||
{ | ||
static int _nextId = 1; | ||
public static int NewId() | ||
{ | ||
return _nextId++; | ||
} | ||
|
||
public int Id { get; set; } | ||
public DateTimeOffset Date { get; set; } | ||
public string? Name { get; set; } | ||
public string? User { get; set; } | ||
} |
8 changes: 8 additions & 0 deletions
8
IdentityServer/v7/BFF/Angular/Angular.Api/appsettings.Development.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft.AspNetCore": "Warning" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft.AspNetCore": "Warning" | ||
} | ||
}, | ||
"AllowedHosts": "*" | ||
} |
27 changes: 27 additions & 0 deletions
27
IdentityServer/v7/BFF/Angular/Angular.Bff/Angular.Bff.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<InvariantGlobalization>true</InvariantGlobalization> | ||
<SpaRoot>..\angular.client</SpaRoot> | ||
<SpaProxyLaunchCommand>npm start</SpaProxyLaunchCommand> | ||
<SpaProxyServerUrl>https://localhost:4200</SpaProxyServerUrl> | ||
<RootNamespace>Angular.Bff</RootNamespace> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\angular.client\angular.client.esproj"> | ||
<ReferenceOutputAssembly>false</ReferenceOutputAssembly> | ||
</ProjectReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Duende.Bff.Yarp" Version="2.2.0" /> | ||
<PackageReference Include="Microsoft.AspNetCore.SpaProxy"> | ||
<Version>8.*-*</Version> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
IdentityServer/v7/BFF/Angular/Angular.Bff/Properties/launchSettings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/launchsettings.json", | ||
"profiles": { | ||
"https": { | ||
"commandName": "Project", | ||
"dotnetRunMessages": true, | ||
"launchBrowser": true, | ||
"applicationUrl": "https://localhost:6001", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development", | ||
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.SpaProxy" | ||
} | ||
} | ||
} | ||
} | ||
|
Oops, something went wrong.