Skip to content

Commit b225eb9

Browse files
committed
(#107) SignalR Authentication and Authorization
1 parent 03f21d3 commit b225eb9

File tree

33 files changed

+567
-135
lines changed

33 files changed

+567
-135
lines changed

src/Microservices/.helm/microservices/charts/webapi/templates/webapi.configmap.yml

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,41 @@ data:
1111
ReRoutes__1__DownstreamHostAndPorts__0__Host: "{{ .Release.Name}}-product-api"
1212
ReRoutes__1__DownstreamHostAndPorts__0__Port: "80"
1313
ReRoutes__2__DownstreamScheme: "http"
14-
ReRoutes__2__DownstreamHostAndPorts__0__Host: "{{ .Release.Name}}-storage-api"
14+
ReRoutes__2__DownstreamHostAndPorts__0__Host: "{{ .Release.Name}}-product-api"
1515
ReRoutes__2__DownstreamHostAndPorts__0__Port: "80"
1616
ReRoutes__3__DownstreamScheme: "http"
1717
ReRoutes__3__DownstreamHostAndPorts__0__Host: "{{ .Release.Name}}-storage-api"
1818
ReRoutes__3__DownstreamHostAndPorts__0__Port: "80"
1919
ReRoutes__4__DownstreamScheme: "http"
20-
ReRoutes__4__DownstreamHostAndPorts__0__Host: "{{ .Release.Name}}-auditlog-api"
20+
ReRoutes__4__DownstreamHostAndPorts__0__Host: "{{ .Release.Name}}-storage-api"
2121
ReRoutes__4__DownstreamHostAndPorts__0__Port: "80"
2222
ReRoutes__5__DownstreamScheme: "http"
23-
ReRoutes__5__DownstreamHostAndPorts__0__Host: "{{ .Release.Name}}-auditlog-api"
23+
ReRoutes__5__DownstreamHostAndPorts__0__Host: "{{ .Release.Name}}-storage-api"
2424
ReRoutes__5__DownstreamHostAndPorts__0__Port: "80"
2525
ReRoutes__6__DownstreamScheme: "http"
26-
ReRoutes__6__DownstreamHostAndPorts__0__Host: "{{ .Release.Name}}-identity-api"
26+
ReRoutes__6__DownstreamHostAndPorts__0__Host: "{{ .Release.Name}}-auditlog-api"
2727
ReRoutes__6__DownstreamHostAndPorts__0__Port: "80"
2828
ReRoutes__7__DownstreamScheme: "http"
29-
ReRoutes__7__DownstreamHostAndPorts__0__Host: "{{ .Release.Name}}-identity-api"
29+
ReRoutes__7__DownstreamHostAndPorts__0__Host: "{{ .Release.Name}}-auditlog-api"
3030
ReRoutes__7__DownstreamHostAndPorts__0__Port: "80"
3131
ReRoutes__8__DownstreamScheme: "http"
32-
ReRoutes__8__DownstreamHostAndPorts__0__Host: "{{ .Release.Name}}-configuration-api"
32+
ReRoutes__8__DownstreamHostAndPorts__0__Host: "{{ .Release.Name}}-auditlog-api"
3333
ReRoutes__8__DownstreamHostAndPorts__0__Port: "80"
3434
ReRoutes__9__DownstreamScheme: "http"
35-
ReRoutes__9__DownstreamHostAndPorts__0__Host: "{{ .Release.Name}}-configuration-api"
35+
ReRoutes__9__DownstreamHostAndPorts__0__Host: "{{ .Release.Name}}-identity-api"
3636
ReRoutes__9__DownstreamHostAndPorts__0__Port: "80"
37+
ReRoutes__10__DownstreamScheme: "http"
38+
ReRoutes__10__DownstreamHostAndPorts__0__Host: "{{ .Release.Name}}-identity-api"
39+
ReRoutes__10__DownstreamHostAndPorts__0__Port: "80"
40+
ReRoutes__11__DownstreamScheme: "http"
41+
ReRoutes__11__DownstreamHostAndPorts__0__Host: "{{ .Release.Name}}-identity-api"
42+
ReRoutes__11__DownstreamHostAndPorts__0__Port: "80"
43+
ReRoutes__12__DownstreamScheme: "http"
44+
ReRoutes__12__DownstreamHostAndPorts__0__Host: "{{ .Release.Name}}-configuration-api"
45+
ReRoutes__12__DownstreamHostAndPorts__0__Port: "80"
46+
ReRoutes__13__DownstreamScheme: "http"
47+
ReRoutes__13__DownstreamHostAndPorts__0__Host: "{{ .Release.Name}}-configuration-api"
48+
ReRoutes__13__DownstreamHostAndPorts__0__Port: "80"
49+
ReRoutes__14__DownstreamScheme: "http"
50+
ReRoutes__14__DownstreamHostAndPorts__0__Host: "{{ .Release.Name}}-configuration-api"
51+
ReRoutes__14__DownstreamHostAndPorts__0__Port: "80"

src/Microservices/.k8s/webapi.configmap.yml

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,41 @@ data:
1111
ReRoutes__1__DownstreamHostAndPorts__0__Host: "product-api"
1212
ReRoutes__1__DownstreamHostAndPorts__0__Port: "80"
1313
ReRoutes__2__DownstreamScheme: "http"
14-
ReRoutes__2__DownstreamHostAndPorts__0__Host: "storage-api"
14+
ReRoutes__2__DownstreamHostAndPorts__0__Host: "product-api"
1515
ReRoutes__2__DownstreamHostAndPorts__0__Port: "80"
1616
ReRoutes__3__DownstreamScheme: "http"
1717
ReRoutes__3__DownstreamHostAndPorts__0__Host: "storage-api"
1818
ReRoutes__3__DownstreamHostAndPorts__0__Port: "80"
1919
ReRoutes__4__DownstreamScheme: "http"
20-
ReRoutes__4__DownstreamHostAndPorts__0__Host: "auditlog-api"
20+
ReRoutes__4__DownstreamHostAndPorts__0__Host: "storage-api"
2121
ReRoutes__4__DownstreamHostAndPorts__0__Port: "80"
2222
ReRoutes__5__DownstreamScheme: "http"
23-
ReRoutes__5__DownstreamHostAndPorts__0__Host: "auditlog-api"
23+
ReRoutes__5__DownstreamHostAndPorts__0__Host: "storage-api"
2424
ReRoutes__5__DownstreamHostAndPorts__0__Port: "80"
2525
ReRoutes__6__DownstreamScheme: "http"
26-
ReRoutes__6__DownstreamHostAndPorts__0__Host: "identity-api"
26+
ReRoutes__6__DownstreamHostAndPorts__0__Host: "auditlog-api"
2727
ReRoutes__6__DownstreamHostAndPorts__0__Port: "80"
2828
ReRoutes__7__DownstreamScheme: "http"
29-
ReRoutes__7__DownstreamHostAndPorts__0__Host: "identity-api"
29+
ReRoutes__7__DownstreamHostAndPorts__0__Host: "auditlog-api"
3030
ReRoutes__7__DownstreamHostAndPorts__0__Port: "80"
3131
ReRoutes__8__DownstreamScheme: "http"
32-
ReRoutes__8__DownstreamHostAndPorts__0__Host: "configuration-api"
32+
ReRoutes__8__DownstreamHostAndPorts__0__Host: "auditlog-api"
3333
ReRoutes__8__DownstreamHostAndPorts__0__Port: "80"
3434
ReRoutes__9__DownstreamScheme: "http"
35-
ReRoutes__9__DownstreamHostAndPorts__0__Host: "configuration-api"
35+
ReRoutes__9__DownstreamHostAndPorts__0__Host: "identity-api"
3636
ReRoutes__9__DownstreamHostAndPorts__0__Port: "80"
37+
ReRoutes__10__DownstreamScheme: "http"
38+
ReRoutes__10__DownstreamHostAndPorts__0__Host: "identity-api"
39+
ReRoutes__10__DownstreamHostAndPorts__0__Port: "80"
40+
ReRoutes__11__DownstreamScheme: "http"
41+
ReRoutes__11__DownstreamHostAndPorts__0__Host: "identity-api"
42+
ReRoutes__11__DownstreamHostAndPorts__0__Port: "80"
43+
ReRoutes__12__DownstreamScheme: "http"
44+
ReRoutes__12__DownstreamHostAndPorts__0__Host: "configuration-api"
45+
ReRoutes__12__DownstreamHostAndPorts__0__Port: "80"
46+
ReRoutes__13__DownstreamScheme: "http"
47+
ReRoutes__13__DownstreamHostAndPorts__0__Host: "configuration-api"
48+
ReRoutes__13__DownstreamHostAndPorts__0__Port: "80"
49+
ReRoutes__14__DownstreamScheme: "http"
50+
ReRoutes__14__DownstreamHostAndPorts__0__Host: "configuration-api"
51+
ReRoutes__14__DownstreamHostAndPorts__0__Port: "80"

src/Microservices/Gateways.WebAPI/ClassifiedAds.Gateways.WebAPI/appsettings.json

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,17 @@
1919
],
2020
"UpstreamPathTemplate": "/api/products"
2121
},
22+
{
23+
"DownstreamPathTemplate": "/api/products/",
24+
"DownstreamScheme": "https",
25+
"DownstreamHostAndPorts": [
26+
{
27+
"Host": "localhost",
28+
"Port": 44328
29+
}
30+
],
31+
"UpstreamPathTemplate": "/api/products/"
32+
},
2233
{
2334
"DownstreamPathTemplate": "/api/products/{everything}",
2435
"DownstreamScheme": "https",
@@ -41,6 +52,17 @@
4152
],
4253
"UpstreamPathTemplate": "/api/files"
4354
},
55+
{
56+
"DownstreamPathTemplate": "/api/files/",
57+
"DownstreamScheme": "https",
58+
"DownstreamHostAndPorts": [
59+
{
60+
"Host": "localhost",
61+
"Port": 44345
62+
}
63+
],
64+
"UpstreamPathTemplate": "/api/files/"
65+
},
4466
{
4567
"DownstreamPathTemplate": "/api/files/{everything}",
4668
"DownstreamScheme": "https",
@@ -63,6 +85,17 @@
6385
],
6486
"UpstreamPathTemplate": "/api/auditLogEntries"
6587
},
88+
{
89+
"DownstreamPathTemplate": "/api/auditLogEntries/",
90+
"DownstreamScheme": "https",
91+
"DownstreamHostAndPorts": [
92+
{
93+
"Host": "localhost",
94+
"Port": 44378
95+
}
96+
],
97+
"UpstreamPathTemplate": "/api/auditLogEntries/"
98+
},
6699
{
67100
"DownstreamPathTemplate": "/api/auditLogEntries/{everything}",
68101
"DownstreamScheme": "https",
@@ -85,6 +118,17 @@
85118
],
86119
"UpstreamPathTemplate": "/api/users"
87120
},
121+
{
122+
"DownstreamPathTemplate": "/api/users/",
123+
"DownstreamScheme": "https",
124+
"DownstreamHostAndPorts": [
125+
{
126+
"Host": "localhost",
127+
"Port": 44306
128+
}
129+
],
130+
"UpstreamPathTemplate": "/api/users/"
131+
},
88132
{
89133
"DownstreamPathTemplate": "/api/users/{everything}",
90134
"DownstreamScheme": "https",
@@ -107,6 +151,17 @@
107151
],
108152
"UpstreamPathTemplate": "/api/ConfigurationEntries"
109153
},
154+
{
155+
"DownstreamPathTemplate": "/api/ConfigurationEntries/",
156+
"DownstreamScheme": "https",
157+
"DownstreamHostAndPorts": [
158+
{
159+
"Host": "localhost",
160+
"Port": 44301
161+
}
162+
],
163+
"UpstreamPathTemplate": "/api/ConfigurationEntries/"
164+
},
110165
{
111166
"DownstreamPathTemplate": "/api/ConfigurationEntries/{everything}",
112167
"DownstreamScheme": "https",

src/Microservices/docker-compose.yml

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -226,26 +226,41 @@ services:
226226
ReRoutes__1__DownstreamHostAndPorts__0__Host: "product-api"
227227
ReRoutes__1__DownstreamHostAndPorts__0__Port: "80"
228228
ReRoutes__2__DownstreamScheme: "http"
229-
ReRoutes__2__DownstreamHostAndPorts__0__Host: "storage-api"
229+
ReRoutes__2__DownstreamHostAndPorts__0__Host: "product-api"
230230
ReRoutes__2__DownstreamHostAndPorts__0__Port: "80"
231231
ReRoutes__3__DownstreamScheme: "http"
232232
ReRoutes__3__DownstreamHostAndPorts__0__Host: "storage-api"
233233
ReRoutes__3__DownstreamHostAndPorts__0__Port: "80"
234234
ReRoutes__4__DownstreamScheme: "http"
235-
ReRoutes__4__DownstreamHostAndPorts__0__Host: "auditlog-api"
235+
ReRoutes__4__DownstreamHostAndPorts__0__Host: "storage-api"
236236
ReRoutes__4__DownstreamHostAndPorts__0__Port: "80"
237237
ReRoutes__5__DownstreamScheme: "http"
238-
ReRoutes__5__DownstreamHostAndPorts__0__Host: "auditlog-api"
238+
ReRoutes__5__DownstreamHostAndPorts__0__Host: "storage-api"
239239
ReRoutes__5__DownstreamHostAndPorts__0__Port: "80"
240240
ReRoutes__6__DownstreamScheme: "http"
241-
ReRoutes__6__DownstreamHostAndPorts__0__Host: "identity-api"
241+
ReRoutes__6__DownstreamHostAndPorts__0__Host: "auditlog-api"
242242
ReRoutes__6__DownstreamHostAndPorts__0__Port: "80"
243243
ReRoutes__7__DownstreamScheme: "http"
244-
ReRoutes__7__DownstreamHostAndPorts__0__Host: "identity-api"
244+
ReRoutes__7__DownstreamHostAndPorts__0__Host: "auditlog-api"
245245
ReRoutes__7__DownstreamHostAndPorts__0__Port: "80"
246246
ReRoutes__8__DownstreamScheme: "http"
247-
ReRoutes__8__DownstreamHostAndPorts__0__Host: "configuration-api"
247+
ReRoutes__8__DownstreamHostAndPorts__0__Host: "auditlog-api"
248248
ReRoutes__8__DownstreamHostAndPorts__0__Port: "80"
249249
ReRoutes__9__DownstreamScheme: "http"
250-
ReRoutes__9__DownstreamHostAndPorts__0__Host: "configuration-api"
250+
ReRoutes__9__DownstreamHostAndPorts__0__Host: "identity-api"
251251
ReRoutes__9__DownstreamHostAndPorts__0__Port: "80"
252+
ReRoutes__10__DownstreamScheme: "http"
253+
ReRoutes__10__DownstreamHostAndPorts__0__Host: "identity-api"
254+
ReRoutes__10__DownstreamHostAndPorts__0__Port: "80"
255+
ReRoutes__11__DownstreamScheme: "http"
256+
ReRoutes__11__DownstreamHostAndPorts__0__Host: "identity-api"
257+
ReRoutes__11__DownstreamHostAndPorts__0__Port: "80"
258+
ReRoutes__12__DownstreamScheme: "http"
259+
ReRoutes__12__DownstreamHostAndPorts__0__Host: "configuration-api"
260+
ReRoutes__12__DownstreamHostAndPorts__0__Port: "80"
261+
ReRoutes__13__DownstreamScheme: "http"
262+
ReRoutes__13__DownstreamHostAndPorts__0__Host: "configuration-api"
263+
ReRoutes__13__DownstreamHostAndPorts__0__Port: "80"
264+
ReRoutes__14__DownstreamScheme: "http"
265+
ReRoutes__14__DownstreamHostAndPorts__0__Host: "configuration-api"
266+
ReRoutes__14__DownstreamHostAndPorts__0__Port: "80"

src/ModularMonolith/ClassifiedAds.BackgroundServer/Startup.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using ClassifiedAds.Domain.Infrastructure.MessageBrokers;
44
using ClassifiedAds.Infrastructure.Notification.Web;
55
using ClassifiedAds.Modules.Notification.Contracts.DTOs;
6-
using ClassifiedAds.Modules.Notification.Hubs;
76
using ClassifiedAds.Modules.Notification.Services;
87
using ClassifiedAds.Modules.Storage.DTOs;
98
using Microsoft.AspNetCore.Builder;
@@ -145,4 +144,10 @@ private void RunMessageBrokerReceivers(IServiceProvider serviceProvider)
145144
});
146145
}
147146
}
147+
148+
internal class SendTaskStatusMessage
149+
{
150+
public string Step { get; internal set; }
151+
public string Message { get; internal set; }
152+
}
148153
}

