mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Remove security mode to use a simple require verification bool
This commit is contained in:
parent
041abb732d
commit
78a3ae8aeb
20
.env.example
20
.env.example
@ -11,27 +11,15 @@ LIBRARY_LANGUAGES=en
|
||||
# A pattern (regex) to ignore video files.
|
||||
LIBRARY_IGNORE_PATTERN=".*/[dD]ownloads?/.*"
|
||||
|
||||
|
||||
# Available modes: open, logged, verif, invite
|
||||
# open means anyone can use your instance, even without an account (guest mode is enabled). To specify guest permissions, see UNLOGGED_PERMISSIONS.
|
||||
# verif means anyone can create an account but their account needs to be manually verified by an admin before they can use kyoo
|
||||
# invite means only created and verified accounts can access your instance. to allow someone else to use your instance, you need to invite them.
|
||||
SECURITY_MODE=verif
|
||||
|
||||
# Specify permissions of guest accounts. By default, if security mode is not open, this is empty.
|
||||
# You can specify this even if security mode is not open to allow guests users to see your
|
||||
# collection without behing able to play videos for example.
|
||||
# Default if SECURITY_MODE is open:
|
||||
# If this is true, new accounts wont have any permissions before you approve them in your admin dashboard.
|
||||
REQUIRE_ACCOUNT_VERIFICATION=true
|
||||
# Specify permissions of guest accounts, default is no permissions but you can allow anyone to use your instance without account by doing:
|
||||
# UNLOGGED_PERMISSIONS=overall.read,overall.play
|
||||
# Default if SECURITY_MODE is not open:
|
||||
# UNLOGGED_PERMISSIONS=
|
||||
# To allow anyone to browse your collection but prevent them from playing a video:
|
||||
# You can specify this to allow guests users to see your collection without behing able to play videos for example:
|
||||
# UNLOGGED_PERMISSIONS=overall.read
|
||||
|
||||
# Specify permissions of new accounts.
|
||||
# DEFAULT_PERMISSIONS=overall.read,overall.play
|
||||
|
||||
|
||||
# Hardware transcoding (equivalent of --profile docker compose option).
|
||||
COMPOSE_PROFILES= # vaapi or qsv or nvidia
|
||||
# the preset used during transcode. faster means worst quality, you can probably use a slower preset with hwaccels
|
||||
|
@ -69,11 +69,16 @@ namespace Kyoo.Authentication
|
||||
PermissionOption options =
|
||||
new()
|
||||
{
|
||||
Default = _configuration.GetValue("UNLOGGED_PERMISSIONS", "")!.Split(','),
|
||||
Default = _configuration
|
||||
.GetValue("UNLOGGED_PERMISSIONS", "overall.read,overall.play")!
|
||||
.Split(','),
|
||||
NewUser = _configuration
|
||||
.GetValue("DEFAULT_PERMISSIONS", "overall.read,overall.play")!
|
||||
.Split(','),
|
||||
SecurityMode = _configuration.GetValue("SECURITY_MODE", SecurityMode.Verif),
|
||||
RequireVerification = _configuration.GetValue(
|
||||
"REQUIRE_ACCOUNT_VERIFICATION",
|
||||
true
|
||||
),
|
||||
PublicUrl =
|
||||
_configuration.GetValue<string?>("PUBLIC_URL") ?? "http://localhost:8901",
|
||||
ApiKeys = _configuration.GetValue("KYOO_APIKEYS", string.Empty)!.Split(','),
|
||||
@ -128,16 +133,9 @@ namespace Kyoo.Authentication
|
||||
return acc;
|
||||
}
|
||||
return acc;
|
||||
}
|
||||
}
|
||||
),
|
||||
};
|
||||
if (!options.Default.Any())
|
||||
{
|
||||
options.Default =
|
||||
options.SecurityMode == SecurityMode.Open
|
||||
? new string[] {"overall.read", "overall.play"}
|
||||
: Array.Empty<string>();
|
||||
}
|
||||
services.AddSingleton(options);
|
||||
services.AddSingleton(
|
||||
new AuthenticationOption() { Secret = secret, Permissions = options, }
|
||||
|
@ -32,20 +32,15 @@ public class ServerInfo
|
||||
/// </summary>
|
||||
public string PublicUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Which security mode was chosen for this instance.
|
||||
/// </summary>
|
||||
public SecurityMode SecurityMode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// True if guest accounts are allowed on this instance.
|
||||
/// </summary>
|
||||
public bool AllowGuests { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// True if a user is able to register.
|
||||
/// True if new users needs to be verifed.
|
||||
/// </summary>
|
||||
public bool AllowRegister { get; set; }
|
||||
public bool RequireVerification { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The list of permissions available for the guest account.
|
||||
|
@ -23,27 +23,6 @@ using Kyoo.Abstractions.Models.Permissions;
|
||||
|
||||
namespace Kyoo.Authentication.Models;
|
||||
|
||||
public enum SecurityMode
|
||||
{
|
||||
/// <summary>
|
||||
/// Anyone can use your instance, even without an account (guest mode is enabled).
|
||||
/// To specify guest permissions, see UNLOGGED_PERMISSIONS.
|
||||
/// </summary>
|
||||
Open,
|
||||
|
||||
/// <summary>
|
||||
/// Anyone can create an account but their account needs to be manually verified
|
||||
/// by an admin before they can use kyoo.
|
||||
/// </summary>
|
||||
Verif,
|
||||
|
||||
/// <summary>
|
||||
/// Only created and verified accounts can access your instance. To allow someone else
|
||||
/// to use your instance, you need to invite them.
|
||||
/// </summary>
|
||||
Invite,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Permission options.
|
||||
/// </summary>
|
||||
@ -55,9 +34,9 @@ public class PermissionOption
|
||||
public const string Path = "authentication:permissions";
|
||||
|
||||
/// <summary>
|
||||
/// Which security mode was chosen for this instance.
|
||||
/// True if new users needs to be verifed.
|
||||
/// </summary>
|
||||
public SecurityMode SecurityMode { get; set; }
|
||||
public bool RequireVerification { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The default permissions that will be given to a non-connected user.
|
||||
|
@ -38,9 +38,8 @@ public class InfoApi(PermissionOption options) : ControllerBase
|
||||
return Ok(
|
||||
new ServerInfo()
|
||||
{
|
||||
SecurityMode = options.SecurityMode,
|
||||
AllowGuests = options.Default.Any(),
|
||||
AllowRegister = options.SecurityMode != SecurityMode.Invite,
|
||||
RequireVerification = options.RequireVerification,
|
||||
GuestPermissions = options.Default.ToList(),
|
||||
PublicUrl = options.PublicUrl,
|
||||
Oidc = options
|
||||
|
Loading…
x
Reference in New Issue
Block a user