Skip to content

Commit 55bcad2

Browse files
chore: Fix naming (#2856)
1 parent 11f0e69 commit 55bcad2

File tree

1 file changed

+43
-36
lines changed

1 file changed

+43
-36
lines changed

src/VirtoCommerce.Platform.Web/Startup.cs

+43-36
Original file line numberDiff line numberDiff line change
@@ -347,61 +347,67 @@ public void ConfigureServices(IServiceCollection services)
347347
// Note: use the generic overload if you need
348348
// to replace the default OpenIddict entities.
349349
services.AddOpenIddict()
350-
.AddCore(options =>
350+
.AddCore(coreBuilder =>
351351
{
352-
options.UseEntityFrameworkCore()
353-
.UseDbContext<SecurityDbContext>();
354-
}).AddServer(options =>
352+
coreBuilder.UseEntityFrameworkCore(efBuilder =>
353+
{
354+
efBuilder.UseDbContext<SecurityDbContext>();
355+
});
356+
})
357+
.AddServer(serverBuilder =>
355358
{
356359
// Register the ASP.NET Core MVC binder used by OpenIddict.
357360
// Note: if you don't call this method, you won't be able to
358361
// bind OpenIdConnectRequest or OpenIdConnectResponse parameters.
359-
var builder = options.UseAspNetCore().
360-
EnableTokenEndpointPassthrough().
361-
EnableAuthorizationEndpointPassthrough();
362+
serverBuilder.UseAspNetCore(aspNetBuilder =>
363+
{
364+
aspNetBuilder.EnableTokenEndpointPassthrough();
365+
aspNetBuilder.EnableAuthorizationEndpointPassthrough();
366+
367+
// When request caching is enabled, authorization and logout requests
368+
// are stored in the distributed cache by OpenIddict and the user agent
369+
// is redirected to the same page with a single parameter (request_id).
370+
// This allows flowing large OpenID Connect requests even when using
371+
// an external authentication provider like Google, Facebook or Twitter.
372+
aspNetBuilder.EnableAuthorizationRequestCaching();
373+
aspNetBuilder.EnableLogoutRequestCaching();
374+
375+
// During development or when you explicitly run the platform in production mode without https,
376+
// need to disable the HTTPS requirement.
377+
if (WebHostEnvironment.IsDevelopment() || platformOptions.AllowInsecureHttp || !Configuration.IsHttpsServerUrlSet())
378+
{
379+
aspNetBuilder.DisableTransportSecurityRequirement();
380+
}
381+
});
362382

363383
// Enable the authorization, logout, token and userinfo endpoints.
364-
options.SetTokenEndpointUris("connect/token");
365-
options.SetUserinfoEndpointUris("api/security/userinfo");
384+
serverBuilder.SetTokenEndpointUris("connect/token");
385+
serverBuilder.SetUserinfoEndpointUris("api/security/userinfo");
366386

367387
// Note: the Mvc.Client sample only uses the code flow and the password flow, but you
368388
// can enable the other flows if you need to support implicit or client credentials.
369-
options.AllowPasswordFlow()
370-
.AllowRefreshTokenFlow()
371-
.AllowClientCredentialsFlow()
372-
.AllowCustomFlow(PlatformConstants.Security.GrantTypes.Impersonate)
373-
.AllowCustomFlow(PlatformConstants.Security.GrantTypes.ExternalSignIn);
389+
serverBuilder.AllowPasswordFlow();
390+
serverBuilder.AllowRefreshTokenFlow();
391+
serverBuilder.AllowClientCredentialsFlow();
392+
serverBuilder.AllowCustomFlow(PlatformConstants.Security.GrantTypes.Impersonate);
393+
serverBuilder.AllowCustomFlow(PlatformConstants.Security.GrantTypes.ExternalSignIn);
374394

375-
options.SetRefreshTokenLifetime(authorizationOptions?.RefreshTokenLifeTime);
376-
options.SetAccessTokenLifetime(authorizationOptions?.AccessTokenLifeTime);
395+
serverBuilder.SetRefreshTokenLifetime(authorizationOptions?.RefreshTokenLifeTime);
396+
serverBuilder.SetAccessTokenLifetime(authorizationOptions?.AccessTokenLifeTime);
377397

378-
options.AcceptAnonymousClients();
398+
serverBuilder.AcceptAnonymousClients();
379399

380400
// Configure Openiddict to issues new refresh token for each token refresh request.
381-
// Enabled by default, to disable use options.DisableRollingRefreshTokens()
401+
// Enabled by default, to disable use serverBuilder.DisableRollingRefreshTokens()
382402

383403
// Make the "client_id" parameter mandatory when sending a token request.
384404
//options.RequireClientIdentification()
385405

386-
// When request caching is enabled, authorization and logout requests
387-
// are stored in the distributed cache by OpenIddict and the user agent
388-
// is redirected to the same page with a single parameter (request_id).
389-
// This allows flowing large OpenID Connect requests even when using
390-
// an external authentication provider like Google, Facebook or Twitter.
391-
builder.EnableAuthorizationRequestCaching();
392-
builder.EnableLogoutRequestCaching();
393-
394-
options.DisableScopeValidation();
395-
396-
// During development or when you explicitly run the platform in production mode without https, need to disable the HTTPS requirement.
397-
if (WebHostEnvironment.IsDevelopment() || platformOptions.AllowInsecureHttp || !Configuration.IsHttpsServerUrlSet())
398-
{
399-
builder.DisableTransportSecurityRequirement();
400-
}
406+
serverBuilder.DisableScopeValidation();
401407

402408
// Note: to use JWT access tokens instead of the default
403409
// encrypted format, the following lines are required:
404-
options.DisableAccessTokenEncryption();
410+
serverBuilder.DisableAccessTokenEncryption();
405411

406412
X509Certificate2 privateKey;
407413
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
@@ -416,8 +422,9 @@ public void ConfigureServices(IServiceCollection services)
416422
{
417423
privateKey = new X509Certificate2(ServerCertificate.PrivateKeyCertBytes, ServerCertificate.PrivateKeyCertPassword, X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.EphemeralKeySet);
418424
}
419-
options.AddSigningCertificate(privateKey);
420-
options.AddEncryptionCertificate(privateKey);
425+
426+
serverBuilder.AddSigningCertificate(privateKey);
427+
serverBuilder.AddEncryptionCertificate(privateKey);
421428
});
422429

423430
services.Configure<IdentityOptions>(Configuration.GetSection("IdentityOptions"));

0 commit comments

Comments
 (0)