Cleaning up code convention inconsistencies

This commit is contained in:
amazing-username
2019-07-04 15:57:43 -04:00
parent bc209c2363
commit ada8fa79d3
21 changed files with 396 additions and 426 deletions
+3 -4
View File
@@ -10,16 +10,15 @@ namespace Icarus.Authorization.Handlers
{
public class HasScopeHandler : AuthorizationHandler<HasScopeRequirement>
{
protected override Task HandleRequirementAsync(AuthorizationHandlerContext context,
HasScopeRequirement requirement)
protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, HasScopeRequirement requirement)
{
if (!context.User.HasClaim(c => c.Type == "scope" && c.Issuer == requirement.Issuer))
{
return Task.CompletedTask;
}
var scopes = context.User.FindFirst(c => c.Type == "scope" &&
c.Issuer == requirement.Issuer).Value.Split(' ');
var scopes = context.User.FindFirst(c =>
c.Type == "scope" && c.Issuer == requirement.Issuer).Value.Split(' ');
if (scopes.Any(s => s == requirement.Scope))
{
+1 -3
View File
@@ -14,9 +14,7 @@ namespace Icarus.Database.Contexts
{
public DbSet<Album> Albums { get; set; }
public AlbumContext(DbContextOptions<AlbumContext> options)
: base(options)
{ }
public AlbumContext(DbContextOptions<AlbumContext> options) : base(options) { }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
+1 -3
View File
@@ -14,9 +14,7 @@ namespace Icarus.Database.Contexts
{
public DbSet<Artist> Artists { get; set; }
public ArtistContext(DbContextOptions<ArtistContext> options)
: base (options)
{ }
public ArtistContext(DbContextOptions<ArtistContext> options) : base (options) { }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
+1 -4
View File
@@ -13,10 +13,7 @@ namespace Icarus.Database.Contexts
public class GenreContext : DbContext
{
public DbSet<Genre> Genres { get; set; }
public GenreContext(DbContextOptions<GenreContext> options)
: base(options)
{ }
public GenreContext(DbContextOptions<GenreContext> options) : base(options) { }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
+1 -3
View File
@@ -15,9 +15,7 @@ namespace Icarus.Database.Contexts
public DbSet<Song> Songs { get; set; }
public SongContext(DbContextOptions<SongContext> options)
: base(options)
{ }
public SongContext(DbContextOptions<SongContext> options) : base(options) { }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
+1 -3
View File
@@ -15,9 +15,7 @@ namespace Icarus.Database.Contexts
public DbSet<User> Users { get; set; }
public UserContext(DbContextOptions<UserContext> options)
: base(options)
{ }
public UserContext(DbContextOptions<UserContext> options) : base(options) { }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
+1 -3
View File
@@ -14,9 +14,7 @@ namespace Icarus.Database.Contexts
{
public DbSet<Year> YearValues { get; set; }
public YearContext(DbContextOptions<YearContext> options)
: base(options)
{ }
public YearContext(DbContextOptions<YearContext> options) : base(options) { }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
+1 -2
View File
@@ -35,8 +35,7 @@ namespace Icarus
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
WebHost.CreateDefaultBuilder(args).UseStartup<Startup>()
.UseUrls("http://localhost:5002")
.ConfigureLogging(logging =>
{
+19 -34
View File
@@ -59,53 +59,43 @@ namespace Icarus
services.AddAuthorization(options =>
{
options.AddPolicy("download:songs", policy =>
policy
.Requirements
policy.Requirements
.Add(new HasScopeRequirement("download:songs", domain)));
options.AddPolicy("upload:songs", policy =>
policy
.Requirements
policy.Requirements
.Add(new HasScopeRequirement("upload:songs", domain)));
options.AddPolicy("delete:songs", policy =>
policy
.Requirements
policy.Requirements
.Add(new HasScopeRequirement("delete:songs", domain)));
options.AddPolicy("read:song_details", policy =>
policy
.Requirements
policy.Requirements
.Add(new HasScopeRequirement("read:song_details", domain)));
options.AddPolicy("update:songs", policy =>
policy
.Requirements
policy.Requirements
.Add(new HasScopeRequirement("update:songs", domain)));
options.AddPolicy("read:artists", policy =>
policy
.Requirements
policy.Requirements
.Add(new HasScopeRequirement("read:artists", domain)));
options.AddPolicy("read:albums", policy =>
policy
.Requirements
policy.Requirements
.Add(new HasScopeRequirement("read:albums", domain)));
options.AddPolicy("read:genre", policy =>
policy
.Requirements
policy.Requirements
.Add(new HasScopeRequirement("read:genre", domain)));
options.AddPolicy("read:year", policy =>
policy
.Requirements
policy.Requirements
.Add(new HasScopeRequirement("read:year", domain)));
options.AddPolicy("stream:songs", policy =>
policy
.Requirements
policy.Requirements
.Add(new HasScopeRequirement("stream:songs", domain)));
});
@@ -115,28 +105,22 @@ namespace Icarus
var connString = Configuration.GetConnectionString("DefaultConnection");
services.Add(new ServiceDescriptor(typeof(SongRepository),
new SongRepository(Configuration
.GetConnectionString("DefaultConnection"))));
new SongRepository(Configuration.GetConnectionString("DefaultConnection"))));
services.Add(new ServiceDescriptor(typeof(AlbumRepository),
new AlbumRepository(Configuration
.GetConnectionString("DefaultConnection"))));
new AlbumRepository(Configuration.GetConnectionString("DefaultConnection"))));
services.Add(new ServiceDescriptor(typeof(ArtistRepository),
new ArtistRepository(Configuration
.GetConnectionString("DefaultConnection"))));
new ArtistRepository(Configuration.GetConnectionString("DefaultConnection"))));
services.Add(new ServiceDescriptor(typeof(GenreRepository),
new GenreRepository(Configuration
.GetConnectionString("DefaultConnection"))));
new GenreRepository(Configuration.GetConnectionString("DefaultConnection"))));
services.Add(new ServiceDescriptor(typeof(YearRepository),
new YearRepository(Configuration
.GetConnectionString("DefaultConnection"))));
new YearRepository(Configuration.GetConnectionString("DefaultConnection"))));
services.Add(new ServiceDescriptor(typeof(UserRepository),
new UserRepository(Configuration
.GetConnectionString("DefaultConnection"))));
new UserRepository(Configuration.GetConnectionString("DefaultConnection"))));
services.AddDbContext<SongContext>(options => options.UseMySQL(connString));
services.AddDbContext<AlbumContext>(options => options.UseMySQL(connString));
@@ -146,7 +130,7 @@ namespace Icarus
services.AddDbContext<YearContext>(options => options.UseMySQL(connString));
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
// Called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
@@ -155,7 +139,8 @@ namespace Icarus
}
else
{
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
// The default HSTS value is 30 days.
// You may want to change this for production scenarios
app.UseHsts();
}