diff --git a/Gameboard.ShogiUI.Sockets/Controllers/GameController.cs b/Gameboard.ShogiUI.Sockets/Controllers/GameController.cs index 27d9d2f..3a1618a 100644 --- a/Gameboard.ShogiUI.Sockets/Controllers/GameController.cs +++ b/Gameboard.ShogiUI.Sockets/Controllers/GameController.cs @@ -5,17 +5,13 @@ using Gameboard.ShogiUI.Sockets.ServiceModels.Socket; using Gameboard.ShogiUI.Sockets.ServiceModels.Types; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; -using System; -using System.Collections.ObjectModel; -using System.Linq; -using System.Threading.Tasks; namespace Gameboard.ShogiUI.Sockets.Controllers { [ApiController] [Route("[controller]")] - [Authorize(Roles = "Shogi")] + [Authorize] public class GameController : ControllerBase { private readonly IGameboardManager gameboardManager; diff --git a/Gameboard.ShogiUI.Sockets/Controllers/SocketController.cs b/Gameboard.ShogiUI.Sockets/Controllers/SocketController.cs index dc8f9ec..06b4657 100644 --- a/Gameboard.ShogiUI.Sockets/Controllers/SocketController.cs +++ b/Gameboard.ShogiUI.Sockets/Controllers/SocketController.cs @@ -16,7 +16,7 @@ namespace Gameboard.ShogiUI.Sockets.Controllers { [ApiController] [Route("[controller]")] - [Authorize(Roles = "Shogi")] + [Authorize] public class SocketController : ControllerBase { private readonly ILogger logger; diff --git a/Gameboard.ShogiUI.Sockets/Gameboard.ShogiUI.Sockets.csproj b/Gameboard.ShogiUI.Sockets/Gameboard.ShogiUI.Sockets.csproj index 0329db1..973c0c2 100644 --- a/Gameboard.ShogiUI.Sockets/Gameboard.ShogiUI.Sockets.csproj +++ b/Gameboard.ShogiUI.Sockets/Gameboard.ShogiUI.Sockets.csproj @@ -15,7 +15,7 @@ - + diff --git a/Gameboard.ShogiUI.Sockets/Managers/ModelMapper.cs b/Gameboard.ShogiUI.Sockets/Managers/ModelMapper.cs index ef01ef2..8d70143 100644 --- a/Gameboard.ShogiUI.Sockets/Managers/ModelMapper.cs +++ b/Gameboard.ShogiUI.Sockets/Managers/ModelMapper.cs @@ -1,7 +1,4 @@ using Gameboard.ShogiUI.Sockets.ServiceModels.Types; -using System; -using System.Collections.Generic; -using System.Linq; using DomainWhichPiece = Shogi.Domain.WhichPiece; using DomainWhichPlayer = Shogi.Domain.WhichPlayer; diff --git a/Gameboard.ShogiUI.Sockets/Program.cs b/Gameboard.ShogiUI.Sockets/Program.cs index 4ddfa69..b20a9aa 100644 --- a/Gameboard.ShogiUI.Sockets/Program.cs +++ b/Gameboard.ShogiUI.Sockets/Program.cs @@ -8,15 +8,12 @@ using Gameboard.ShogiUI.Sockets.Services.RequestValidators; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Authentication.JwtBearer; -using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.HttpLogging; -using Microsoft.Extensions.Hosting; using Microsoft.Identity.Web; using Microsoft.OpenApi.Models; using Newtonsoft.Json; using Newtonsoft.Json.Converters; using Newtonsoft.Json.Serialization; -using System; using System.Text; namespace Gameboard.ShogiUI.Sockets @@ -43,7 +40,8 @@ namespace Gameboard.ShogiUI.Sockets app.UseSwagger(); 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; }); 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"), TokenUrl = new Uri("https://login.microsoftonline.com/common/oauth2/v2.0/token"), + Scopes = new Dictionary + { + { "api://c1e94676-cab0-42ba-8b6c-9532b8486fff/DefaultScope", "Default Scope" } + } } }, Scheme = "Bearer", diff --git a/Gameboard.ShogiUI.Sockets/appsettings.json b/Gameboard.ShogiUI.Sockets/appsettings.json index 860dbe9..7b37247 100644 --- a/Gameboard.ShogiUI.Sockets/appsettings.json +++ b/Gameboard.ShogiUI.Sockets/appsettings.json @@ -14,20 +14,9 @@ }, "AzureAd": { "Instance": "https://login.microsoftonline.com/", - "Domain": "Hauthlive.onmicrosoft.com", - "TenantId": "d6019544-c403-415c-8e96-50009635b6aa", + "TenantId": "common", "ClientId": "c1e94676-cab0-42ba-8b6c-9532b8486fff", - "Scopes": "", - "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" + "SwaggerUIClientId": "26bf69a4-2af8-4711-bf5b-79f75e20b082" }, "AllowedHosts": "*" } \ No newline at end of file