|
10 | 10 | using Microsoft.AspNetCore.DataProtection; |
11 | 11 | using Microsoft.Extensions.Caching.Distributed; |
12 | 12 | using Microsoft.Extensions.Caching.Memory; |
13 | | -using Microsoft.Extensions.DependencyInjection; |
14 | 13 | using Microsoft.Extensions.Logging; |
15 | 14 | using Microsoft.Owin; |
16 | 15 | using Microsoft.Owin.BuilderProperties; |
@@ -39,28 +38,17 @@ public OAuthIntrospectionMiddleware( |
39 | 38 | } |
40 | 39 |
|
41 | 40 | if (options.DataProtectionProvider == null) { |
42 | | - // Create a new DI container and register |
43 | | - // the data protection services. |
44 | | - var services = new ServiceCollection(); |
| 41 | + // Try to use the application name provided by |
| 42 | + // the OWIN host as the application discriminator. |
| 43 | + var discriminator = new AppProperties(app.Properties).AppName; |
45 | 44 |
|
46 | | - services.AddDataProtection(configuration => { |
47 | | - // Try to use the application name provided by |
48 | | - // the OWIN host as the application discriminator. |
49 | | - var discriminator = new AppProperties(app.Properties).AppName; |
| 45 | + // When an application discriminator cannot be resolved from |
| 46 | + // the OWIN host properties, generate a temporary identifier. |
| 47 | + if (string.IsNullOrEmpty(discriminator)) { |
| 48 | + discriminator = Guid.NewGuid().ToString(); |
| 49 | + } |
50 | 50 |
|
51 | | - // When an application discriminator cannot be resolved from |
52 | | - // the OWIN host properties, generate a temporary identifier. |
53 | | - if (string.IsNullOrEmpty(discriminator)) { |
54 | | - discriminator = Guid.NewGuid().ToString(); |
55 | | - } |
56 | | - |
57 | | - configuration.ApplicationDiscriminator = discriminator; |
58 | | - }); |
59 | | - |
60 | | - var container = services.BuildServiceProvider(); |
61 | | - |
62 | | - // Resolve a data protection provider from the services container. |
63 | | - options.DataProtectionProvider = container.GetRequiredService<IDataProtectionProvider>(); |
| 51 | + options.DataProtectionProvider = DataProtectionProvider.Create(discriminator); |
64 | 52 | } |
65 | 53 |
|
66 | 54 | if (options.AccessTokenFormat == null) { |
|
0 commit comments