mirror of https://github.com/Squidex/squidex.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.7 KiB
43 lines
1.7 KiB
// ==========================================================================
|
|
// Squidex Headless CMS
|
|
// ==========================================================================
|
|
// Copyright (c) Squidex UG (haftungsbeschränkt)
|
|
// All rights reserved. Licensed under the MIT license.
|
|
// ==========================================================================
|
|
|
|
using Microsoft.AspNetCore.Authentication;
|
|
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
namespace Squidex.Config.Authentication
|
|
{
|
|
public static class OidcServices
|
|
{
|
|
public static AuthenticationBuilder AddSquidexExternalOdic(this AuthenticationBuilder authBuilder, MyIdentityOptions identityOptions)
|
|
{
|
|
if (identityOptions.IsOidcConfigured())
|
|
{
|
|
var displayName = !string.IsNullOrWhiteSpace(identityOptions.OidcName) ? identityOptions.OidcName : OpenIdConnectDefaults.DisplayName;
|
|
|
|
authBuilder.AddOpenIdConnect("ExternalOidc", displayName, options =>
|
|
{
|
|
options.Authority = identityOptions.OidcAuthority;
|
|
options.ClientId = identityOptions.OidcClient;
|
|
options.ClientSecret = identityOptions.OidcSecret;
|
|
options.RequireHttpsMetadata = false;
|
|
options.Events = new OidcHandler(identityOptions);
|
|
|
|
if (identityOptions.OidcScopes != null)
|
|
{
|
|
foreach (var scope in identityOptions.OidcScopes)
|
|
{
|
|
options.Scope.Add(scope);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
return authBuilder;
|
|
}
|
|
}
|
|
}
|
|
|