#oauth changed GoogleController for the jwt flow ( using a common token if we connect from our app or from google )
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
using System.Security.Claims;
|
||||
using Hutopy.Domain.Interfaces;
|
||||
using Hutopy.Infrastructure.Services;
|
||||
using Hutopy.Application.Common.Interfaces;
|
||||
using Hutopy.Infrastructure.Utils;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||
using Microsoft.AspNetCore.Authentication.Facebook;
|
||||
@@ -8,7 +8,7 @@ using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Hutopy.Web.Controllers;
|
||||
|
||||
public class FacebookController(IUserService userService) : Controller
|
||||
public class FacebookController(IIdentityService identityService) : Controller
|
||||
{
|
||||
[HttpGet("/api/facebook/sign-in")]
|
||||
public async Task SignIn()
|
||||
@@ -27,10 +27,10 @@ public class FacebookController(IUserService userService) : Controller
|
||||
|
||||
var claims = authenticateResult.Principal.Claims.ToList();
|
||||
|
||||
var name = claims.FirstOrDefault(c => c.Type == ClaimTypes.Name)?.Value;
|
||||
var email = claims.FirstOrDefault(c => c.Type == ClaimTypes.Email)?.Value;
|
||||
var givenName = claims.FirstOrDefault(c => c.Type == ClaimTypes.GivenName)?.Value;
|
||||
var familyName = claims.FirstOrDefault(c => c.Type == ClaimTypes.Surname)?.Value;
|
||||
var name = claims.FirstOrDefault(c => c.Type == ClaimTypes.Name)?.Value ?? "";
|
||||
var email = claims.FirstOrDefault(c => c.Type == ClaimTypes.Email)?.Value ?? "";
|
||||
var givenName = claims.FirstOrDefault(c => c.Type == ClaimTypes.GivenName)?.Value ?? "";
|
||||
var familyName = claims.FirstOrDefault(c => c.Type == ClaimTypes.Surname)?.Value ?? "";
|
||||
|
||||
var claimsIdentity = new ClaimsIdentity(new List<Claim>
|
||||
{
|
||||
@@ -40,13 +40,13 @@ public class FacebookController(IUserService userService) : Controller
|
||||
new(ClaimTypes.Surname, familyName)
|
||||
}, CookieAuthenticationDefaults.AuthenticationScheme);
|
||||
|
||||
if (await userService.FindUserByEmailAsync(email) != null)
|
||||
if (await identityService.FindUserByEmailAsync(email) != null)
|
||||
{
|
||||
await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(claimsIdentity));
|
||||
return Redirect("/");
|
||||
}
|
||||
|
||||
await userService.CreateUserAsync(email, givenName, givenName, familyName, RandomGenerator.RandomString(24));
|
||||
await identityService.CreateUserAsync(email, givenName, givenName, familyName, RandomGenerator.RandomString(24));
|
||||
await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(claimsIdentity));
|
||||
return Redirect("/");
|
||||
}
|
||||
|
||||
@@ -1,53 +1,70 @@
|
||||
using System.Security.Claims;
|
||||
using Hutopy.Domain.Interfaces;
|
||||
using Hutopy.Infrastructure.Services;
|
||||
using Hutopy.Application.Common.Interfaces;
|
||||
using Hutopy.Infrastructure.Utils;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||
using Microsoft.AspNetCore.Authentication.Google;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Hutopy.Web.Controllers;
|
||||
|
||||
public class GoogleController(IUserService userService) : Controller
|
||||
public class GoogleController(IIdentityService identityService, IHttpClientFactory httpClientFactory) : Controller
|
||||
{
|
||||
[HttpGet("/api/google/sign-in")]
|
||||
public async Task SignIn()
|
||||
[HttpPost("/api/google/sign-in")]
|
||||
public async Task<IActionResult> SignIn([FromBody] GoogleSignInRequest request)
|
||||
{
|
||||
await HttpContext.ChallengeAsync(GoogleDefaults.AuthenticationScheme, new AuthenticationProperties
|
||||
var httpClient = httpClientFactory.CreateClient();
|
||||
// Verify the token with Google
|
||||
var response = await httpClient.GetAsync($"https://www.googleapis.com/oauth2/v1/userinfo?access_token={request.AccessToken}");
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
RedirectUri = Url.Action("Authorize")
|
||||
});
|
||||
}
|
||||
|
||||
public async Task<IActionResult> Authorize()
|
||||
{
|
||||
var authenticateResult = await HttpContext.AuthenticateAsync(GoogleDefaults.AuthenticationScheme);
|
||||
return BadRequest("Invalid Google token.");
|
||||
}
|
||||
|
||||
var payload = JObject.Parse(await response.Content.ReadAsStringAsync());
|
||||
|
||||
var email = payload["email"]?.ToString() ?? "";
|
||||
var name = payload["name"]?.ToString() ?? "";
|
||||
var givenName = payload["given_name"]?.ToString() ?? "";
|
||||
var familyName = payload["family_name"]?.ToString() ?? "";
|
||||
|
||||
if (string.IsNullOrEmpty(email))
|
||||
{
|
||||
return BadRequest("Google token did not contain an email.");
|
||||
}
|
||||
|
||||
// Check if user exists or create a new one
|
||||
var user = await identityService.FindUserByEmailAsync(email);
|
||||
if (user == null)
|
||||
{
|
||||
await identityService.CreateUserAsync(email, email, givenName, familyName, RandomGenerator.RandomString(24));
|
||||
user = await identityService.FindUserByEmailAsync(email);
|
||||
}
|
||||
|
||||
if (!authenticateResult.Succeeded) return BadRequest();
|
||||
|
||||
var claims = authenticateResult.Principal.Claims.ToList();
|
||||
|
||||
var name = claims.FirstOrDefault(c => c.Type == ClaimTypes.Name)?.Value;
|
||||
var email = claims.FirstOrDefault(c => c.Type == ClaimTypes.Email)?.Value;
|
||||
var givenName = claims.FirstOrDefault(c => c.Type == ClaimTypes.GivenName)?.Value;
|
||||
var familyName = claims.FirstOrDefault(c => c.Type == ClaimTypes.Surname)?.Value;
|
||||
|
||||
var claimsIdentity = new ClaimsIdentity(new List<Claim>
|
||||
if (user is null)
|
||||
{
|
||||
return BadRequest("Unable to find or create the user.");
|
||||
}
|
||||
|
||||
// Sign in the user
|
||||
var claims = new List<Claim>
|
||||
{
|
||||
new(ClaimTypes.Name, name),
|
||||
new(ClaimTypes.Email, email),
|
||||
new(ClaimTypes.GivenName, givenName),
|
||||
new(ClaimTypes.Surname, familyName)
|
||||
}, CookieAuthenticationDefaults.AuthenticationScheme);
|
||||
|
||||
if (await userService.FindUserByEmailAsync(email) != null)
|
||||
{
|
||||
await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(claimsIdentity));
|
||||
return Redirect("/");
|
||||
}
|
||||
|
||||
await userService.CreateUserAsync(email, givenName, givenName, familyName, RandomGenerator.RandomString(24));
|
||||
};
|
||||
|
||||
var claimsIdentity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme);
|
||||
await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(claimsIdentity));
|
||||
return Redirect("/");
|
||||
|
||||
var jwtToken = JwtTokenHelper.GenerateJwtToken("https://hutopy.com", "Hutopy", "V3J3bWFuUml3ZVpQbmxlWmZhWEo3ZkJSZ01YbHBwS24=", user.Id!);
|
||||
|
||||
return Ok(new { accessToken = jwtToken, email });
|
||||
}
|
||||
|
||||
public class GoogleSignInRequest
|
||||
{
|
||||
public required string AccessToken { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
using Azure.Identity;
|
||||
using System.Text;
|
||||
using Azure.Identity;
|
||||
using Hutopy.Application.Common.Interfaces;
|
||||
using Hutopy.Infrastructure.Data;
|
||||
using Hutopy.Web.Services;
|
||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||
using Microsoft.AspNetCore.Authentication.Facebook;
|
||||
using Microsoft.AspNetCore.Authentication.Google;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using NSwag;
|
||||
using NSwag.Generation.Processors.Security;
|
||||
|
||||
@@ -24,6 +30,8 @@ public static class DependencyInjection
|
||||
services.AddExceptionHandler<CustomExceptionHandler>();
|
||||
|
||||
services.AddRazorPages();
|
||||
|
||||
services.AddHttpClient();
|
||||
|
||||
// Customise default API behaviour
|
||||
services.Configure<ApiBehaviorOptions>(options =>
|
||||
@@ -62,4 +70,45 @@ public static class DependencyInjection
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
public static IServiceCollection AddAuthorizationAndAuthentication(this IServiceCollection services, ConfigurationManager configuration)
|
||||
{
|
||||
services.AddAuthentication(options =>
|
||||
{
|
||||
options.DefaultScheme = JwtBearerDefaults.AuthenticationScheme;
|
||||
options.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme;
|
||||
})
|
||||
.AddCookie("Identity.Application", options =>
|
||||
{
|
||||
options.LoginPath = "/api/Users/login";
|
||||
})
|
||||
.AddCookie()
|
||||
.AddJwtBearer(JwtBearerDefaults.AuthenticationScheme, jwtBearerOptions =>
|
||||
{
|
||||
jwtBearerOptions.Authority = "https://hutopy.com";
|
||||
jwtBearerOptions.TokenValidationParameters = new TokenValidationParameters
|
||||
{
|
||||
ValidateIssuer = true,
|
||||
ValidIssuer = configuration["Jwt:Issuer"],
|
||||
ValidateAudience = true,
|
||||
ValidAudience = configuration["Jwt:Audience"],
|
||||
ValidateLifetime = true,
|
||||
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(configuration["Jwt:Key"] ?? ""))
|
||||
};
|
||||
})
|
||||
.AddGoogle(GoogleDefaults.AuthenticationScheme, options =>
|
||||
{
|
||||
options.ClientId = configuration["Google:ClientId"] ?? "";
|
||||
options.ClientSecret = configuration["Google:ClientSecret"] ?? "";
|
||||
})
|
||||
.AddFacebook(FacebookDefaults.AuthenticationScheme, options =>
|
||||
{
|
||||
options.ClientId = configuration["Facebook:ClientId"] ??
|
||||
throw new ArgumentNullException("The Facebook ClientId is missing.");
|
||||
options.ClientSecret = configuration["Facebook:ClientSecret"] ??
|
||||
throw new ArgumentNullException("The Facebook ClientSecret is missing.");
|
||||
});
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@ public class Users : EndpointGroupBase
|
||||
{
|
||||
app.MapGroup(this)
|
||||
.MapPost(CreateUser)
|
||||
.MapGet(GetMinimalUser)
|
||||
.MapIdentityApi<ApplicationUser>();
|
||||
.MapPost(Login, "/login")
|
||||
.MapGet(GetMinimalUser);
|
||||
}
|
||||
|
||||
private static async Task<Guid> CreateUser(ISender sender, CreateUserCommand command)
|
||||
@@ -23,4 +23,9 @@ public class Users : EndpointGroupBase
|
||||
{
|
||||
return await sender.Send(query);
|
||||
}
|
||||
|
||||
private static async Task<string> Login(ISender sender, LoginCommand command)
|
||||
{
|
||||
return await sender.Send(command);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,12 +3,7 @@ using Hutopy.Infrastructure;
|
||||
using Hutopy.Infrastructure.Data;
|
||||
using Hutopy.Web;
|
||||
using Azure.Identity;
|
||||
using Hutopy.Infrastructure.Identity;
|
||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||
using Microsoft.AspNetCore.Authentication.Facebook;
|
||||
using Microsoft.AspNetCore.Authentication.Google;
|
||||
using Microsoft.AspNetCore.HttpOverrides;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
@@ -50,49 +45,8 @@ builder.Services.AddKeyVaultIfConfigured(builder.Configuration);
|
||||
builder.Services.AddApplicationServices();
|
||||
builder.Services.AddInfrastructureServices(builder.Configuration);
|
||||
builder.Services.AddWebServices();
|
||||
|
||||
// OAuth
|
||||
builder.Services.AddAuthentication(options =>
|
||||
{
|
||||
options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
|
||||
options.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme;
|
||||
})
|
||||
.AddCookie()
|
||||
.AddGoogle(
|
||||
GoogleDefaults.AuthenticationScheme,
|
||||
options =>
|
||||
{
|
||||
options.ClientId = builder.Configuration["Google:ClientId"] ??
|
||||
throw new ArgumentNullException("The Google ClientId is missing.");
|
||||
options.ClientSecret = builder.Configuration["Google:ClientSecret"] ??
|
||||
throw new ArgumentNullException("The Google ClientSecret is missing.");
|
||||
//options.AccessDeniedPath = "/AccessDeniedPathInfo";
|
||||
})
|
||||
.AddFacebook(
|
||||
FacebookDefaults.AuthenticationScheme,
|
||||
options =>
|
||||
{
|
||||
options.ClientId = builder.Configuration["Facebook:ClientId"] ??
|
||||
throw new ArgumentNullException("The Facebook ClientId is missing.");
|
||||
options.ClientSecret = builder.Configuration["Facebook:ClientSecret"] ??
|
||||
throw new ArgumentNullException("The Facebook ClientSecret is missing.");
|
||||
//options.AccessDeniedPath = "/AccessDeniedPathInfo";
|
||||
});
|
||||
|
||||
// Password hashing
|
||||
builder.Services.AddIdentity<ApplicationUser, IdentityRole>(options =>
|
||||
{
|
||||
options.Password.RequireDigit = false;
|
||||
options.Password.RequireLowercase = false;
|
||||
options.Password.RequireUppercase = false;
|
||||
options.Password.RequireNonAlphanumeric = false;
|
||||
options.Password.RequiredLength = 16;
|
||||
})
|
||||
.AddEntityFrameworkStores<ApplicationDbContext>()
|
||||
.AddDefaultTokenProviders();
|
||||
|
||||
builder.Services.AddAuthorizationAndAuthentication(builder.Configuration);
|
||||
builder.Services.AddControllers();
|
||||
builder.Services.AddScoped<IUserService, UserService>();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
@@ -100,13 +54,15 @@ app.UseForwardedHeaders(
|
||||
new ForwardedHeadersOptions { ForwardedHeaders = ForwardedHeaders.XForwardedProto }
|
||||
);
|
||||
|
||||
app.UseAuthentication();
|
||||
app.UseAuthorization();
|
||||
|
||||
app.UseCors("AllowAll");
|
||||
app.UseCors("AllowHutopyUi");
|
||||
app.UseCors("AllowHutopyUiPreview");
|
||||
|
||||
app.UseAuthentication();
|
||||
app.UseAuthorization();
|
||||
|
||||
|
||||
|
||||
// Initialize and seed the db.
|
||||
await app.InitialiseDatabaseAsync();
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
<PackageReference Include="Azure.Identity" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.Facebook" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.Google" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" />
|
||||
|
||||
@@ -9,21 +9,15 @@
|
||||
},
|
||||
"Google": {
|
||||
"ClientId": "",
|
||||
"ClientSecret": "",
|
||||
"ProjectId": "",
|
||||
"AuthUri": "",
|
||||
"TokenUri": "",
|
||||
"AuthProviderX509CertUrl": "",
|
||||
"RedirectUris": [
|
||||
"https://hutopy.ca",
|
||||
"https://hutopy.com",
|
||||
"http://localhost"
|
||||
],
|
||||
"JavascriptOrigins": [
|
||||
"https://hutopy.ca",
|
||||
"https://hutopy.com",
|
||||
"http://localhost"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
"ClientSecret": ""
|
||||
},
|
||||
"Facebook": {
|
||||
"ClientId": "",
|
||||
"ClientSecret": ""
|
||||
},
|
||||
"Jwt": {
|
||||
"Issuer": "",
|
||||
"Audience": "",
|
||||
"Key": ""
|
||||
}
|
||||
}
|
||||
@@ -273,75 +273,22 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/Users/register": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"Users"
|
||||
],
|
||||
"operationId": "PostApiUsersRegister",
|
||||
"requestBody": {
|
||||
"x-name": "registration",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/RegisterRequest"
|
||||
}
|
||||
}
|
||||
},
|
||||
"x-position": 1
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": ""
|
||||
},
|
||||
"400": {
|
||||
"description": "",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/HttpValidationProblemDetails"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/Users/login": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"Users"
|
||||
],
|
||||
"operationId": "PostApiUsersLogin",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "useCookies",
|
||||
"in": "query",
|
||||
"schema": {
|
||||
"type": "boolean",
|
||||
"nullable": true
|
||||
},
|
||||
"x-position": 2
|
||||
},
|
||||
{
|
||||
"name": "useSessionCookies",
|
||||
"in": "query",
|
||||
"schema": {
|
||||
"type": "boolean",
|
||||
"nullable": true
|
||||
},
|
||||
"x-position": 3
|
||||
}
|
||||
],
|
||||
"operationId": "Login",
|
||||
"requestBody": {
|
||||
"x-name": "login",
|
||||
"x-name": "command",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/LoginRequest"
|
||||
"$ref": "#/components/schemas/LoginCommand"
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": true,
|
||||
"x-position": 1
|
||||
},
|
||||
"responses": {
|
||||
@@ -350,7 +297,7 @@
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/AccessTokenResponse"
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -358,305 +305,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/Users/refresh": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"Users"
|
||||
],
|
||||
"operationId": "PostApiUsersRefresh",
|
||||
"requestBody": {
|
||||
"x-name": "refreshRequest",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/RefreshRequest"
|
||||
}
|
||||
}
|
||||
},
|
||||
"x-position": 1
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/AccessTokenResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/Users/confirmEmail": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Users"
|
||||
],
|
||||
"operationId": "GetApiUsersConfirmEmail",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "userId",
|
||||
"in": "query",
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
},
|
||||
"x-position": 1
|
||||
},
|
||||
{
|
||||
"name": "code",
|
||||
"in": "query",
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
},
|
||||
"x-position": 2
|
||||
},
|
||||
{
|
||||
"name": "changedEmail",
|
||||
"in": "query",
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
},
|
||||
"x-position": 3
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/Users/resendConfirmationEmail": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"Users"
|
||||
],
|
||||
"operationId": "PostApiUsersResendConfirmationEmail",
|
||||
"requestBody": {
|
||||
"x-name": "resendRequest",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ResendConfirmationEmailRequest"
|
||||
}
|
||||
}
|
||||
},
|
||||
"x-position": 1
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/Users/forgotPassword": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"Users"
|
||||
],
|
||||
"operationId": "PostApiUsersForgotPassword",
|
||||
"requestBody": {
|
||||
"x-name": "resetRequest",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ForgotPasswordRequest"
|
||||
}
|
||||
}
|
||||
},
|
||||
"x-position": 1
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": ""
|
||||
},
|
||||
"400": {
|
||||
"description": "",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/HttpValidationProblemDetails"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/Users/resetPassword": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"Users"
|
||||
],
|
||||
"operationId": "PostApiUsersResetPassword",
|
||||
"requestBody": {
|
||||
"x-name": "resetRequest",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ResetPasswordRequest"
|
||||
}
|
||||
}
|
||||
},
|
||||
"x-position": 1
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": ""
|
||||
},
|
||||
"400": {
|
||||
"description": "",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/HttpValidationProblemDetails"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/Users/manage/2fa": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"Users"
|
||||
],
|
||||
"operationId": "PostApiUsersManage2fa",
|
||||
"requestBody": {
|
||||
"x-name": "tfaRequest",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/TwoFactorRequest"
|
||||
}
|
||||
}
|
||||
},
|
||||
"x-position": 1
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/TwoFactorResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/HttpValidationProblemDetails"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": ""
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"JWT": []
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/Users/manage/info": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Users"
|
||||
],
|
||||
"operationId": "GetApiUsersManageInfo",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/InfoResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/HttpValidationProblemDetails"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": ""
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"JWT": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"post": {
|
||||
"tags": [
|
||||
"Users"
|
||||
],
|
||||
"operationId": "PostApiUsersManageInfo",
|
||||
"requestBody": {
|
||||
"x-name": "infoRequest",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/InfoRequest"
|
||||
}
|
||||
}
|
||||
},
|
||||
"x-position": 1
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/InfoResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/HttpValidationProblemDetails"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": ""
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"JWT": []
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/WeatherForecasts": {
|
||||
"get": {
|
||||
"tags": [
|
||||
@@ -699,14 +347,34 @@
|
||||
}
|
||||
},
|
||||
"/api/google/sign-in": {
|
||||
"get": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"Google"
|
||||
],
|
||||
"operationId": "Google_SignIn",
|
||||
"requestBody": {
|
||||
"x-name": "request",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/GoogleSignInRequest"
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": true,
|
||||
"x-position": 1
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": ""
|
||||
"description": "",
|
||||
"content": {
|
||||
"application/octet-stream": {
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"format": "binary"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -986,6 +654,18 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"LoginCommand": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"emailAddress": {
|
||||
"type": "string"
|
||||
},
|
||||
"password": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"MinimalUserDto": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
@@ -1001,231 +681,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"HttpValidationProblemDetails": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/components/schemas/ProblemDetails"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"nullable": true
|
||||
},
|
||||
"properties": {
|
||||
"errors": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"ProblemDetails": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"nullable": true
|
||||
},
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
},
|
||||
"title": {
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
},
|
||||
"status": {
|
||||
"type": "integer",
|
||||
"format": "int32",
|
||||
"nullable": true
|
||||
},
|
||||
"detail": {
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
},
|
||||
"instance": {
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"RegisterRequest": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"email": {
|
||||
"type": "string"
|
||||
},
|
||||
"password": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"AccessTokenResponse": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"tokenType": {
|
||||
"type": "string"
|
||||
},
|
||||
"accessToken": {
|
||||
"type": "string"
|
||||
},
|
||||
"expiresIn": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
"refreshToken": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"LoginRequest": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"email": {
|
||||
"type": "string"
|
||||
},
|
||||
"password": {
|
||||
"type": "string"
|
||||
},
|
||||
"twoFactorCode": {
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
},
|
||||
"twoFactorRecoveryCode": {
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"RefreshRequest": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"refreshToken": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ResendConfirmationEmailRequest": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"email": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ForgotPasswordRequest": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"email": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ResetPasswordRequest": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"email": {
|
||||
"type": "string"
|
||||
},
|
||||
"resetCode": {
|
||||
"type": "string"
|
||||
},
|
||||
"newPassword": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"TwoFactorResponse": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"sharedKey": {
|
||||
"type": "string"
|
||||
},
|
||||
"recoveryCodesLeft": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
},
|
||||
"recoveryCodes": {
|
||||
"type": "array",
|
||||
"nullable": true,
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"isTwoFactorEnabled": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"isMachineRemembered": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
"TwoFactorRequest": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"enable": {
|
||||
"type": "boolean",
|
||||
"nullable": true
|
||||
},
|
||||
"twoFactorCode": {
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
},
|
||||
"resetSharedKey": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"resetRecoveryCodes": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"forgetMachine": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
"InfoResponse": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"email": {
|
||||
"type": "string"
|
||||
},
|
||||
"isEmailConfirmed": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
"InfoRequest": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"newEmail": {
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
},
|
||||
"newPassword": {
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
},
|
||||
"oldPassword": {
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"WeatherForecast": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
@@ -1247,6 +702,15 @@
|
||||
"nullable": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"GoogleSignInRequest": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"accessToken": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"securitySchemes": {
|
||||
|
||||
Reference in New Issue
Block a user