Swagger-ui works

This commit is contained in:
2022-06-16 19:08:23 -05:00
parent 96cfd2411b
commit 3e938a8576
6 changed files with 11 additions and 27 deletions

View File

@@ -5,17 +5,13 @@ using Gameboard.ShogiUI.Sockets.ServiceModels.Socket;
using Gameboard.ShogiUI.Sockets.ServiceModels.Types; using Gameboard.ShogiUI.Sockets.ServiceModels.Types;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading.Tasks;
namespace Gameboard.ShogiUI.Sockets.Controllers namespace Gameboard.ShogiUI.Sockets.Controllers
{ {
[ApiController] [ApiController]
[Route("[controller]")] [Route("[controller]")]
[Authorize(Roles = "Shogi")] [Authorize]
public class GameController : ControllerBase public class GameController : ControllerBase
{ {
private readonly IGameboardManager gameboardManager; private readonly IGameboardManager gameboardManager;

View File

@@ -16,7 +16,7 @@ namespace Gameboard.ShogiUI.Sockets.Controllers
{ {
[ApiController] [ApiController]
[Route("[controller]")] [Route("[controller]")]
[Authorize(Roles = "Shogi")] [Authorize]
public class SocketController : ControllerBase public class SocketController : ControllerBase
{ {
private readonly ILogger<SocketController> logger; private readonly ILogger<SocketController> logger;

View File

@@ -15,7 +15,7 @@
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.5" /> <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.5" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="6.0.5" /> <PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="6.0.5" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.1" /> <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.1" />
<PackageReference Include="Microsoft.Identity.Web" Version="1.21.1" /> <PackageReference Include="Microsoft.Identity.Web" Version="1.24.1" />
<PackageReference Include="Microsoft.Identity.Web.UI" Version="1.16.0" /> <PackageReference Include="Microsoft.Identity.Web.UI" Version="1.16.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.3.1" /> <PackageReference Include="Swashbuckle.AspNetCore" Version="6.3.1" />

View File

@@ -1,7 +1,4 @@
using Gameboard.ShogiUI.Sockets.ServiceModels.Types; using Gameboard.ShogiUI.Sockets.ServiceModels.Types;
using System;
using System.Collections.Generic;
using System.Linq;
using DomainWhichPiece = Shogi.Domain.WhichPiece; using DomainWhichPiece = Shogi.Domain.WhichPiece;
using DomainWhichPlayer = Shogi.Domain.WhichPlayer; using DomainWhichPlayer = Shogi.Domain.WhichPlayer;

View File

@@ -8,15 +8,12 @@ using Gameboard.ShogiUI.Sockets.Services.RequestValidators;
using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpLogging; using Microsoft.AspNetCore.HttpLogging;
using Microsoft.Extensions.Hosting;
using Microsoft.Identity.Web; using Microsoft.Identity.Web;
using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Converters; using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Serialization;
using System;
using System.Text; using System.Text;
namespace Gameboard.ShogiUI.Sockets namespace Gameboard.ShogiUI.Sockets
@@ -43,7 +40,8 @@ namespace Gameboard.ShogiUI.Sockets
app.UseSwagger(); app.UseSwagger();
app.UseSwaggerUI(options => app.UseSwaggerUI(options =>
{ {
options.OAuthConfigObject.ClientId = builder.Configuration["AzureAd:ClientId"]; options.OAuthScopes("api://c1e94676-cab0-42ba-8b6c-9532b8486fff/DefaultScope");
options.OAuthConfigObject.ClientId = builder.Configuration["AzureAd:SwaggerUIClientId"];
options.OAuthConfigObject.UsePkceWithAuthorizationCodeGrant = true; options.OAuthConfigObject.UsePkceWithAuthorizationCodeGrant = true;
}); });
app.UseHttpsRedirection(); // Apache handles HTTPS in production. app.UseHttpsRedirection(); // Apache handles HTTPS in production.
@@ -194,6 +192,10 @@ namespace Gameboard.ShogiUI.Sockets
{ {
AuthorizationUrl = new Uri("https://login.microsoftonline.com/common/oauth2/v2.0/authorize"), AuthorizationUrl = new Uri("https://login.microsoftonline.com/common/oauth2/v2.0/authorize"),
TokenUrl = new Uri("https://login.microsoftonline.com/common/oauth2/v2.0/token"), TokenUrl = new Uri("https://login.microsoftonline.com/common/oauth2/v2.0/token"),
Scopes = new Dictionary<string, string>
{
{ "api://c1e94676-cab0-42ba-8b6c-9532b8486fff/DefaultScope", "Default Scope" }
}
} }
}, },
Scheme = "Bearer", Scheme = "Bearer",

View File

@@ -14,20 +14,9 @@
}, },
"AzureAd": { "AzureAd": {
"Instance": "https://login.microsoftonline.com/", "Instance": "https://login.microsoftonline.com/",
"Domain": "Hauthlive.onmicrosoft.com", "TenantId": "common",
"TenantId": "d6019544-c403-415c-8e96-50009635b6aa",
"ClientId": "c1e94676-cab0-42ba-8b6c-9532b8486fff", "ClientId": "c1e94676-cab0-42ba-8b6c-9532b8486fff",
"Scopes": "", "SwaggerUIClientId": "26bf69a4-2af8-4711-bf5b-79f75e20b082"
"CallbackPath": "/signin-oidc"
},
"AzureAd2": {
"Instance": "https://login.microsoftonline.com/",
"ClientId": "c1e94676-cab0-42ba-8b6c-9532b8486fff",
"TenantId": "d6019544-c403-415c-8e96-50009635b6aa",
"Audience": "c1e94676-cab0-42ba-8b6c-9532b8486fff",
"ClientSecret": "",
"Domain": "Hauthlive.onmicrosoft.com",
"CallbackPath": "/signin-oidc"
}, },
"AllowedHosts": "*" "AllowedHosts": "*"
} }