Add guest permissions to server info

This commit is contained in:
Zoe Roux 2024-03-05 00:00:21 +01:00
parent df6f9ea71d
commit 158058b720
3 changed files with 20 additions and 12 deletions

View File

@ -31,6 +31,11 @@ public class ServerInfo
/// 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>
/// The list of permissions available for the guest account.
/// </summary>
public List<string> GuestPermissions { get; set; }
} }
public class OidcInfo public class OidcInfo

View File

@ -39,6 +39,7 @@ public class InfoApi(PermissionOption options) : ControllerBase
new ServerInfo() new ServerInfo()
{ {
AllowGuests = options.Default.Any(), AllowGuests = options.Default.Any(),
GuestPermissions = options.Default.ToList(),
Oidc = options Oidc = options
.OIDC.Select(x => new KeyValuePair<string, OidcInfo>( .OIDC.Select(x => new KeyValuePair<string, OidcInfo>(
x.Key, x.Key,

View File

@ -37,12 +37,14 @@ export const ServerInfoP = z.object({
* True if guest accounts are allowed on this instance. * True if guest accounts are allowed on this instance.
*/ */
allowGuests: z.boolean(), allowGuests: z.boolean(),
/*
* The list of permissions available for the guest account.
*/
guestPermissions: z.array(z.string()),
/* /*
* The list of oidc providers configured for this instance of kyoo. * The list of oidc providers configured for this instance of kyoo.
*/ */
oidc: z oidc: z.record(z.string(), OidcInfoP).transform((x) =>
.record(z.string(), OidcInfoP)
.transform((x) =>
Object.fromEntries( Object.fromEntries(
Object.entries(x).map(([provider, info]) => [ Object.entries(x).map(([provider, info]) => [
provider, provider,