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.
/// </summary>
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

View File

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

View File

@ -37,22 +37,24 @@ export const ServerInfoP = z.object({
* True if guest accounts are allowed on this instance.
*/
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.
*/
oidc: z
.record(z.string(), OidcInfoP)
.transform((x) =>
Object.fromEntries(
Object.entries(x).map(([provider, info]) => [
provider,
{
...info,
link: imageFn(`/auth/login/${provider}?redirectUrl=${baseAppUrl()}/login/callback`),
},
]),
),
oidc: z.record(z.string(), OidcInfoP).transform((x) =>
Object.fromEntries(
Object.entries(x).map(([provider, info]) => [
provider,
{
...info,
link: imageFn(`/auth/login/${provider}?redirectUrl=${baseAppUrl()}/login/callback`),
},
]),
),
),
});
/**