Release v1.0.0 #16
.envDbInitializer.csDependencyInjection.csnuget.config
.gitea/workflows
.gitignoreApiDto
ApiDto.csproj
Backend.slnDockerfileCommon
Requests
Responses
Endpoint
Backend.httpISaveSettings.cs
README.mdCommon
Attributes
BadRequestResponseAttribute.csCacheMaxAgeAttribute.csLocalhostAttribute.csMaintenanceModeIgnoreAttribute.csNotFoundResponseAttribute.csSwaggerDefaultAttribute.csTokenAuthenticationAttribute.cs
Exceptions
Interfaces
MapperDto
Services
Configuration
Core
BackgroundTasks
Middleware
CacheMaxAgeMiddleware.csCookieAuthorizationMiddleware.csCustomExceptionHandlerMiddleware.csJwtRevocationMiddleware.csMaintenanceModeMiddleware.cs
Startup
Model
SwaggerOptions
Validation
Controllers
BaseController.cs
Endpoint.csprojProgram.csConfiguration
V1
AuthController.csCampusController.csDisciplineController.csFacultyController.csGroupController.csImportController.csLectureHallController.csProfessorController.csScheduleController.cs
WeatherForecastController.csSync
WeatherForecast.cswwwroot
css
swagger
Security
Common
CookieNames.cs
DependencyInjection.csDomain
Caching
CookieOptionsParameters.csOAuth2
OAuthProvider.csOAuthUser.csRequestContextInfo.csTwoFactorAuthenticator.csUser.csInterfaces
Properties
Security.csprojServices
SqlData
Application
Application.csprojDependencyInjection.cs
Common
Cqrs
Campus
Queries
Discipline
Queries
Faculty
Queries
Group
Queries
LectureHall
Queries
Professor
Queries
GetProfessorDetails
GetProfessorDetailsBySearch
GetProfessorList
Schedule
Interfaces
Domain
Domain.csproj
Schedule
Migrations
MysqlMigrations
Migrations
20240601023106_InitialMigration.Designer.cs20240601023106_InitialMigration.cs20241027034820_RemoveUnusedRef.Designer.cs20241027034820_RemoveUnusedRef.csUberDbContextModelSnapshot.cs
MysqlMigrations.csprojPsqlMigrations
Migrations
20240601021702_InitialMigration.Designer.cs20240601021702_InitialMigration.cs20241027032753_RemoveUnusedRef.Designer.cs20241027032753_RemoveUnusedRef.csUberDbContextModelSnapshot.cs
PsqlMigrations.csprojSqliteMigrations
Persistence
Common
BaseDbContext.csConfigurationResolver.csDatabaseProvider.csDbContextFactory.csModelBuilderExtensions.cs
Contexts
Schedule
EntityTypeConfigurations
Persistence.csprojUberDbContext.cs
22
ApiDto/Common/OAuthProvider.cs
Normal file
22
ApiDto/Common/OAuthProvider.cs
Normal file
@ -0,0 +1,22 @@
|
||||
namespace Mirea.Api.Dto.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Represents different OAuth providers for authentication.
|
||||
/// </summary>
|
||||
public enum OAuthProvider
|
||||
{
|
||||
/// <summary>
|
||||
/// OAuth provider for Google.
|
||||
/// </summary>
|
||||
Google,
|
||||
|
||||
/// <summary>
|
||||
/// OAuth provider for Yandex.
|
||||
/// </summary>
|
||||
Yandex,
|
||||
|
||||
/// <summary>
|
||||
/// OAuth provider for Mail.ru.
|
||||
/// </summary>
|
||||
MailRu
|
||||
}
|
25
ApiDto/Responses/AvailableProvidersResponse.cs
Normal file
25
ApiDto/Responses/AvailableProvidersResponse.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using Mirea.Api.Dto.Common;
|
||||
using System;
|
||||
|
||||
namespace Mirea.Api.Dto.Responses;
|
||||
|
||||
/// <summary>
|
||||
/// Represents the response containing information about available OAuth providers.
|
||||
/// </summary>
|
||||
public class AvailableProvidersResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the OAuth provider.
|
||||
/// </summary>
|
||||
public required string ProviderName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the enum value representing the OAuth provider.
|
||||
/// </summary>
|
||||
public OAuthProvider Provider { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the redirect URI for the OAuth provider.
|
||||
/// </summary>
|
||||
public required Uri Redirect { get; set; }
|
||||
}
|
27
Endpoint/Common/MapperDto/AvailableProvidersConverter.cs
Normal file
27
Endpoint/Common/MapperDto/AvailableProvidersConverter.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using Mirea.Api.Dto.Responses;
|
||||
using Mirea.Api.Security.Common.Domain;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Mirea.Api.Endpoint.Common.MapperDto;
|
||||
|
||||
public static class AvailableProvidersConverter
|
||||
{
|
||||
public static Dto.Common.OAuthProvider ConvertToDto(this OAuthProvider provider) =>
|
||||
provider switch
|
||||
{
|
||||
OAuthProvider.Google => Dto.Common.OAuthProvider.Google,
|
||||
OAuthProvider.Yandex => Dto.Common.OAuthProvider.Yandex,
|
||||
OAuthProvider.MailRu => Dto.Common.OAuthProvider.MailRu,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(provider), provider, null)
|
||||
};
|
||||
|
||||
public static List<AvailableProvidersResponse> ConvertToDto(this (OAuthProvider Provider, Uri Redirect)[] data) =>
|
||||
data.Select(x => new AvailableProvidersResponse()
|
||||
{
|
||||
ProviderName = Enum.GetName(x.Provider)!,
|
||||
Provider = x.Provider.ConvertToDto(),
|
||||
Redirect = x.Redirect
|
||||
}).ToList();
|
||||
}
|
@ -5,6 +5,7 @@ using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Mirea.Api.Dto.Common;
|
||||
using Mirea.Api.Dto.Requests;
|
||||
using Mirea.Api.Dto.Responses;
|
||||
using Mirea.Api.Endpoint.Common.Attributes;
|
||||
using Mirea.Api.Endpoint.Common.Exceptions;
|
||||
using Mirea.Api.Endpoint.Common.MapperDto;
|
||||
@ -28,6 +29,12 @@ public class AuthController(IOptionsSnapshot<Admin> user, AuthService auth, Pass
|
||||
Path = UrlHelper.GetSubPathWithoutFirstApiName + "api"
|
||||
};
|
||||
|
||||
[HttpGet("GetAvailableProviders")]
|
||||
public ActionResult<List<AvailableProvidersResponse>> GetUrls() =>
|
||||
Ok(oAuthService
|
||||
.GetAvailableProviders(HttpContext, GetCookieParams(), HttpContext.GetApiUrl(Url.Action("OAuth2")!))
|
||||
.ConvertToDto());
|
||||
|
||||
[HttpPost("Login")]
|
||||
[BadRequestResponse]
|
||||
public async Task<ActionResult<TwoFactorAuthentication>> Login([FromBody] LoginRequest request)
|
||||
|
Reference in New Issue
Block a user