You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
jellyfin/MediaBrowser.Controller/Net/AuthenticatedAttribute.cs

71 lines
2.2 KiB

using System;
6 years ago
using MediaBrowser.Model.Services;
using Microsoft.AspNetCore.Http;
6 years ago
namespace MediaBrowser.Controller.Net
{
public class AuthenticatedAttribute : Attribute, IHasRequestFilter, IAuthenticationAttributes
{
public static IAuthService AuthService { get; set; }
/// <summary>
/// Gets or sets the roles.
/// </summary>
/// <value>The roles.</value>
public string Roles { get; set; }
/// <summary>
/// Gets or sets a value indicating whether [escape parental control].
/// </summary>
/// <value><c>true</c> if [escape parental control]; otherwise, <c>false</c>.</value>
public bool EscapeParentalControl { get; set; }
/// <summary>
/// Gets or sets a value indicating whether [allow before startup wizard].
/// </summary>
/// <value><c>true</c> if [allow before startup wizard]; otherwise, <c>false</c>.</value>
public bool AllowBeforeStartupWizard { get; set; }
public bool AllowLocal { get; set; }
/// <summary>
/// The request filter is executed before the service.
/// </summary>
/// <param name="request">The http request wrapper.</param>
/// <param name="response">The http response wrapper.</param>
/// <param name="requestDto">The request DTO.</param>
public void RequestFilter(IRequest request, HttpResponse response, object requestDto)
6 years ago
{
AuthService.Authenticate(request, this);
}
/// <summary>
/// Order in which Request Filters are executed.
/// &lt;0 Executed before global request filters
/// &gt;0 Executed after global request filters
/// </summary>
/// <value>The priority.</value>
public int Priority => 0;
6 years ago
public string[] GetRoles()
{
return (Roles ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
6 years ago
}
public bool AllowLocalOnly { get; set; }
}
public interface IAuthenticationAttributes
{
bool EscapeParentalControl { get; }
6 years ago
bool AllowBeforeStartupWizard { get; }
6 years ago
bool AllowLocal { get; }
6 years ago
bool AllowLocalOnly { get; }
string[] GetRoles();
}
}