diff --git a/.idea/.idea.ModeusSchedule.MSAuth/.idea/.gitignore b/.idea/.idea.ModeusSchedule.MSAuth/.idea/.gitignore new file mode 100644 index 0000000..c779a28 --- /dev/null +++ b/.idea/.idea.ModeusSchedule.MSAuth/.idea/.gitignore @@ -0,0 +1,15 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Rider ignored files +/modules.xml +/contentModel.xml +/projectSettingsUpdater.xml +/.idea.ModeusSchedule.MSAuth.iml +# Ignored default folder with query files +/queries/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/src/BrowserScripts/MicrosoftLoginHelper.cs b/src/BrowserScripts/MicrosoftLoginHelper.cs index d0f1bba..6070e10 100644 --- a/src/BrowserScripts/MicrosoftLoginHelper.cs +++ b/src/BrowserScripts/MicrosoftLoginHelper.cs @@ -1,5 +1,4 @@ using System.Text.RegularExpressions; -using Microsoft.Extensions.Logging; using Microsoft.Playwright; namespace ModeusSchedule.MSAuth.BrowserScripts; @@ -122,6 +121,30 @@ public static class MicrosoftLoginHelper #endregion + // Microsoft может предложить добавить еще один способ проверки после успешного MFA. + // Ссылка определяется по адресу, чтобы обработка не зависела от языка страницы. + var skipMfaRegistration = page.Locator("a[href*='skipmfaregistration=1']").First; + var canSkipMfaRegistration = false; + try + { + await skipMfaRegistration.WaitForAsync(new() + { + State = WaitForSelectorState.Visible, + Timeout = 8_000 + }); + canSkipMfaRegistration = true; + } + catch (TimeoutException) + { + logger.LogDebug("Предложение настроить дополнительный способ MFA не появилось — пропускаем шаг."); + } + + if (canSkipMfaRegistration) + { + logger.LogInformation("Откладываем настройку дополнительного способа MFA."); + await skipMfaRegistration.ClickAsync(); + } + await page.WaitForSelectorAsync("button, input[type='submit'], a", new PageWaitForSelectorOptions { Timeout = 8000 }); var locator = page.Locator("#idSIButton9, #idBtn_Back").First; diff --git a/src/Dockerfile b/src/Dockerfile index a8f13a9..50d3618 100644 --- a/src/Dockerfile +++ b/src/Dockerfile @@ -1,11 +1,11 @@ -FROM mcr.microsoft.com/dotnet/sdk:9.0-alpine3.22 AS build +FROM mcr.microsoft.com/dotnet/sdk:10.0-alpine3.24 AS build ARG BUILD_CONFIGURATION=Release WORKDIR /src COPY . . RUN dotnet restore "ModeusSchedule.MSAuth.csproj" RUN dotnet publish "ModeusSchedule.MSAuth.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false -FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS final +FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS final EXPOSE 8080 WORKDIR /app diff --git a/src/ModeusSchedule.MSAuth.csproj b/src/ModeusSchedule.MSAuth.csproj index b043672..5c7fe9f 100644 --- a/src/ModeusSchedule.MSAuth.csproj +++ b/src/ModeusSchedule.MSAuth.csproj @@ -1,13 +1,13 @@ - net9.0 + net10.0 enable enable - +