@@ -28,7 +28,8 @@ public static class MultiTenantBuilderExtensions
28
28
/// <summary>
29
29
/// Configures authentication options to enable per-tenant behavior.
30
30
/// </summary>
31
- /// <returns>The same MultiTenantBuilder passed into the method.</returns>
31
+ /// <typeparam name="TTenantInfo">The ITenantInfo implementation type.</typeparam>
32
+ /// <returns>The <see cref="MultiTenantBuilder<TTenantInfo>"/> so that additional calls can be chained.</returns>
32
33
public static MultiTenantBuilder < TTenantInfo > WithPerTenantAuthentication < TTenantInfo > (
33
34
this MultiTenantBuilder < TTenantInfo > builder )
34
35
where TTenantInfo : class , ITenantInfo , new ( )
@@ -39,9 +40,10 @@ public static MultiTenantBuilder<TTenantInfo> WithPerTenantAuthentication<TTenan
39
40
/// <summary>
40
41
/// Configures per-tenant authentication behavior.
41
42
/// </summary>
43
+ /// <typeparam name="TTenantInfo">The ITenantInfo implementation type.</typeparam>
42
44
/// <param name="builder">MultiTenantBuilder instance.</param>
43
45
/// <param name="config">Authentication options config.</param>
44
- /// <returns>The same MultiTenantBuilder passed into the method .</returns>
46
+ /// <returns>The <see cref=" MultiTenantBuilder<TTenantInfo>"/> so that additional calls can be chained .</returns>
45
47
// ReSharper disable once MemberCanBePrivate.Global
46
48
public static MultiTenantBuilder < TTenantInfo > WithPerTenantAuthentication < TTenantInfo > (
47
49
this MultiTenantBuilder < TTenantInfo > builder , Action < MultiTenantAuthenticationOptions > config )
@@ -57,7 +59,8 @@ public static MultiTenantBuilder<TTenantInfo> WithPerTenantAuthentication<TTenan
57
59
/// <summary>
58
60
/// Configures conventional functionality for per-tenant authentication.
59
61
/// </summary>
60
- /// <returns>The same MultiTenantBuilder passed into the method.</returns>
62
+ /// <typeparam name="TTenantInfo">The ITenantInfo implementation type.</typeparam>
63
+ /// <returns>The <see cref="MultiTenantBuilder<TTenantInfo>"/> so that additional calls can be chained.</returns>
61
64
public static MultiTenantBuilder < TTenantInfo > WithPerTenantAuthenticationConventions < TTenantInfo > (
62
65
this MultiTenantBuilder < TTenantInfo > builder )
63
66
where TTenantInfo : class , ITenantInfo , new ( )
@@ -139,9 +142,10 @@ public static MultiTenantBuilder<TTenantInfo> WithPerTenantAuthenticationConvent
139
142
/// <summary>
140
143
/// Configures core functionality for per-tenant authentication.
141
144
/// </summary>
145
+ /// <typeparam name="TTenantInfo">The ITenantInfo implementation type.</typeparam>
142
146
/// <param name="builder">MultiTenantBuilder instance.</param>
143
147
/// <param name="config">Authentication options config</param>
144
- /// <returns>The same MultiTenantBuilder passed into the method .</returns>
148
+ /// <returns>The <see cref=" MultiTenantBuilder<TTenantInfo>"/> so that additional calls can be chained .</returns>
145
149
public static MultiTenantBuilder < TTenantInfo > WithPerTenantAuthenticationCore < TTenantInfo > (
146
150
this MultiTenantBuilder < TTenantInfo > builder , Action < MultiTenantAuthenticationOptions > ? config =
147
151
null )
@@ -167,8 +171,9 @@ public static MultiTenantBuilder<TTenantInfo> WithPerTenantAuthenticationCore<TT
167
171
/// <summary>
168
172
/// Adds and configures a SessionStrategy to the application.
169
173
/// </summary>
174
+ /// <typeparam name="TTenantInfo">The ITenantInfo implementation type.</typeparam>
170
175
/// <param name="builder">MultiTenantBuilder instance.</param>
171
- /// <returns>The same MultiTenantBuilder passed into the method .</returns>
176
+ /// <returns>The <see cref=" MultiTenantBuilder<TTenantInfo>"/> so that additional calls can be chained .</returns>
172
177
public static MultiTenantBuilder < TTenantInfo > WithSessionStrategy < TTenantInfo > (
173
178
this MultiTenantBuilder < TTenantInfo > builder )
174
179
where TTenantInfo : class , ITenantInfo , new ( )
@@ -177,9 +182,10 @@ public static MultiTenantBuilder<TTenantInfo> WithSessionStrategy<TTenantInfo>(
177
182
/// <summary>
178
183
/// Adds and configures a SessionStrategy to the application.
179
184
/// </summary>
185
+ /// <typeparam name="TTenantInfo">The ITenantInfo implementation type.</typeparam>
180
186
/// <param name="builder">MultiTenantBuilder instance.</param>
181
187
/// <param name="tenantKey">The session key to use.</param>
182
- /// <returns>The same MultiTenantBuilder passed into the method .</returns>
188
+ /// <returns>The <see cref=" MultiTenantBuilder<TTenantInfo>"/> so that additional calls can be chained .</returns>
183
189
public static MultiTenantBuilder < TTenantInfo > WithSessionStrategy < TTenantInfo > (
184
190
this MultiTenantBuilder < TTenantInfo > builder , string tenantKey )
185
191
where TTenantInfo : class , ITenantInfo , new ( )
@@ -188,7 +194,8 @@ public static MultiTenantBuilder<TTenantInfo> WithSessionStrategy<TTenantInfo>(
188
194
/// <summary>
189
195
/// Adds and configures a RemoteAuthenticationCallbackStrategy to the application.
190
196
/// </summary>
191
- /// <returns>The same MultiTenantBuilder passed into the method.</returns>
197
+ /// <typeparam name="TTenantInfo">The ITenantInfo implementation type.</typeparam>
198
+ /// <returns>The <see cref="MultiTenantBuilder<TTenantInfo>"/> so that additional calls can be chained.</returns>
192
199
public static MultiTenantBuilder < TTenantInfo > WithRemoteAuthenticationCallbackStrategy < TTenantInfo > (
193
200
this MultiTenantBuilder < TTenantInfo > builder )
194
201
where TTenantInfo : class , ITenantInfo , new ( )
@@ -199,6 +206,7 @@ public static MultiTenantBuilder<TTenantInfo> WithRemoteAuthenticationCallbackSt
199
206
/// <summary>
200
207
/// Adds and configures a BasePathStrategy to the application.
201
208
/// </summary>
209
+ /// <typeparam name="TTenantInfo">The ITenantInfo implementation type.</typeparam>
202
210
/// <returns>The same MultiTenantBuilder passed into the method.></returns>
203
211
public static MultiTenantBuilder < TTenantInfo > WithBasePathStrategy < TTenantInfo > (
204
212
this MultiTenantBuilder < TTenantInfo > builder )
@@ -208,6 +216,7 @@ public static MultiTenantBuilder<TTenantInfo> WithBasePathStrategy<TTenantInfo>(
208
216
/// <summary>
209
217
/// Adds and configures a BasePathStrategy to the application.
210
218
/// </summary>
219
+ /// <typeparam name="TTenantInfo">The ITenantInfo implementation type.</typeparam>
211
220
/// <returns>The same MultiTenantBuilder passed into the method.></returns>
212
221
public static MultiTenantBuilder < TTenantInfo > WithBasePathStrategy < TTenantInfo > (
213
222
this MultiTenantBuilder < TTenantInfo > builder , Action < BasePathStrategyOptions > configureOptions )
@@ -241,7 +250,8 @@ resolutionCompletedContext.Context is HttpContext httpContext &&
241
250
/// <summary>
242
251
/// Adds and configures a RouteStrategy with a route parameter Constants.TenantToken to the application.
243
252
/// </summary>
244
- /// <returns>The same MultiTenantBuilder passed into the method.</returns>
253
+ /// <typeparam name="TTenantInfo">The ITenantInfo implementation type.</typeparam>
254
+ /// <returns>The <see cref="MultiTenantBuilder<TTenantInfo>"/> so that additional calls can be chained.</returns>
245
255
public static MultiTenantBuilder < TTenantInfo > WithRouteStrategy < TTenantInfo > (
246
256
this MultiTenantBuilder < TTenantInfo > builder )
247
257
where TTenantInfo : class , ITenantInfo , new ( )
@@ -250,9 +260,10 @@ public static MultiTenantBuilder<TTenantInfo> WithRouteStrategy<TTenantInfo>(
250
260
/// <summary>
251
261
/// Adds and configures a RouteStrategy to the application.
252
262
/// </summary>
263
+ /// <typeparam name="TTenantInfo">The ITenantInfo implementation type.</typeparam>
253
264
/// <param name="builder">MultiTenantBuilder instance.</param>
254
265
/// <param name="tenantParam">The name of the route parameter used to determine the tenant identifier.</param>
255
- /// <returns>The same MultiTenantBuilder passed into the method .</returns>
266
+ /// <returns>The <see cref=" MultiTenantBuilder<TTenantInfo>"/> so that additional calls can be chained .</returns>
256
267
public static MultiTenantBuilder < TTenantInfo > WithRouteStrategy < TTenantInfo > (
257
268
this MultiTenantBuilder < TTenantInfo > builder , string tenantParam )
258
269
where TTenantInfo : class , ITenantInfo , new ( )
@@ -264,12 +275,12 @@ public static MultiTenantBuilder<TTenantInfo> WithRouteStrategy<TTenantInfo>(
264
275
265
276
return builder . WithStrategy < RouteStrategy > ( ServiceLifetime . Singleton , tenantParam ) ;
266
277
}
267
- // #endif
268
278
269
279
/// <summary>
270
280
/// Adds and configures a HostStrategy with template "__tenant__.*" to the application.
271
281
/// </summary>
272
- /// <returns>The same MultiTenantBuilder passed into the method.</returns>
282
+ /// <typeparam name="TTenantInfo">The ITenantInfo implementation type.</typeparam>
283
+ /// <returns>The <see cref="MultiTenantBuilder<TTenantInfo>"/> so that additional calls can be chained.</returns>
273
284
public static MultiTenantBuilder < TTenantInfo > WithHostStrategy < TTenantInfo > (
274
285
this MultiTenantBuilder < TTenantInfo > builder )
275
286
where TTenantInfo : class , ITenantInfo , new ( )
@@ -278,9 +289,10 @@ public static MultiTenantBuilder<TTenantInfo> WithHostStrategy<TTenantInfo>(
278
289
/// <summary>
279
290
/// Adds and configures a HostStrategy to the application.
280
291
/// </summary>
292
+ /// <typeparam name="TTenantInfo">The ITenantInfo implementation type.</typeparam>
281
293
/// <param name="builder">MultiTenantBuilder instance.</param>
282
294
/// <param name="template">The template for determining the tenant identifier in the host.</param>
283
- /// <returns>The same MultiTenantBuilder passed into the method .</returns>
295
+ /// <returns>The <see cref=" MultiTenantBuilder<TTenantInfo>"/> so that additional calls can be chained .</returns>
284
296
public static MultiTenantBuilder < TTenantInfo > WithHostStrategy < TTenantInfo > (
285
297
this MultiTenantBuilder < TTenantInfo > builder , string template )
286
298
where TTenantInfo : class , ITenantInfo , new ( )
@@ -296,7 +308,8 @@ public static MultiTenantBuilder<TTenantInfo> WithHostStrategy<TTenantInfo>(
296
308
/// <summary>
297
309
/// Adds and configures a ClaimStrategy for claim name "__tenant__" to the application. Uses the default authentication handler scheme.
298
310
/// </summary>
299
- /// <returns>The same MultiTenantBuilder passed into the method.</returns>
311
+ /// <typeparam name="TTenantInfo">The ITenantInfo implementation type.</typeparam>
312
+ /// <returns>The <see cref="MultiTenantBuilder<TTenantInfo>"/> so that additional calls can be chained.</returns>
300
313
public static MultiTenantBuilder < TTenantInfo > WithClaimStrategy < TTenantInfo > (
301
314
this MultiTenantBuilder < TTenantInfo > builder ) where TTenantInfo : class , ITenantInfo , new ( )
302
315
{
@@ -306,9 +319,10 @@ public static MultiTenantBuilder<TTenantInfo> WithClaimStrategy<TTenantInfo>(
306
319
/// <summary>
307
320
/// Adds and configures a ClaimStrategy to the application. Uses the default authentication handler scheme.
308
321
/// </summary>
322
+ /// <typeparam name="TTenantInfo">The ITenantInfo implementation type.</typeparam>
309
323
/// <param name="builder">MultiTenantBuilder instance.</param>
310
324
/// <param name="tenantKey">Claim name for determining the tenant identifier.</param>
311
- /// <returns>The same MultiTenantBuilder passed into the method .</returns>
325
+ /// <returns>The <see cref=" MultiTenantBuilder<TTenantInfo>"/> so that additional calls can be chained .</returns>
312
326
// ReSharper disable once MemberCanBePrivate.Global
313
327
public static MultiTenantBuilder < TTenantInfo > WithClaimStrategy < TTenantInfo > (
314
328
this MultiTenantBuilder < TTenantInfo > builder , string tenantKey )
@@ -321,17 +335,32 @@ public static MultiTenantBuilder<TTenantInfo> WithClaimStrategy<TTenantInfo>(
321
335
/// <summary>
322
336
/// Adds and configures a ClaimStrategy to the application.
323
337
/// </summary>
338
+ /// <typeparam name="TTenantInfo">The ITenantInfo implementation type.</typeparam>
324
339
/// <param name="builder">MultiTenantBuilder instance.</param>
325
340
/// <param name="tenantKey">Claim name for determining the tenant identifier.</param>
326
341
/// <param name="authenticationScheme">The authentication scheme to check for claims.</param>
327
- /// <returns>The same MultiTenantBuilder passed into the method .</returns>
342
+ /// <returns>The <see cref=" MultiTenantBuilder<TTenantInfo>"/> so that additional calls can be chained .</returns>
328
343
public static MultiTenantBuilder < TTenantInfo > WithClaimStrategy < TTenantInfo > (
329
344
this MultiTenantBuilder < TTenantInfo > builder , string tenantKey , string authenticationScheme )
330
345
where TTenantInfo : class , ITenantInfo , new ( )
331
346
{
332
347
BypassSessionPrincipalValidation ( builder ) ;
333
348
return builder . WithStrategy < ClaimStrategy > ( ServiceLifetime . Singleton , tenantKey , authenticationScheme ) ;
334
349
}
350
+
351
+ /// <summary>
352
+ /// Adds and configures an HttpContext delegate strategy to the application.
353
+ /// </summary>
354
+ /// <typeparam name="TTenantInfo">The ITenantInfo implementation type.</typeparam>
355
+ /// <param name="builder">MultiTenantBuilder instance.</param>
356
+ /// <param name="doStrategy">The delegate to execute to determine the tenant identifier.</param>
357
+ /// <returns>The <see cref="MultiTenantBuilder<TTenantInfo>"/> so that additional calls can be chained.</returns>
358
+ public static MultiTenantBuilder < TTenantInfo > WithHttpContextStrategy < TTenantInfo > (
359
+ this MultiTenantBuilder < TTenantInfo > builder , Func < HttpContext , Task < string ? > > doStrategy )
360
+ where TTenantInfo : class , ITenantInfo , new ( )
361
+ {
362
+ return builder . WithDelegateStrategy < HttpContext , TTenantInfo > ( doStrategy ) ;
363
+ }
335
364
336
365
private static void BypassSessionPrincipalValidation < TTenantInfo > (
337
366
MultiTenantBuilder < TTenantInfo > builder )
@@ -355,7 +384,7 @@ private static void BypassSessionPrincipalValidation<TTenantInfo>(
355
384
/// <summary>
356
385
/// Adds and configures a HeaderStrategy with using HTTP header key "__tenant__" to the application.
357
386
/// </summary>
358
- /// <returns>The same MultiTenantBuilder passed into the method .</returns>
387
+ /// <returns>The <see cref=" MultiTenantBuilder<TTenantInfo>"/> so that additional calls can be chained .</returns>
359
388
public static MultiTenantBuilder < TTenantInfo > WithHeaderStrategy < TTenantInfo > (
360
389
this MultiTenantBuilder < TTenantInfo > builder ) where TTenantInfo : class , ITenantInfo , new ( )
361
390
{
@@ -367,7 +396,7 @@ public static MultiTenantBuilder<TTenantInfo> WithHeaderStrategy<TTenantInfo>(
367
396
/// </summary>
368
397
/// <param name="builder">MultiTenantBuilder instance.</param>
369
398
/// <param name="tenantKey">The HTTP header key for determining the tenant identifier in the request.</param>
370
- /// <returns>The same MultiTenantBuilder passed into the method .</returns>
399
+ /// <returns>The <see cref=" MultiTenantBuilder<TTenantInfo>"/> so that additional calls can be chained .</returns>
371
400
public static MultiTenantBuilder < TTenantInfo > WithHeaderStrategy < TTenantInfo > (
372
401
this MultiTenantBuilder < TTenantInfo > builder , string tenantKey )
373
402
where TTenantInfo : class , ITenantInfo , new ( )
0 commit comments