< Summary

Class:SVETA.Api.ConfigureOptions.ConfigureIdentityServerOptions
Assembly:SVETA.Api
File(s):/opt/dev/sveta_api_build/SVETA.Api/ConfigureOptions/ConfigureIdentityServerOptions.cs
Covered lines:0
Uncovered lines:15
Coverable lines:15
Total lines:48
Line coverage:0% (0 of 15)
Covered branches:0
Total branches:4
Branch coverage:0% (0 of 4)

Metrics

MethodLine coverage Branch coverage
.ctor(...)0%100%
Configure(...)0%0%
Configure(...)0%100%

File(s)

/opt/dev/sveta_api_build/SVETA.Api/ConfigureOptions/ConfigureIdentityServerOptions.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using System.Linq;
 4using Microsoft.Extensions.Options;
 5using System.Threading.Tasks;
 6using IdentityServer4.AccessTokenValidation;
 7using Microsoft.Extensions.DependencyInjection;
 8using WinSolutions.Sveta.Server.Data.DataModel.Contexts;
 9using WinSolutions.Sveta.Server.Data.DataModel.Entities;
 10using Microsoft.Extensions.Configuration;
 11using SVETA.Api.Data.DTO;
 12using SVETA.Api.Data.Domain;
 13using SVETA.Api.Helpers;
 14using System.Text;
 15
 16namespace SVETA.Api.ConfigureOptions
 17{
 18    public class ConfigureIdentityServerOptions : IConfigureNamedOptions<IdentityServerAuthenticationOptions>
 19    {
 20        private readonly IConfiguration _сonfiguration;
 21        private readonly AuthorizationSettings _authConfs;
 22
 023        public ConfigureIdentityServerOptions(IConfiguration сonfiguration, IOptions<AuthorizationSettings> authConfs)
 024        {
 025            _сonfiguration = сonfiguration;
 026            _authConfs = authConfs.Value;
 027        }
 28
 29        /// <summary>
 30        /// Конфигурирует настройки OIDC
 31        /// </summary>
 32        /// <param name="name"></param>
 33        /// <param name="options"></param>
 34        public void Configure(string name, IdentityServerAuthenticationOptions options)
 035        {
 036            if (name == IdentityServerAuthenticationDefaults.AuthenticationScheme)
 037            {
 038                options.Authority = _authConfs.IdentityUrl;
 039                options.ApiName = _authConfs.ApiName;
 040                options.ApiSecret = _authConfs.ApiSecret.Encrypted ? SymmetricCrypto.DecryptData(Convert.FromBase64Strin
 041                options.RequireHttpsMetadata = false;
 042            }
 043        }
 44
 45        // This won't be called, but is required for the IConfigureNamedOptions interface
 046        public void Configure(IdentityServerAuthenticationOptions options) => Configure(Options.DefaultName, options);
 47    }
 48}