< Summary

Information
Class: Syki.Back.Configs.AuthorizationConfigs
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Configs/AuthorizationConfigs.cs
Tag: 22_11348620282
Line coverage
87%
Covered lines: 14
Uncovered lines: 2
Coverable lines: 16
Total lines: 27
Line coverage: 87.5%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
AddAuthorizationConfigs(...)100%1187.5%

File(s)

/home/runner/work/syki/syki/Back/Configs/AuthorizationConfigs.cs

#LineLine coverage
 1using Syki.Back.Auth;
 2
 3namespace Syki.Back.Configs;
 4
 5public static class AuthorizationConfigs
 6{
 7    public static void AddAuthorizationConfigs(this IServiceCollection services)
 8    {
 19        services.ConfigureApplicationCookie(options =>
 110        {
 111            options.Events.OnRedirectToLogin = context =>
 112            {
 013                context.Response.StatusCode = 401;
 014                return Task.CompletedTask;
 115            };
 216        });
 17
 118        services.AddSingleton<IAuthorizationHandler, SkipUserRegisterAuthReqHandler>();
 119        services.AddSingleton<IAuthorizationHandler, CrossLoginAuthReqHandler>();
 20
 121        services.AddAuthorization(options =>
 122        {
 223            options.AddPolicy(BackPolicy.SkipUserRegister, p => p.Requirements.Add(new SkipUserRegisterAuthRequirement()
 224            options.AddPolicy(BackPolicy.CrossLogin, p => p.Requirements.Add(new CrossLoginAuthRequirement()));
 225        });
 126    }
 27}