src/ModularMonolith/ClassifiedAds.Modules.Notification/Hubs/HealthCheckHub.cs

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using Microsoft.AspNetCore.Authorization;
2+
using Microsoft.AspNetCore.SignalR;
3+
4+
namespace ClassifiedAds.Modules.Notification.Hubs
5+
{
6+
[Authorize]
7+
public class NotificationHub : Hub
8+
{
9+
}
10+
}

src/ModularMonolith/ClassifiedAds.Modules.Notification/Hubs/SimulatedLongRunningTaskHub.cs

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/ModularMonolith/ClassifiedAds.WebAPI/Startup.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using ClassifiedAds.Modules.Identity.Contracts.Services;
1010
using ClassifiedAds.Modules.Identity.Repositories;
1111
using ClassifiedAds.Modules.Identity.Services;
12+
using ClassifiedAds.Modules.Notification.Hubs;
1213
using ClassifiedAds.WebAPI.ConfigurationOptions;
1314
using Microsoft.AspNetCore.Authentication.JwtBearer;
1415
using Microsoft.AspNetCore.Builder;
@@ -55,12 +56,15 @@ public void ConfigureServices(IServiceCollection services)
5556
.AddStorageModule()
5657
.AddMonitoringServices(AppSettings.Monitoring);
5758

59+
services.AddSignalR();
60+
5861
services.AddCors(options =>
5962
{
6063
options.AddPolicy("AllowedOrigins", builder => builder
6164
.WithOrigins(AppSettings.CORS.AllowedOrigins)
6265
.AllowAnyMethod()
63-
.AllowAnyHeader());
66+
.AllowAnyHeader()
67+
.AllowCredentials());
6468

6569
options.AddPolicy("AllowAnyOrigin", builder => builder
6670
.AllowAnyOrigin()
@@ -281,6 +285,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
281285
app.UseEndpoints(endpoints =>
282286
{
283287
endpoints.MapControllers();
288+
endpoints.MapHub<NotificationHub>("/hubs/notification");
284289
});
285290
}
286291
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using Microsoft.AspNetCore.Authorization;
2+
using Microsoft.AspNetCore.SignalR;
3+
4+
namespace ClassifiedAds.WebAPI.Hubs
5+
{
6+
[Authorize]
7+
public class NotificationHub : Hub
8+
{
9+
}
10+
}

0 commit comments

Comments
 (0)