• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

avv73 / graphigrade / 12735771290

12 Jan 2025 05:47PM UTC coverage: 8.778% (-0.1%) from 8.882%
12735771290

push

github

web-flow
feat(sso): Add Microsoft SSO. (#8)

0 of 30 new or added lines in 3 files covered. (0.0%)

2 existing lines in 2 files now uncovered.

209 of 2381 relevant lines covered (8.78%)

0.99 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Program.cs
1
using GraphiGrade.Configuration;
2
using GraphiGrade.Data;
3
using GraphiGrade.Extensions;
4
using GraphiGrade.Logger;
5
using GraphiGrade.Models.Identity;
6
using Microsoft.EntityFrameworkCore;
7

8
var builder = WebApplication.CreateBuilder(args);
×
9

10
// Read configuration from appsettings.
11
var configurationBuilder = new ConfigurationBuilder()
×
12
    .SetBasePath(builder.Environment.ContentRootPath)
×
13
    .AddJsonFile($"appsettings.{builder.Environment.EnvironmentName}.json", optional: false, reloadOnChange: false)
×
14
    .AddEnvironmentVariables()
×
15
    .AddUserSecrets<Program>();
×
16

17
var configuration = configurationBuilder.Build();
×
18

19
// Setup configuration through Options Pattern.
20
builder.Services.AddOptions<GraphiGradeConfig>()
×
21
    .Bind(configuration.GetSection("GraphiGradeConfig"))
×
22
    .ValidateDataAnnotations()
×
23
    .ValidateOnStart();
×
24

25
// Read configuration from Options Pattern to setup services down the line.
NEW
26
var optionsConfiguration = new GraphiGradeConfig();
×
NEW
27
configuration.GetSection("GraphiGradeConfig").Bind(optionsConfiguration);
×
28

29
// Setup Db context.
30
builder.Services.AddDbContext<ApplicationDbContext>(options =>
×
NEW
31
    options.UseSqlServer(optionsConfiguration.DbConnectionString));
×
32

33
builder.Services.AddDatabaseDeveloperPageExceptionFilter();
×
34

35
// Setup ASP.NET Core identity.
36
builder.Services.AddDefaultIdentity<User>(options => options.SignIn.RequireConfirmedAccount = true)
×
37
    .AddEntityFrameworkStores<ApplicationDbContext>();
×
38

39
// Setup Microsoft SSO.
NEW
40
if (optionsConfiguration.MicrosoftSsoConfig.IsEnabled)
×
41
{
NEW
42
    builder.Services.AddAuthentication().AddMicrosoftAccount(microsoftOptions =>
×
NEW
43
    {
×
NEW
44
        microsoftOptions.ClientId = optionsConfiguration.MicrosoftSsoConfig.ClientId;
×
NEW
45
        microsoftOptions.ClientSecret = optionsConfiguration.MicrosoftSsoConfig.ClientSecret;
×
NEW
46
        microsoftOptions.AuthorizationEndpoint = optionsConfiguration.MicrosoftSsoConfig.AuthorizationEndpoint;
×
NEW
47
        microsoftOptions.TokenEndpoint = optionsConfiguration.MicrosoftSsoConfig.TokenEndpoint;
×
NEW
48
    });
×
49
}
50

UNCOV
51
builder.Services.AddGraphiGradeServices();
×
52

53
builder.Services.AddRazorPages();
×
54

55
LogUtils.PrintStartInfo(builder);
×
56

57
var app = builder.Build();
×
58

59
// Automatically apply migrations for Production before startup.
60
if (builder.Environment.IsProduction())
×
61
{
62
    Console.WriteLine("[STARTUP] Applying Production migrations to DB...");
×
63
    app.ApplyMigrations();
×
64
    Console.WriteLine("[STARTUP] Migrations applied!");
×
65
}
66

67
// Configure the HTTP request pipeline.
68
if (app.Environment.IsDevelopment())
×
69
{
70
    app.UseMigrationsEndPoint();
×
71
}
72
else
73
{
74
    app.UseExceptionHandler("/Error");
×
75
    // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
76
    app.UseHsts();
×
77
}
78

79
app.UseHttpsRedirection();
×
80
app.UseStaticFiles();
×
81

82
app.UseRouting();
×
83

84
app.UseAuthorization();
×
85

86
app.MapRazorPages();
×
87

88
app.Run();
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc