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.
|
# A pattern (regex) to ignore video files.
|
||||||
LIBRARY_IGNORE_PATTERN=".*/[dD]ownloads?/.*"
|
LIBRARY_IGNORE_PATTERN=".*/[dD]ownloads?/.*"
|
||||||
|
|
||||||
|
# If this is true, new accounts wont have any permissions before you approve them in your admin dashboard.
|
||||||
# Available modes: open, logged, verif, invite
|
REQUIRE_ACCOUNT_VERIFICATION=true
|
||||||
# open means anyone can use your instance, even without an account (guest mode is enabled). To specify guest permissions, see UNLOGGED_PERMISSIONS.
|
# Specify permissions of guest accounts, default is no permissions but you can allow anyone to use your instance without account by doing:
|
||||||
# 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:
|
|
||||||
# UNLOGGED_PERMISSIONS=overall.read,overall.play
|
# UNLOGGED_PERMISSIONS=overall.read,overall.play
|
||||||
# Default if SECURITY_MODE is not open:
|
# You can specify this to allow guests users to see your collection without behing able to play videos for example:
|
||||||
# UNLOGGED_PERMISSIONS=
|
|
||||||
# To allow anyone to browse your collection but prevent them from playing a video:
|
|
||||||
# UNLOGGED_PERMISSIONS=overall.read
|
# UNLOGGED_PERMISSIONS=overall.read
|
||||||
|
|
||||||
# Specify permissions of new accounts.
|
# Specify permissions of new accounts.
|
||||||
# DEFAULT_PERMISSIONS=overall.read,overall.play
|
# DEFAULT_PERMISSIONS=overall.read,overall.play
|
||||||
|
|
||||||
|
|
||||||
# Hardware transcoding (equivalent of --profile docker compose option).
|
# Hardware transcoding (equivalent of --profile docker compose option).
|
||||||
COMPOSE_PROFILES= # vaapi or qsv or nvidia
|
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
|
# 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 =
|
PermissionOption options =
|
||||||
new()
|
new()
|
||||||
{
|
{
|
||||||
Default = _configuration.GetValue("UNLOGGED_PERMISSIONS", "")!.Split(','),
|
Default = _configuration
|
||||||
|
.GetValue("UNLOGGED_PERMISSIONS", "overall.read,overall.play")!
|
||||||
|
.Split(','),
|
||||||
NewUser = _configuration
|
NewUser = _configuration
|
||||||
.GetValue("DEFAULT_PERMISSIONS", "overall.read,overall.play")!
|
.GetValue("DEFAULT_PERMISSIONS", "overall.read,overall.play")!
|
||||||
.Split(','),
|
.Split(','),
|
||||||
SecurityMode = _configuration.GetValue("SECURITY_MODE", SecurityMode.Verif),
|
RequireVerification = _configuration.GetValue(
|
||||||
|
"REQUIRE_ACCOUNT_VERIFICATION",
|
||||||
|
true
|
||||||
|
),
|
||||||
PublicUrl =
|
PublicUrl =
|
||||||
_configuration.GetValue<string?>("PUBLIC_URL") ?? "http://localhost:8901",
|
_configuration.GetValue<string?>("PUBLIC_URL") ?? "http://localhost:8901",
|
||||||
ApiKeys = _configuration.GetValue("KYOO_APIKEYS", string.Empty)!.Split(','),
|
ApiKeys = _configuration.GetValue("KYOO_APIKEYS", string.Empty)!.Split(','),
|
||||||
@ -131,13 +136,6 @@ namespace Kyoo.Authentication
|
|||||||
}
|
}
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
if (!options.Default.Any())
|
|
||||||
{
|
|
||||||
options.Default =
|
|
||||||
options.SecurityMode == SecurityMode.Open
|
|
||||||
? new string[] {"overall.read", "overall.play"}
|
|
||||||
: Array.Empty<string>();
|
|
||||||
}
|
|
||||||
services.AddSingleton(options);
|
services.AddSingleton(options);
|
||||||
services.AddSingleton(
|
services.AddSingleton(
|
||||||
new AuthenticationOption() { Secret = secret, Permissions = options, }
|
new AuthenticationOption() { Secret = secret, Permissions = options, }
|
||||||
|
@ -32,20 +32,15 @@ public class ServerInfo
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string PublicUrl { get; set; }
|
public string PublicUrl { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Which security mode was chosen for this instance.
|
|
||||||
/// </summary>
|
|
||||||
public SecurityMode SecurityMode { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// True if guest accounts are allowed on this instance.
|
/// True if guest accounts are allowed on this instance.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool AllowGuests { get; set; }
|
public bool AllowGuests { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// True if a user is able to register.
|
/// True if new users needs to be verifed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool AllowRegister { get; set; }
|
public bool RequireVerification { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The list of permissions available for the guest account.
|
/// The list of permissions available for the guest account.
|
||||||
|
@ -23,27 +23,6 @@ using Kyoo.Abstractions.Models.Permissions;
|
|||||||
|
|
||||||
namespace Kyoo.Authentication.Models;
|
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>
|
/// <summary>
|
||||||
/// Permission options.
|
/// Permission options.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -55,9 +34,9 @@ public class PermissionOption
|
|||||||
public const string Path = "authentication:permissions";
|
public const string Path = "authentication:permissions";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Which security mode was chosen for this instance.
|
/// True if new users needs to be verifed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public SecurityMode SecurityMode { get; set; }
|
public bool RequireVerification { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The default permissions that will be given to a non-connected user.
|
/// The default permissions that will be given to a non-connected user.
|
||||||
|
@ -38,9 +38,8 @@ public class InfoApi(PermissionOption options) : ControllerBase
|
|||||||
return Ok(
|
return Ok(
|
||||||
new ServerInfo()
|
new ServerInfo()
|
||||||
{
|
{
|
||||||
SecurityMode = options.SecurityMode,
|
|
||||||
AllowGuests = options.Default.Any(),
|
AllowGuests = options.Default.Any(),
|
||||||
AllowRegister = options.SecurityMode != SecurityMode.Invite,
|
RequireVerification = options.RequireVerification,
|
||||||
GuestPermissions = options.Default.ToList(),
|
GuestPermissions = options.Default.ToList(),
|
||||||
PublicUrl = options.PublicUrl,
|
PublicUrl = options.PublicUrl,
|
||||||
Oidc = options
|
Oidc = options
|
||||||
|
Loading…
x
Reference in New Issue
Block a user