Merging the authorization branch

This commit is contained in:
Zoe Roux
2021-05-05 22:33:49 +02:00
11 changed files with 136 additions and 110 deletions
@@ -0,0 +1,24 @@
using Microsoft.AspNetCore.Authorization;
namespace Kyoo.Authentication
{
/// <summary>
/// The requirement of Kyoo's authentication policies.
/// </summary>
public class AuthRequirement : IAuthorizationRequirement
{
/// <summary>
/// The name of the permission
/// </summary>
public string Permission { get; }
/// <summary>
/// Create a new <see cref="AuthRequirement"/> for the given permission.
/// </summary>
/// <param name="permission">The permission needed</param>
public AuthRequirement(string permission)
{
Permission = permission;
}
}
}
@@ -0,0 +1,25 @@
using System.Collections.Generic;
namespace Kyoo.Authentication.Models
{
/// <summary>
/// Permission options.
/// </summary>
public class PermissionOption
{
/// <summary>
/// The path to get this option from the root configuration.
/// </summary>
public const string Path = "authentication:permissions";
/// <summary>
/// The default permissions that will be given to a non-connected user.
/// </summary>
public ICollection<string> Default { get; set; }
/// <summary>
/// Permissions applied to a new user.
/// </summary>
public ICollection<string> NewUser { get; set; }
}
}