Progresss
This commit is contained in:
@@ -7,6 +7,7 @@ using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using VueCliMiddleware;
|
||||
|
||||
namespace KTUSAPS
|
||||
@@ -23,7 +24,10 @@ namespace KTUSAPS
|
||||
// This method gets called by the runtime. Use this method to add services to the container.
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddControllers();
|
||||
services.AddControllers(options =>
|
||||
options.SuppressAsyncSuffixInActionNames = false
|
||||
)
|
||||
.AddControllersAsServices();
|
||||
services.AddSpaStaticFiles(configuration =>
|
||||
{
|
||||
configuration.RootPath = "ClientApp/dist";
|
||||
@@ -32,8 +36,9 @@ namespace KTUSAPS
|
||||
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
|
||||
.AddJwtBearer(options =>
|
||||
{
|
||||
options.MetadataAddress = "https://login.microsoftonline.com/3415f2f7-f5a8-4092-b52a-003aaf844853/v2.0/.well-known/openid-configuration";
|
||||
options.Audience = Configuration["ClientId"];
|
||||
options.Authority = Configuration["Authority"];
|
||||
//options.Authority = Configuration["Authority"];
|
||||
});
|
||||
|
||||
services.AddAuthorization((configure) =>
|
||||
@@ -47,7 +52,28 @@ namespace KTUSAPS
|
||||
services.AddDbContext<Data.SAPSDataContext>((options) => options.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)));
|
||||
services.AddHostedService<DatabaseInitializationService>();
|
||||
|
||||
services.AddSwaggerGen();
|
||||
services.AddSwaggerGen(options =>
|
||||
{
|
||||
options.OperationFilter<AuthorizeCheckOperationFilter>();
|
||||
options.AddSecurityDefinition("msad", new Microsoft.OpenApi.Models.OpenApiSecurityScheme()
|
||||
{
|
||||
Type = Microsoft.OpenApi.Models.SecuritySchemeType.OAuth2,
|
||||
Flows = new Microsoft.OpenApi.Models.OpenApiOAuthFlows()
|
||||
{
|
||||
AuthorizationCode = new Microsoft.OpenApi.Models.OpenApiOAuthFlow()
|
||||
{
|
||||
AuthorizationUrl = new Uri("https://login.microsoftonline.com/3415f2f7-f5a8-4092-b52a-003aaf844853/oauth2/v2.0/authorize"),
|
||||
TokenUrl = new Uri("https://login.microsoftonline.com/3415f2f7-f5a8-4092-b52a-003aaf844853/oauth2/v2.0/token"),
|
||||
Scopes = new Dictionary<string, string>
|
||||
{
|
||||
{ "openid", "Access to user's id" },
|
||||
{ "profile", "Access to user's name" },
|
||||
{ "email", "Access to email" }
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
@@ -60,6 +86,10 @@ namespace KTUSAPS
|
||||
app.UseSwaggerUI(c =>
|
||||
{
|
||||
c.SwaggerEndpoint("/swagger/v1/swagger.json", "API");
|
||||
|
||||
c.OAuthClientId(Configuration["ClientId"]);
|
||||
c.OAuthAppName("KTUSA Problem<65> sistema");
|
||||
c.OAuthUsePkce();
|
||||
});
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user