diff --git a/Kyoo/Models/DatabaseContext.cs b/Kyoo/Models/DatabaseContext.cs index d997f6eb..3c19d7d1 100644 --- a/Kyoo/Models/DatabaseContext.cs +++ b/Kyoo/Models/DatabaseContext.cs @@ -69,13 +69,13 @@ namespace Kyoo modelBuilder.Entity() .Ignore(x => x.Genres); - // modelBuilder.Entity().ToTable("User"); - // modelBuilder.Entity>().ToTable("UserRole"); - // modelBuilder.Entity>().ToTable("UserLogin"); - // modelBuilder.Entity>().ToTable("UserClaim"); - // modelBuilder.Entity().ToTable("UserRoles"); - // modelBuilder.Entity>().ToTable("UserRoleClaim"); - // modelBuilder.Entity>().ToTable("UserToken"); + modelBuilder.Entity().ToTable("User"); + modelBuilder.Entity>().ToTable("UserRole"); + modelBuilder.Entity>().ToTable("UserLogin"); + modelBuilder.Entity>().ToTable("UserClaim"); + modelBuilder.Entity().ToTable("UserRoles"); + modelBuilder.Entity>().ToTable("UserRoleClaim"); + modelBuilder.Entity>().ToTable("UserToken"); } } } diff --git a/Kyoo/Models/DatabaseMigrations/Internal/20200330024910_Initial.Designer.cs b/Kyoo/Models/DatabaseMigrations/Internal/20200330171153_Initial.Designer.cs similarity index 98% rename from Kyoo/Models/DatabaseMigrations/Internal/20200330024910_Initial.Designer.cs rename to Kyoo/Models/DatabaseMigrations/Internal/20200330171153_Initial.Designer.cs index 8fc847af..e372c27b 100644 --- a/Kyoo/Models/DatabaseMigrations/Internal/20200330024910_Initial.Designer.cs +++ b/Kyoo/Models/DatabaseMigrations/Internal/20200330171153_Initial.Designer.cs @@ -6,10 +6,10 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -namespace Kyoo.Models.DatabaseMigrations +namespace Kyoo.Models.DatabaseMigrations.Internal { [DbContext(typeof(DatabaseContext))] - [Migration("20200330024910_Initial")] + [Migration("20200330171153_Initial")] partial class Initial { protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -544,7 +544,7 @@ namespace Kyoo.Models.DatabaseMigrations .IsUnique() .HasName("UserNameIndex"); - b.ToTable("AspNetUsers"); + b.ToTable("User"); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => @@ -570,7 +570,7 @@ namespace Kyoo.Models.DatabaseMigrations .IsUnique() .HasName("RoleNameIndex"); - b.ToTable("AspNetRoles"); + b.ToTable("UserRoles"); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => @@ -593,7 +593,7 @@ namespace Kyoo.Models.DatabaseMigrations b.HasIndex("RoleId"); - b.ToTable("AspNetRoleClaims"); + b.ToTable("UserRoleClaim"); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => @@ -616,7 +616,7 @@ namespace Kyoo.Models.DatabaseMigrations b.HasIndex("UserId"); - b.ToTable("AspNetUserClaims"); + b.ToTable("UserClaim"); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => @@ -640,7 +640,7 @@ namespace Kyoo.Models.DatabaseMigrations b.HasIndex("UserId"); - b.ToTable("AspNetUserLogins"); + b.ToTable("UserLogin"); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => @@ -655,7 +655,7 @@ namespace Kyoo.Models.DatabaseMigrations b.HasIndex("RoleId"); - b.ToTable("AspNetUserRoles"); + b.ToTable("UserRole"); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => @@ -676,7 +676,7 @@ namespace Kyoo.Models.DatabaseMigrations b.HasKey("UserId", "LoginProvider", "Name"); - b.ToTable("AspNetUserTokens"); + b.ToTable("UserToken"); }); modelBuilder.Entity("Kyoo.Models.CollectionLink", b => diff --git a/Kyoo/Models/DatabaseMigrations/Internal/20200330024910_Initial.cs b/Kyoo/Models/DatabaseMigrations/Internal/20200330171153_Initial.cs similarity index 91% rename from Kyoo/Models/DatabaseMigrations/Internal/20200330024910_Initial.cs rename to Kyoo/Models/DatabaseMigrations/Internal/20200330171153_Initial.cs index 0e6b9efe..63a5aad6 100644 --- a/Kyoo/Models/DatabaseMigrations/Internal/20200330024910_Initial.cs +++ b/Kyoo/Models/DatabaseMigrations/Internal/20200330171153_Initial.cs @@ -1,53 +1,12 @@ using System; using Microsoft.EntityFrameworkCore.Migrations; -namespace Kyoo.Models.DatabaseMigrations +namespace Kyoo.Models.DatabaseMigrations.Internal { public partial class Initial : Migration { protected override void Up(MigrationBuilder migrationBuilder) { - migrationBuilder.CreateTable( - name: "AspNetRoles", - columns: table => new - { - Id = table.Column(nullable: false), - Name = table.Column(maxLength: 256, nullable: true), - NormalizedName = table.Column(maxLength: 256, nullable: true), - ConcurrencyStamp = table.Column(nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetRoles", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AspNetUsers", - columns: table => new - { - Id = table.Column(nullable: false), - UserName = table.Column(maxLength: 256, nullable: true), - NormalizedUserName = table.Column(maxLength: 256, nullable: true), - Email = table.Column(maxLength: 256, nullable: true), - NormalizedEmail = table.Column(maxLength: 256, nullable: true), - EmailConfirmed = table.Column(nullable: false), - PasswordHash = table.Column(nullable: true), - SecurityStamp = table.Column(nullable: true), - ConcurrencyStamp = table.Column(nullable: true), - PhoneNumber = table.Column(nullable: true), - PhoneNumberConfirmed = table.Column(nullable: false), - TwoFactorEnabled = table.Column(nullable: false), - LockoutEnd = table.Column(nullable: true), - LockoutEnabled = table.Column(nullable: false), - AccessFailedCount = table.Column(nullable: false), - OTAC = table.Column(nullable: true), - OTACExpires = table.Column(nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetUsers", x => x.Id); - }); - migrationBuilder.CreateTable( name: "Collections", columns: table => new @@ -158,109 +117,44 @@ namespace Kyoo.Models.DatabaseMigrations }); migrationBuilder.CreateTable( - name: "AspNetRoleClaims", + name: "User", columns: table => new { - Id = table.Column(nullable: false) - .Annotation("Sqlite:Autoincrement", true), - RoleId = table.Column(nullable: false), - ClaimType = table.Column(nullable: true), - ClaimValue = table.Column(nullable: true) + Id = table.Column(nullable: false), + UserName = table.Column(maxLength: 256, nullable: true), + NormalizedUserName = table.Column(maxLength: 256, nullable: true), + Email = table.Column(maxLength: 256, nullable: true), + NormalizedEmail = table.Column(maxLength: 256, nullable: true), + EmailConfirmed = table.Column(nullable: false), + PasswordHash = table.Column(nullable: true), + SecurityStamp = table.Column(nullable: true), + ConcurrencyStamp = table.Column(nullable: true), + PhoneNumber = table.Column(nullable: true), + PhoneNumberConfirmed = table.Column(nullable: false), + TwoFactorEnabled = table.Column(nullable: false), + LockoutEnd = table.Column(nullable: true), + LockoutEnabled = table.Column(nullable: false), + AccessFailedCount = table.Column(nullable: false), + OTAC = table.Column(nullable: true), + OTACExpires = table.Column(nullable: true) }, constraints: table => { - table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id); - table.ForeignKey( - name: "FK_AspNetRoleClaims_AspNetRoles_RoleId", - column: x => x.RoleId, - principalTable: "AspNetRoles", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); + table.PrimaryKey("PK_User", x => x.Id); }); migrationBuilder.CreateTable( - name: "AspNetUserClaims", + name: "UserRoles", columns: table => new { - Id = table.Column(nullable: false) - .Annotation("Sqlite:Autoincrement", true), - UserId = table.Column(nullable: false), - ClaimType = table.Column(nullable: true), - ClaimValue = table.Column(nullable: true) + Id = table.Column(nullable: false), + Name = table.Column(maxLength: 256, nullable: true), + NormalizedName = table.Column(maxLength: 256, nullable: true), + ConcurrencyStamp = table.Column(nullable: true) }, constraints: table => { - table.PrimaryKey("PK_AspNetUserClaims", x => x.Id); - table.ForeignKey( - name: "FK_AspNetUserClaims_AspNetUsers_UserId", - column: x => x.UserId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AspNetUserLogins", - columns: table => new - { - LoginProvider = table.Column(maxLength: 128, nullable: false), - ProviderKey = table.Column(maxLength: 128, nullable: false), - ProviderDisplayName = table.Column(nullable: true), - UserId = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey }); - table.ForeignKey( - name: "FK_AspNetUserLogins_AspNetUsers_UserId", - column: x => x.UserId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AspNetUserRoles", - columns: table => new - { - UserId = table.Column(nullable: false), - RoleId = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId }); - table.ForeignKey( - name: "FK_AspNetUserRoles_AspNetRoles_RoleId", - column: x => x.RoleId, - principalTable: "AspNetRoles", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_AspNetUserRoles_AspNetUsers_UserId", - column: x => x.UserId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AspNetUserTokens", - columns: table => new - { - UserId = table.Column(nullable: false), - LoginProvider = table.Column(maxLength: 128, nullable: false), - Name = table.Column(maxLength: 128, nullable: false), - Value = table.Column(nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name }); - table.ForeignKey( - name: "FK_AspNetUserTokens_AspNetUsers_UserId", - column: x => x.UserId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); + table.PrimaryKey("PK_UserRoles", x => x.Id); }); migrationBuilder.CreateTable( @@ -297,6 +191,112 @@ namespace Kyoo.Models.DatabaseMigrations onDelete: ReferentialAction.Restrict); }); + migrationBuilder.CreateTable( + name: "UserClaim", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("Sqlite:Autoincrement", true), + UserId = table.Column(nullable: false), + ClaimType = table.Column(nullable: true), + ClaimValue = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_UserClaim", x => x.Id); + table.ForeignKey( + name: "FK_UserClaim_User_UserId", + column: x => x.UserId, + principalTable: "User", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "UserLogin", + columns: table => new + { + LoginProvider = table.Column(maxLength: 128, nullable: false), + ProviderKey = table.Column(maxLength: 128, nullable: false), + ProviderDisplayName = table.Column(nullable: true), + UserId = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_UserLogin", x => new { x.LoginProvider, x.ProviderKey }); + table.ForeignKey( + name: "FK_UserLogin_User_UserId", + column: x => x.UserId, + principalTable: "User", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "UserToken", + columns: table => new + { + UserId = table.Column(nullable: false), + LoginProvider = table.Column(maxLength: 128, nullable: false), + Name = table.Column(maxLength: 128, nullable: false), + Value = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_UserToken", x => new { x.UserId, x.LoginProvider, x.Name }); + table.ForeignKey( + name: "FK_UserToken_User_UserId", + column: x => x.UserId, + principalTable: "User", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "UserRole", + columns: table => new + { + UserId = table.Column(nullable: false), + RoleId = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_UserRole", x => new { x.UserId, x.RoleId }); + table.ForeignKey( + name: "FK_UserRole_UserRoles_RoleId", + column: x => x.RoleId, + principalTable: "UserRoles", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_UserRole_User_UserId", + column: x => x.UserId, + principalTable: "User", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "UserRoleClaim", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("Sqlite:Autoincrement", true), + RoleId = table.Column(nullable: false), + ClaimType = table.Column(nullable: true), + ClaimValue = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_UserRoleClaim", x => x.Id); + table.ForeignKey( + name: "FK_UserRoleClaim_UserRoles_RoleId", + column: x => x.RoleId, + principalTable: "UserRoles", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + migrationBuilder.CreateTable( name: "CollectionLinks", columns: table => new @@ -496,43 +496,6 @@ namespace Kyoo.Models.DatabaseMigrations onDelete: ReferentialAction.Cascade); }); - migrationBuilder.CreateIndex( - name: "IX_AspNetRoleClaims_RoleId", - table: "AspNetRoleClaims", - column: "RoleId"); - - migrationBuilder.CreateIndex( - name: "RoleNameIndex", - table: "AspNetRoles", - column: "NormalizedName", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_AspNetUserClaims_UserId", - table: "AspNetUserClaims", - column: "UserId"); - - migrationBuilder.CreateIndex( - name: "IX_AspNetUserLogins_UserId", - table: "AspNetUserLogins", - column: "UserId"); - - migrationBuilder.CreateIndex( - name: "IX_AspNetUserRoles_RoleId", - table: "AspNetUserRoles", - column: "RoleId"); - - migrationBuilder.CreateIndex( - name: "EmailIndex", - table: "AspNetUsers", - column: "NormalizedEmail"); - - migrationBuilder.CreateIndex( - name: "UserNameIndex", - table: "AspNetUsers", - column: "NormalizedUserName", - unique: true); - migrationBuilder.CreateIndex( name: "IX_CollectionLinks_CollectionID", table: "CollectionLinks", @@ -618,25 +581,47 @@ namespace Kyoo.Models.DatabaseMigrations name: "IX_Tracks_EpisodeID", table: "Tracks", column: "EpisodeID"); + + migrationBuilder.CreateIndex( + name: "EmailIndex", + table: "User", + column: "NormalizedEmail"); + + migrationBuilder.CreateIndex( + name: "UserNameIndex", + table: "User", + column: "NormalizedUserName", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_UserClaim_UserId", + table: "UserClaim", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_UserLogin_UserId", + table: "UserLogin", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_UserRole_RoleId", + table: "UserRole", + column: "RoleId"); + + migrationBuilder.CreateIndex( + name: "IX_UserRoleClaim_RoleId", + table: "UserRoleClaim", + column: "RoleId"); + + migrationBuilder.CreateIndex( + name: "RoleNameIndex", + table: "UserRoles", + column: "NormalizedName", + unique: true); } protected override void Down(MigrationBuilder migrationBuilder) { - migrationBuilder.DropTable( - name: "AspNetRoleClaims"); - - migrationBuilder.DropTable( - name: "AspNetUserClaims"); - - migrationBuilder.DropTable( - name: "AspNetUserLogins"); - - migrationBuilder.DropTable( - name: "AspNetUserRoles"); - - migrationBuilder.DropTable( - name: "AspNetUserTokens"); - migrationBuilder.DropTable( name: "CollectionLinks"); @@ -659,10 +644,19 @@ namespace Kyoo.Models.DatabaseMigrations name: "Tracks"); migrationBuilder.DropTable( - name: "AspNetRoles"); + name: "UserClaim"); migrationBuilder.DropTable( - name: "AspNetUsers"); + name: "UserLogin"); + + migrationBuilder.DropTable( + name: "UserRole"); + + migrationBuilder.DropTable( + name: "UserRoleClaim"); + + migrationBuilder.DropTable( + name: "UserToken"); migrationBuilder.DropTable( name: "Genres"); @@ -679,6 +673,12 @@ namespace Kyoo.Models.DatabaseMigrations migrationBuilder.DropTable( name: "Episodes"); + migrationBuilder.DropTable( + name: "UserRoles"); + + migrationBuilder.DropTable( + name: "User"); + migrationBuilder.DropTable( name: "Seasons"); diff --git a/Kyoo/Models/DatabaseMigrations/Internal/DatabaseContextModelSnapshot.cs b/Kyoo/Models/DatabaseMigrations/Internal/DatabaseContextModelSnapshot.cs index 1fd162e4..7a0d8df9 100644 --- a/Kyoo/Models/DatabaseMigrations/Internal/DatabaseContextModelSnapshot.cs +++ b/Kyoo/Models/DatabaseMigrations/Internal/DatabaseContextModelSnapshot.cs @@ -5,7 +5,7 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -namespace Kyoo.Models.DatabaseMigrations +namespace Kyoo.Models.DatabaseMigrations.Internal { [DbContext(typeof(DatabaseContext))] partial class DatabaseContextModelSnapshot : ModelSnapshot @@ -542,7 +542,7 @@ namespace Kyoo.Models.DatabaseMigrations .IsUnique() .HasName("UserNameIndex"); - b.ToTable("AspNetUsers"); + b.ToTable("User"); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => @@ -568,7 +568,7 @@ namespace Kyoo.Models.DatabaseMigrations .IsUnique() .HasName("RoleNameIndex"); - b.ToTable("AspNetRoles"); + b.ToTable("UserRoles"); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => @@ -591,7 +591,7 @@ namespace Kyoo.Models.DatabaseMigrations b.HasIndex("RoleId"); - b.ToTable("AspNetRoleClaims"); + b.ToTable("UserRoleClaim"); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => @@ -614,7 +614,7 @@ namespace Kyoo.Models.DatabaseMigrations b.HasIndex("UserId"); - b.ToTable("AspNetUserClaims"); + b.ToTable("UserClaim"); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => @@ -638,7 +638,7 @@ namespace Kyoo.Models.DatabaseMigrations b.HasIndex("UserId"); - b.ToTable("AspNetUserLogins"); + b.ToTable("UserLogin"); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => @@ -653,7 +653,7 @@ namespace Kyoo.Models.DatabaseMigrations b.HasIndex("RoleId"); - b.ToTable("AspNetUserRoles"); + b.ToTable("UserRole"); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => @@ -674,7 +674,7 @@ namespace Kyoo.Models.DatabaseMigrations b.HasKey("UserId", "LoginProvider", "Name"); - b.ToTable("AspNetUserTokens"); + b.ToTable("UserToken"); }); modelBuilder.Entity("Kyoo.Models.CollectionLink", b => diff --git a/Kyoo/Startup.cs b/Kyoo/Startup.cs index 2702c410..c59a677d 100644 --- a/Kyoo/Startup.cs +++ b/Kyoo/Startup.cs @@ -84,11 +84,11 @@ namespace Kyoo services.AddAuthorization(options => { - options.AddPolicy("Read", policy => policy.RequireScope("kyoo.read").RequireClaim("read")); - options.AddPolicy("Write", policy => policy.RequireScope("kyoo.write").RequireClaim("write")); - options.AddPolicy("Play", policy => policy.RequireScope("kyoo.play").RequireClaim("play")); - options.AddPolicy("Download", policy => policy.RequireScope("kyoo.download").RequireClaim("download")); - options.AddPolicy("Admin", policy => policy.RequireScope("kyoo.admin").RequireClaim("admin")); + options.AddPolicy("Read", policy => policy.RequireScope("kyoo.read").RequireClaim("kyoo.read")); //Checked from the access token so kyoo.read is not here but it is inside the permissions string-array. + options.AddPolicy("Write", policy => policy.RequireScope("kyoo.write").RequireClaim("kyoo.write")); + options.AddPolicy("Play", policy => policy.RequireScope("kyoo.play").RequireClaim("kyoo.play")); + options.AddPolicy("Download", policy => policy.RequireScope("kyoo.download").RequireClaim("kyoo.download")); + options.AddPolicy("Admin", policy => policy.RequireScope("kyoo.admin").RequireClaim("kyoo.admin")); }); services.AddScoped(); diff --git a/Kyoo/Views/API/AccountAPI.cs b/Kyoo/Views/API/AccountAPI.cs index 1eea4b5f..b3cc61f6 100644 --- a/Kyoo/Views/API/AccountAPI.cs +++ b/Kyoo/Views/API/AccountAPI.cs @@ -55,8 +55,8 @@ namespace Kyoo.Api public Claim[] defaultClaims = { - new Claim("read", ""), - new Claim("play", "") + new Claim("kyoo.read", ""), + new Claim("kyoo.play", "") }; // TODO should add this field on the server's configuration page. public AccountController(UserManager userManager, SignInManager siginInManager, IConfiguration configuration) @@ -125,6 +125,10 @@ namespace Kyoo.Api new Claim("username", user.UserName), new Claim("picture", $"api/account/picture/{user.UserName}") }; + + IList userClaims = await _userManager.GetClaimsAsync(user); + IEnumerable permissions = from claim in userClaims where claim.Type.StartsWith("kyoo.") select claim.Type.Substring(claim.Type.IndexOf(".") + 1); + claims.Add(new Claim("permissions", string.Join(",", permissions))); context.IssuedClaims.AddRange(claims); } diff --git a/Kyoo/Views/API/LibrariesAPI.cs b/Kyoo/Views/API/LibrariesAPI.cs index 0bc4f1f5..75233fc1 100644 --- a/Kyoo/Views/API/LibrariesAPI.cs +++ b/Kyoo/Views/API/LibrariesAPI.cs @@ -3,6 +3,7 @@ using Kyoo.Models; using Microsoft.AspNetCore.Mvc; using System.Collections.Generic; using System.Linq; +using Microsoft.AspNetCore.Authorization; namespace Kyoo.Api { @@ -24,6 +25,7 @@ namespace Kyoo.Api } [HttpGet("{librarySlug}")] + [Authorize(Policy="Read")] public ActionResult> GetShows(string librarySlug) { Library library = _libraryManager.GetLibrary(librarySlug); diff --git a/Kyoo/Views/API/ShowsAPI.cs b/Kyoo/Views/API/ShowsAPI.cs index 05beb8bb..67913293 100644 --- a/Kyoo/Views/API/ShowsAPI.cs +++ b/Kyoo/Views/API/ShowsAPI.cs @@ -19,7 +19,7 @@ namespace Kyoo.Api } [HttpGet] - [Authorize] + [Authorize(Policy="Read")] public IEnumerable GetShows() { return _libraryManager.GetShows(); diff --git a/Kyoo/Views/WebClient b/Kyoo/Views/WebClient index 92924ddf..d0a4ef3f 160000 --- a/Kyoo/Views/WebClient +++ b/Kyoo/Views/WebClient @@ -1 +1 @@ -Subproject commit 92924ddfb62306c3e6ed7fe6462317f920686962 +Subproject commit d0a4ef3fdf6b25b64a160d0feae3223afadc8236 diff --git a/Kyoo/tempkey.rsa b/Kyoo/tempkey.rsa new file mode 100644 index 00000000..5fa49c77 --- /dev/null +++ b/Kyoo/tempkey.rsa @@ -0,0 +1 @@ +{"KeyId":"mkaygTF8pb-42wV_HvSUCQ","Parameters":{"D":"usyImLSKe8Gvh65XyygNoe9bCffxcB9maRAAL9tXou89QHc4WhPvCjRDlryOwNUxNWJvduDXJm+AenWbSx7/PNVzaKaK6j/GKt9OMsD//9ubEswP9zhNFn9zAzmWsp2wSMEM+1fU6VcXc9MCwjySP3DtHiw3ZwFUvfP4pm3PhKwaI3TKe2rmB9mwziiv9SSd+bwbKlVlGmMM4UVMwD/VYmJZZMB8NaQY2PmdJHztyp4NYJIMFnGFaJVN9GSFC1qv2btKhlZrL7InGdATbzUC82+Ff0st5YX4omJyb8DJ25SiCSXzKkeLWafcCedYdJwIPSxAgd9edCQLUNvORa26qQ==","DP":"0x2WZoveXkd9cYs4xGpL3cKmg5RQe1IBNy19tqLhpiCOqtzgz7agCbEBSsHsPQVclrQMp+GvBbuWTKEAj4DR/N2o+ir6V0W80VN8/2K4PX7wo9ryJAmUXNp4b231ubJv4neDGqF2j0g+WWxt5Gh6gx+FJjkGENYs5VJ7kFSc+fs=","DQ":"HQr0bM//+68PwegI6PSmFYgNMciMsnXGpn9xElU2Ed8EiF8dRW3LBjl8y3tsuZVwHbteZtlZJqUtd0kuwkC+5Kts1dEds8FOXfrZgpt/n+APOr14707yaxrcWhGkJu9kCjRsAbhsxtScxQE/sUb+5naTF5ypmORplL3O6ZnJ8L0=","Exponent":"AQAB","InverseQ":"IYckPpRj0eq7UF3YrzSt7sLPYdz/S1nfBJl4gNKEYvnwysaxg2iOq2u/4hu7+r1Jf8+j6e1dcOJqN4jPXyq2ycQ0X5BLNHENXBjvRrfaUD35bBMz2vKRq423sXPAV2k1Mpt6StZSAjyxF741IIQ+X1W5IVuuO9awK9ruw9bpR2I=","Modulus":"yoIp2j1kI5sku7k16xJNLEt7uw4LQY+UX3onsgdf69aNNXk2j6IyoW6dE9lAGRYKsNkKSH2kvUBTHCX78j0Mg0dInNyB1s7MgS5t8ypc4y5lIE+xFEXKAKeH6lZ9NC+PNwtCSY9iNAteiPO1ittmzkS7QR9fgHQ/8NwYuU3AxQUxf5QULuYWIE4rKryQHqlQzqvg7cZizcuINXxG3oUiSGWg1aYQUcjY07wWJFvVwsV7pjKTSL0edDCoqg8bQ/F97aDuP4e0QKaALs1GkXb854Kp977EitxLOAYkJrq4X/OkTZjwXjQhXnDwiwacuCnqLpDz4OX1Nr7EKJz1ZzmGrw==","P":"7zjThXlm/qG07URGqKTnq1QWGwoCCxXfVK5u0xbzhuPtjISAk2ijs4Bp7XNbQD63zdO52k7F8od8s4HXBjCG5rzpMNxpMef3SPfBX2f726XtQQYhXEW90iXeIUl55Hp41M+CO9GQs4XOy+k/AtkDbbaR7EKAQP7w4ddhRSJUyqM=","Q":"2LYnkzwnZdd4Femjg/6whVLFJZ8g78dew/0SnlX++3ShOX9GheACcunKVs6LD8X9ALay2ondx+4qRuep0wphc4UK6HoN9S/GnhJZDt2GjfAPPPegEfOEW+jIcX/COYX1unfcCVb17Cl+dWfQRa6RXtvfputA1u6N+wb0wtcmwIU="}} \ No newline at end of file