Migration to EF and starting to add Identity #11

Merged
jtom38 merged 16 commits from features/ef-identity-migration into main 2023-07-09 22:19:01 -07:00
7 changed files with 38 additions and 23 deletions
Showing only changes of commit 9e2b44df7c - Show all commits

View File

@ -1,6 +1,7 @@
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Newsbot.Collector.Database.Repositories;
using Newsbot.Collector.Domain.Dto; using Newsbot.Collector.Domain.Dto;
using Newsbot.Collector.Domain.Interfaces; using Newsbot.Collector.Domain.Interfaces;
using Newsbot.Collector.Domain.Models; using Newsbot.Collector.Domain.Models;
@ -9,17 +10,18 @@ namespace Newsbot.Collector.Api.Controllers;
[ApiController] [ApiController]
[Route("api/articles")] [Route("api/articles")]
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
public class ArticlesController : ControllerBase public class ArticlesController : ControllerBase
{ {
private readonly IArticlesRepository _articles;
private readonly ILogger<ArticlesController> _logger; private readonly ILogger<ArticlesController> _logger;
private readonly IArticlesRepository _articles;
private readonly ISourcesRepository _sources; private readonly ISourcesRepository _sources;
public ArticlesController(ILogger<ArticlesController> logger, IOptions<ConnectionStrings> settings) public ArticlesController(ILogger<ArticlesController> logger, IArticlesRepository articles, ISourcesRepository sources)
{ {
_logger = logger; _logger = logger;
_articles = new ArticlesTable(settings.Value.Database); _articles = articles;
_sources = new SourcesTable(settings.Value.Database); _sources = sources;
} }
[HttpGet(Name = "GetArticles")] [HttpGet(Name = "GetArticles")]

View File

@ -1,4 +1,6 @@
using Hangfire; using Hangfire;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Newsbot.Collector.Domain.Models.Config; using Newsbot.Collector.Domain.Models.Config;
@ -8,6 +10,7 @@ namespace Newsbot.Collector.Api.Controllers;
[ApiController] [ApiController]
[Route("api/codeprojects")] [Route("api/codeprojects")]
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
public class CodeProjectController public class CodeProjectController
{ {
private readonly ConfigSectionConnectionStrings _connectionStrings; private readonly ConfigSectionConnectionStrings _connectionStrings;

View File

@ -1,4 +1,6 @@
using System.Net; using System.Net;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Newsbot.Collector.Database.Repositories; using Newsbot.Collector.Database.Repositories;
@ -11,17 +13,16 @@ namespace Newsbot.Collector.Api.Controllers;
[ApiController] [ApiController]
[Route("api/discord/webhooks")] [Route("api/discord/webhooks")]
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
public class DiscordWebHookController : ControllerBase public class DiscordWebHookController : ControllerBase
{ {
private readonly ILogger<DiscordWebHookController> _logger; private readonly ILogger<DiscordWebHookController> _logger;
private readonly ConnectionStrings _settings;
private readonly IDiscordWebHooksRepository _webhooks; private readonly IDiscordWebHooksRepository _webhooks;
public DiscordWebHookController(ILogger<DiscordWebHookController> logger, IOptions<ConnectionStrings> settings) public DiscordWebHookController(ILogger<DiscordWebHookController> logger, IOptions<ConnectionStrings> settings, IDiscordWebHooksRepository webhooks)
{ {
_logger = logger; _logger = logger;
_settings = settings.Value; _webhooks = webhooks;
_webhooks = new DiscordWebhooksTable(_settings.Database);
} }
[HttpGet(Name = "GetDiscordWebhooks")] [HttpGet(Name = "GetDiscordWebhooks")]

View File

@ -1,13 +1,17 @@
using Hangfire; using Hangfire;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Newsbot.Collector.Domain.Models.Config; using Newsbot.Collector.Domain.Models.Config;
using Newsbot.Collector.Domain.Models.Config.Sources;
using Newsbot.Collector.Services.Jobs; using Newsbot.Collector.Services.Jobs;
namespace Newsbot.Collector.Api.Controllers; namespace Newsbot.Collector.Api.Controllers;
[ApiController] [ApiController]
[Route("api/rss")] [Route("api/rss")]
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
public class RssController public class RssController
{ {
private readonly ConfigSectionConnectionStrings _connectionStrings; private readonly ConfigSectionConnectionStrings _connectionStrings;

View File

@ -1,3 +1,5 @@
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Newsbot.Collector.Database.Repositories; using Newsbot.Collector.Database.Repositories;
@ -12,22 +14,18 @@ namespace Newsbot.Collector.Api.Controllers;
[ApiController] [ApiController]
[Route("api/sources")] [Route("api/sources")]
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
public class SourcesController : ControllerBase public class SourcesController : ControllerBase
{ {
private readonly IArticlesRepository _articles;
//private readonly ConnectionStrings _settings;
private readonly IIconsRepository _icons;
private readonly ILogger<SourcesController> _logger; private readonly ILogger<SourcesController> _logger;
private readonly IIconsRepository _icons;
private readonly ISourcesRepository _sources; private readonly ISourcesRepository _sources;
public SourcesController(ILogger<SourcesController> logger, IOptions<ConnectionStrings> settings) public SourcesController(ILogger<SourcesController> logger, IIconsRepository icons, ISourcesRepository sources)
{ {
_logger = logger; _logger = logger;
//_settings = settings.Value; _icons = icons;
_sources = new SourcesTable(settings.Value.Database); _sources = sources;
_icons = new IconsTable(settings.Value.Database);
_articles = new ArticlesTable(settings.Value.Database);
} }
[HttpGet(Name = "GetSources")] [HttpGet(Name = "GetSources")]

View File

@ -1,3 +1,5 @@
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Newsbot.Collector.Database.Repositories; using Newsbot.Collector.Database.Repositories;
@ -10,19 +12,20 @@ namespace Newsbot.Collector.Api.Controllers;
[ApiController] [ApiController]
[Route("api/subscriptions")] [Route("api/subscriptions")]
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
public class SubscriptionsController : ControllerBase public class SubscriptionsController : ControllerBase
{ {
private readonly IDiscordWebHooksRepository _discord;
private readonly ILogger<SubscriptionsController> _logger; private readonly ILogger<SubscriptionsController> _logger;
private readonly IDiscordWebHooksRepository _discord;
private readonly ISourcesRepository _sources; private readonly ISourcesRepository _sources;
private readonly ISubscriptionRepository _subscription; private readonly ISubscriptionRepository _subscription;
public SubscriptionsController(ILogger<SubscriptionsController> logger, IOptions<ConnectionStrings> settings) public SubscriptionsController(ILogger<SubscriptionsController> logger, IDiscordWebHooksRepository discord, ISourcesRepository sources, ISubscriptionRepository subscription)
{ {
_logger = logger; _logger = logger;
_subscription = new SubscriptionsTable(settings.Value.Database); _discord = discord;
_discord = new DiscordWebhooksTable(settings.Value.Database); _sources = sources;
_sources = new SourcesTable(settings.Value.Database); _subscription = subscription;
} }
[HttpGet(Name = "ListSubscriptions")] [HttpGet(Name = "ListSubscriptions")]

View File

@ -1,7 +1,10 @@
using Hangfire; using Hangfire;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Newsbot.Collector.Domain.Models.Config; using Newsbot.Collector.Domain.Models.Config;
using Newsbot.Collector.Domain.Models.Config.Sources;
using Newsbot.Collector.Services.Jobs; using Newsbot.Collector.Services.Jobs;
using ILogger = Grpc.Core.Logging.ILogger; using ILogger = Grpc.Core.Logging.ILogger;
@ -9,6 +12,7 @@ namespace Newsbot.Collector.Api.Controllers;
[ApiController] [ApiController]
[Route("api/youtube")] [Route("api/youtube")]
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
public class YoutubeController public class YoutubeController
{ {
private readonly ILogger<YoutubeController> _logger; private readonly ILogger<YoutubeController> _logger;