Added oidc service to webapi with a dumb way of authenticating incoming tokens

This commit is contained in:
2021-10-13 22:26:45 -04:00
parent cccd609233
commit 33cbb4f136
13 changed files with 120 additions and 114 deletions

View File

@@ -30,9 +30,39 @@ namespace WebAPI
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo {Title = "Petrie Panel Web API", Version = "v1"}); });
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo {Title = "Petrie Panel Web API", Version = "v1"});
c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme()
{
Description = "JWT Token",
Name = "Authorization",
In = ParameterLocation.Header,
Type = SecuritySchemeType.ApiKey,
Scheme = "Bearer"
});
c.AddSecurityRequirement(new OpenApiSecurityRequirement()
{
{
new OpenApiSecurityScheme
{
Reference = new OpenApiReference
{
Type = ReferenceType.SecurityScheme,
Id = "Bearer"
},
Scheme = "oauth2",
Name = "Bearer",
In = ParameterLocation.Header,
},
new List<string>()
}
});
});
services.AddDbContext<AppDbContext>(options => options.UseNpgsql(Configuration.GetConnectionString("DefaultConnection")));
services.AddSingleton<PterodactylService>();
services.AddSingleton<OIDCService>();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.