|
@@ -5,6 +5,7 @@ using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Hosting;
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
+using Robware.Lib.Auth.ApiKey;
|
|
using Robware.Projects.Code;
|
|
using Robware.Projects.Code;
|
|
using Robware.Projects.Gogs;
|
|
using Robware.Projects.Gogs;
|
|
|
|
|
|
@@ -24,6 +25,8 @@ namespace Robware.Api.Projects {
|
|
client.DefaultRequestHeaders.Add("Authorization", $"token {Configuration["gitApiToken"]}");
|
|
client.DefaultRequestHeaders.Add("Authorization", $"token {Configuration["gitApiToken"]}");
|
|
})
|
|
})
|
|
.ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler {ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => true});
|
|
.ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler {ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => true});
|
|
|
|
+
|
|
|
|
+ services.AddApiKeyAuthentication(Configuration["authEndpoint"], Configuration["authApiKey"]);
|
|
}
|
|
}
|
|
|
|
|
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
|
@@ -35,11 +38,11 @@ namespace Robware.Api.Projects {
|
|
app.UseHttpsRedirection();
|
|
app.UseHttpsRedirection();
|
|
|
|
|
|
app.UseRouting();
|
|
app.UseRouting();
|
|
-
|
|
|
|
|
|
+ app.UseAuthentication();
|
|
app.UseAuthorization();
|
|
app.UseAuthorization();
|
|
|
|
|
|
app.UseEndpoints(endpoints => {
|
|
app.UseEndpoints(endpoints => {
|
|
- endpoints.MapControllers();
|
|
|
|
|
|
+ endpoints.MapControllers().RequireAuthorization();
|
|
});
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|