Add redis prefix option

This commit is contained in:
Laura Hausmann 2024-01-28 00:59:57 +01:00
parent 135d26127b
commit f9480d096b
No known key found for this signature in database
GPG key ID: D044E84C5BE01605
4 changed files with 8 additions and 5 deletions

View file

@ -3,12 +3,12 @@ using J = System.Text.Json.Serialization.JsonPropertyNameAttribute;
namespace Iceshrimp.Backend.Controllers.Schemas;
public class AuthRequest {
[J("username")] public required string Username { get; set; }
[J("password")] public required string Password { get; set; }
[J("username")] public required string Username { get; set; }
[J("password")] public required string Password { get; set; }
}
public class RegistrationRequest : AuthRequest {
[J("invite")] public string? Invite { get; set; }
[J("invite")] public string? Invite { get; set; }
}
public class ChangePasswordRequest {

View file

@ -52,9 +52,10 @@ public sealed class Config {
public sealed class RedisSection {
public required string Host { get; init; } = "localhost";
public required int Port { get; init; } = 6379;
public int? Database { get; init; }
public string? Prefix { get; init; }
public string? Username { get; init; }
public string? Password { get; init; }
public int? Database { get; init; }
//TODO: TLS settings
}

View file

@ -70,6 +70,7 @@ public static class ServiceExtensions {
var config = configuration.GetSection("Redis").Get<Config.RedisSection>();
if (config == null) throw new Exception("Failed to initialize redis: Failed to load configuration");
services.AddStackExchangeRedisCache(options => {
options.InstanceName = config.Prefix;
options.ConfigurationOptions = new ConfigurationOptions {
User = config.Username,
Password = config.Password,

View file

@ -24,9 +24,10 @@ Password = iceshrimp
[Redis]
Host = localhost
Port = 6379
;;Database = 0
;;Prefix =
;;Username =
;;Password =
;;Database = 0
[Logging:LogLevel]
Default = Information