Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Microsoft Identity #2

Merged
merged 4 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,6 @@
<PackageVersion Include="OpenTelemetry.Instrumentation.GrpcNetClient" Version="1.6.0-beta.2" />
<PackageVersion Include="OpenTelemetry.Instrumentation.Http" Version="1.6.0-beta.2" />
<PackageVersion Include="OpenTelemetry.Instrumentation.Runtime" Version="1.5.1" />
<!-- Identity Server -->
<PackageVersion Include="Duende.IdentityServer" Version="6.3.5" />
<PackageVersion Include="Duende.IdentityServer.AspNetIdentity" Version="6.3.5" />
<PackageVersion Include="Duende.IdentityServer.EntityFramework" Version="6.3.5" />
<PackageVersion Include="Duende.IdentityServer.EntityFramework.Storage" Version="6.3.5" />
<PackageVersion Include="Duende.IdentityServer.Storage" Version="6.3.5" />
<!-- VS Test -->
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<!-- Scaffolding -->
Expand All @@ -87,6 +81,7 @@
<PackageVersion Include="AspNetCore.HealthChecks.AzureServiceBus" Version="7.0.0" />
<PackageVersion Include="Azure.Messaging.ServiceBus" Version="7.16.2" />
<PackageVersion Include="Azure.Monitor.OpenTelemetry.AspNetCore" Version="1.0.0-beta.8" />
<PackageVersion Include="Microsoft.Identity.Web" Version="2.15.3" />
<!-- Miscellaneous -->
<PackageVersion Include="Automapper" Version="12.0.1" />
<PackageVersion Include="BuildBundlerMinifier" Version="3.2.449" />
Expand Down
7 changes: 0 additions & 7 deletions eShop.sln
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "eShop.ServiceDefaults", "sr
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EventBus", "src\EventBus\EventBus.csproj", "{53FC1F8E-F56F-4245-A4DD-5100FEB380EC}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Identity.API", "src\Identity.API\Identity.API.csproj", "{0A92921A-7B75-43C1-8A18-F3DE1D74C76E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IntegrationEventLogEF", "src\IntegrationEventLogEF\IntegrationEventLogEF.csproj", "{71B91168-EC19-4F90-8115-5C8CC2433832}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mobile.Bff.Shopping", "src\Mobile.Bff.Shopping\Mobile.Bff.Shopping.csproj", "{A6D9A9F5-E654-462F-A55F-320F386B163D}"
Expand Down Expand Up @@ -95,10 +93,6 @@ Global
{53FC1F8E-F56F-4245-A4DD-5100FEB380EC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{53FC1F8E-F56F-4245-A4DD-5100FEB380EC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{53FC1F8E-F56F-4245-A4DD-5100FEB380EC}.Release|Any CPU.Build.0 = Release|Any CPU
{0A92921A-7B75-43C1-8A18-F3DE1D74C76E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0A92921A-7B75-43C1-8A18-F3DE1D74C76E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0A92921A-7B75-43C1-8A18-F3DE1D74C76E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0A92921A-7B75-43C1-8A18-F3DE1D74C76E}.Release|Any CPU.Build.0 = Release|Any CPU
{71B91168-EC19-4F90-8115-5C8CC2433832}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{71B91168-EC19-4F90-8115-5C8CC2433832}.Debug|Any CPU.Build.0 = Debug|Any CPU
{71B91168-EC19-4F90-8115-5C8CC2433832}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -197,7 +191,6 @@ Global
{65321F44-C60B-4F80-B0D4-55E14E23CDB8} = {932D8224-11F6-4D07-B109-DA28AD288A63}
{CB04FF2E-F033-487F-8CC1-F2D3490F2187} = {932D8224-11F6-4D07-B109-DA28AD288A63}
{53FC1F8E-F56F-4245-A4DD-5100FEB380EC} = {932D8224-11F6-4D07-B109-DA28AD288A63}
{0A92921A-7B75-43C1-8A18-F3DE1D74C76E} = {932D8224-11F6-4D07-B109-DA28AD288A63}
{71B91168-EC19-4F90-8115-5C8CC2433832} = {932D8224-11F6-4D07-B109-DA28AD288A63}
{A6D9A9F5-E654-462F-A55F-320F386B163D} = {932D8224-11F6-4D07-B109-DA28AD288A63}
{C8BA83CE-480E-4CC7-9508-747A76671F63} = {932D8224-11F6-4D07-B109-DA28AD288A63}
Expand Down
2 changes: 0 additions & 2 deletions src/Basket.API/Grpc/BasketService.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Diagnostics.CodeAnalysis;
using eShop.Basket.API.Repositories;
using eShop.Basket.API.Extensions;
using eShop.Basket.API.Model;

namespace eShop.Basket.API.Grpc;
Expand All @@ -9,7 +8,6 @@ public class BasketService(
IBasketRepository repository,
ILogger<BasketService> logger) : Basket.BasketBase
{
[AllowAnonymous]
public override async Task<CustomerBasketResponse> GetBasket(GetBasketRequest request, ServerCallContext context)
{
var userId = context.GetUserIdentity();
Expand Down
8 changes: 6 additions & 2 deletions src/Basket.API/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
var builder = WebApplication.CreateBuilder(args);
using Microsoft.Identity.Web;

var builder = WebApplication.CreateBuilder(args);

builder.AddBasicServiceDefaults();
builder.AddApplicationServices();
Expand All @@ -9,6 +11,8 @@

app.MapDefaultEndpoints();

app.MapGrpcService<BasketService>();
app.MapGrpcService<BasketService>()
.RequireAuthorization()
.RequireScope(app.Configuration["AzureAD:Scopes"].Split(' '));

app.Run();
11 changes: 9 additions & 2 deletions src/Basket.API/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,16 @@
"EventBus": "amqp://localhost"
},
"Identity": {
"Audience": "basket"
"Audience": "https://localhost:7298/",
"Authority": "https://login.microsoftonline.com/<tenant id>/v2.0/"
},
"EventBus": {
"SubscriptionClientName": "Basket"
},
"AzureAd": {
"Instance": "https://login.microsoftonline.com/",
"TenantId": "<tenant id>",
"ClientId": "<client id>",
"Scopes": "basket"
}
}
}
2 changes: 0 additions & 2 deletions src/Identity.API/.gitignore

This file was deleted.

189 changes: 0 additions & 189 deletions src/Identity.API/Configuration/Config.cs

This file was deleted.

22 changes: 0 additions & 22 deletions src/Identity.API/Data/ApplicationDbContext.cs

This file was deleted.

Loading